File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ add_object_library_macros(GS_HIRES_OBJS ee/gs/src/gsHires.c
165165 _gsKit_create_passes
166166 gsKit_hires_sync
167167 gsKit_hires_flip
168+ gsKit_hires_flip_ext
168169 gsKit_hires_prepare_bg
169170 gsKit_hires_set_bg
170171 gsKit_hires_init_screen
Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ struct gsVertex
8282};
8383typedef struct gsVertex GSVERTEX ;
8484
85+ /// Flip mode for gsKit_hires_flip_ext
86+ typedef enum {
87+ GSFLIP_DIRECT = 0 , ///< Flip immediately, no vsync wait
88+ GSFLIP_VSYNC = 1 , ///< Wait for vsync before flipping
89+ GSFLIP_RATE_LIMIT_1 = 2 , ///< Limit to 60fps (1 vsync per frame)
90+ GSFLIP_RATE_LIMIT_2 = 3 ///< Limit to 30fps (2 vsyncs per frame)
91+ } GSFLIP_MODE ;
92+
8593#ifdef __cplusplus
8694extern "C" {
8795#endif
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ void gsKit_hires_sync(GSGLOBAL *gsGlobal);
2828/// Flips Draw Queue
2929void gsKit_hires_flip (GSGLOBAL * gsGlobal );
3030
31+ /// Flips Draw Queue with specified flip mode
32+ void gsKit_hires_flip_ext (GSGLOBAL * gsGlobal , GSFLIP_MODE mode );
33+
3134/// Converts PSM and interlacing for use as background image
3235void gsKit_hires_prepare_bg (GSGLOBAL * gsGlobal , GSTEXTURE * tex );
3336
Original file line number Diff line number Diff line change @@ -260,8 +260,35 @@ void gsKit_hires_sync(GSGLOBAL *gsGlobal)
260260
261261#if F_gsKit_hires_flip
262262void gsKit_hires_flip (GSGLOBAL * gsGlobal )
263+ {
264+ gsKit_hires_flip_ext (gsGlobal , GSFLIP_DIRECT );
265+ }
266+ #endif
267+
268+ #if F_gsKit_hires_flip_ext
269+ // State tracking for rate limiting
270+ static u32 __last_flip_vsync_count = 0 ;
271+
272+ void gsKit_hires_flip_ext (GSGLOBAL * gsGlobal , GSFLIP_MODE mode )
263273{
264274 u32 iY ;
275+ u32 vsync_end ;
276+
277+ // Handle vsync waiting based on mode
278+ switch (mode ) {
279+ case GSFLIP_DIRECT : vsync_end = __vsync_count ; break ;
280+ case GSFLIP_VSYNC : vsync_end = __vsync_count + 1 ; break ;
281+ case GSFLIP_RATE_LIMIT_1 : vsync_end = __last_flip_vsync_count + 1 ; break ;
282+ case GSFLIP_RATE_LIMIT_2 : vsync_end = __last_flip_vsync_count + 2 ; break ;
283+ }
284+
285+ // Wait for required vsyncs
286+ while (__vsync_count < vsync_end ) {
287+ WaitSema (__sema_vsync_id );
288+ }
289+
290+ // Update last flip vsync count
291+ __last_flip_vsync_count = __vsync_count ;
265292
266293 // HACK: The start of the first displayed line
267294 // this is needed by the hsync interrupt but must be
You can’t perform that action at this time.
0 commit comments