21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL 31 #include "../SDL_egl_c.h" 35 #include <wrl/client.h> 39 static const int ANGLE_D3D_FEATURE_LEVEL_ANY = 0;
40 #define EGL_PLATFORM_ANGLE_ANGLE 0x3202 41 #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 42 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 43 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 44 #define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 45 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209 46 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B 47 #define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F 49 #define EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER 0x320B 57 WINRT_GLES_LoadLibrary(
_THIS,
const char *
path)
66 CreateWinrtEglWindow_Old_Function CreateWinrtEglWindow = (CreateWinrtEglWindow_Old_Function)
SDL_LoadFunction(
_this->egl_data->egl_dll_handle,
"CreateWinrtEglWindow");
67 if (CreateWinrtEglWindow) {
75 CoreWindow ^ native_win = CoreWindow::GetForCurrentThread();
76 Microsoft::WRL::ComPtr<IUnknown> cpp_win =
reinterpret_cast<IUnknown *
>(native_win);
88 Microsoft::WRL::ComPtr<IUnknown> cpp_display = video_data->
winrtEglWindow;
89 _this->egl_data->egl_display = ((eglGetDisplay_Old_Function)
_this->egl_data->eglGetDisplay)(cpp_display);
90 if (!
_this->egl_data->egl_display) {
91 return SDL_EGL_SetError(
"Could not get Windows 8.0 EGL display",
"eglGetDisplay");
95 return SDL_EGL_SetError(
"Could not initialize Windows 8.0 EGL",
"eglInitialize");
101 const EGLint defaultDisplayAttributes[] =
103 EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
104 EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER,
EGL_TRUE,
105 EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
EGL_TRUE,
109 const EGLint fl9_3DisplayAttributes[] =
111 EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
112 EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9,
113 EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3,
114 EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER,
EGL_TRUE,
115 EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
EGL_TRUE,
119 const EGLint warpDisplayAttributes[] =
121 EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
122 EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE,
123 EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER,
EGL_TRUE,
124 EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
EGL_TRUE,
134 eglGetPlatformDisplayEXT_Function eglGetPlatformDisplayEXT = (eglGetPlatformDisplayEXT_Function)
_this->egl_data->eglGetProcAddress(
"eglGetPlatformDisplayEXT");
135 if (!eglGetPlatformDisplayEXT) {
136 return SDL_EGL_SetError(
"Could not retrieve ANGLE/WinRT display function(s)",
"eglGetProcAddress");
139 #if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) 143 _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
EGL_DEFAULT_DISPLAY, defaultDisplayAttributes);
144 if (!
_this->egl_data->egl_display) {
145 return SDL_EGL_SetError(
"Could not get EGL display for Direct3D 10_0+",
"eglGetPlatformDisplayEXT");
155 _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes);
156 if (!
_this->egl_data->egl_display) {
157 return SDL_EGL_SetError(
"Could not get EGL display for Direct3D 9_3",
"eglGetPlatformDisplayEXT");
164 _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
EGL_DEFAULT_DISPLAY, warpDisplayAttributes);
165 if (!
_this->egl_data->egl_display) {
166 return SDL_EGL_SetError(
"Could not get EGL display for Direct3D WARP",
"eglGetPlatformDisplayEXT");
170 return SDL_EGL_SetError(
"Could not initialize WinRT 8.x+ EGL",
"eglInitialize");
180 WINRT_GLES_UnloadLibrary(
_THIS)
191 SDL_EGL_UnloadLibrary(
_this);
195 SDL_EGL_CreateContext_impl(WINRT)
196 SDL_EGL_SwapWindow_impl(WINRT)
197 SDL_EGL_MakeCurrent_impl(WINRT)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
#define EGL_DEFAULT_DISPLAY
static SDL_VideoDevice * _this
HRESULT(WINAPI *GetDpiForMonitor)(HMONITOR hmonitor
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if
IUnknown * winrtEglWindow
GLsizei const GLchar *const * path
void * SDL_LoadFunction(void *handle, const char *name)