@@ -16,9 +16,6 @@ static bool g_gfxInitialized = 0;
1616static ViDisplay g_gfxDisplay ;
1717static Handle g_gfxDisplayVsyncEvent = INVALID_HANDLE ;
1818static ViLayer g_gfxLayer ;
19- static u8 g_gfxNativeWindow [0x100 ];
20- static u64 g_gfxNativeWindow_Size ;
21- static s32 g_gfxNativeWindow_ID ;
2219static Binder g_gfxBinderSession ;
2320static s32 g_gfxCurrentBuffer = 0 ;
2421static s32 g_gfxCurrentProducerBuffer = 0 ;
@@ -111,20 +108,6 @@ static BqGraphicBuffer g_gfx_BufferInitData = {
111108 }
112109};
113110
114- static Result _gfxGetNativeWindowID (u8 * buf , u64 size , s32 * out_ID ) {
115- u32 * bufptr = (u32 * )buf ;
116-
117- //Validate ParcelData{Size|Offset}.
118- if ((u64 )bufptr [1 ] > size || (u64 )bufptr [0 ] > size || ((u64 )bufptr [1 ])+ ((u64 )bufptr [0 ]) > size ) return MAKERESULT (Module_Libnx , LibnxError_BadInput );
119- if (bufptr [0 ] < 0xc ) return MAKERESULT (Module_Libnx , LibnxError_BadInput );
120- //bufptr = start of ParcelData
121- bufptr = (u32 * )& buf [bufptr [1 ]];
122-
123- * out_ID = (s32 )bufptr [2 ];
124-
125- return 0 ;
126- }
127-
128111static Result _gfxDequeueBuffer (void ) {
129112 Result rc = 0 ;
130113 BqFence * fence = & g_gfx_DequeueBuffer_fence ;
@@ -166,13 +149,12 @@ static Result _gfxQueueBuffer(s32 buf) {
166149 return rc ;
167150}
168151
169- static Result _gfxInit ( ViServiceType servicetype , const char * DisplayName , u32 LayerFlags , u64 LayerId ) {
152+ Result gfxInitDefault ( void ) {
170153 Result rc = 0 ;
171154 u32 i = 0 ;
172155
173156 if (g_gfxInitialized )return 0 ;
174157
175- g_gfxNativeWindow_ID = 0 ;
176158 g_gfxDisplayVsyncEvent = INVALID_HANDLE ;
177159 g_gfxCurrentBuffer = -1 ;
178160 g_gfxCurrentProducerBuffer = -1 ;
@@ -224,20 +206,18 @@ static Result _gfxInit(ViServiceType servicetype, const char *DisplayName, u32 L
224206 return rc ;
225207 }
226208
227- rc = viInitialize (servicetype );
209+ rc = viInitialize (ViServiceType_Default );
228210
229- if (R_SUCCEEDED (rc )) rc = viOpenDisplay ( DisplayName , & g_gfxDisplay );
211+ if (R_SUCCEEDED (rc )) rc = viOpenDefaultDisplay ( & g_gfxDisplay );
230212
231213 if (R_SUCCEEDED (rc )) rc = viGetDisplayVsyncEvent (& g_gfxDisplay , & g_gfxDisplayVsyncEvent );
232214
233- if (R_SUCCEEDED (rc )) rc = viOpenLayer ( g_gfxNativeWindow , & g_gfxNativeWindow_Size , & g_gfxDisplay , & g_gfxLayer , LayerFlags , LayerId );
215+ if (R_SUCCEEDED (rc )) rc = viCreateLayer ( & g_gfxDisplay , & g_gfxLayer );
234216
235217 if (R_SUCCEEDED (rc )) rc = viSetLayerScalingMode (& g_gfxLayer , ViScalingMode_Default );
236218
237- if (R_SUCCEEDED (rc )) rc = _gfxGetNativeWindowID (g_gfxNativeWindow , g_gfxNativeWindow_Size , & g_gfxNativeWindow_ID );
238-
239219 if (R_SUCCEEDED (rc )) {
240- binderCreate (& g_gfxBinderSession , viGetSession_IHOSBinderDriverRelay ()-> handle , g_gfxNativeWindow_ID );
220+ binderCreate (& g_gfxBinderSession , viGetSession_IHOSBinderDriverRelay ()-> handle , g_gfxLayer . igbp_binder_obj_id );
241221 rc = binderInitSession (& g_gfxBinderSession , 0x0f );
242222 }
243223
@@ -308,7 +288,6 @@ static Result _gfxInit(ViServiceType servicetype, const char *DisplayName, u32 L
308288 free (g_gfxFramebufLinear );
309289 g_gfxFramebufLinear = NULL ;
310290
311- g_gfxNativeWindow_ID = 0 ;
312291 g_gfxCurrentBuffer = 0 ;
313292 g_gfxCurrentProducerBuffer = -1 ;
314293 g_gfx_ProducerConnected = 0 ;
@@ -327,10 +306,6 @@ static Result _gfxInit(ViServiceType servicetype, const char *DisplayName, u32 L
327306 return rc ;
328307}
329308
330- Result gfxInitDefault (void ) {
331- return _gfxInit (ViServiceType_Default , "Default" , ViLayerFlags_Default , 0 );
332- }
333-
334309void gfxExit (void )
335310{
336311 u32 i = 0 ;
@@ -365,7 +340,6 @@ void gfxExit(void)
365340 g_gfxFramebufLinear = NULL ;
366341
367342 g_gfxInitialized = 0 ;
368- g_gfxNativeWindow_ID = 0 ;
369343
370344 g_gfxCurrentBuffer = 0 ;
371345 g_gfxCurrentProducerBuffer = -1 ;
0 commit comments