@@ -76,6 +76,8 @@ const GUID DECLSPEC_SELECTANY libretro_IID_IDXGIFactory5 = { 0x7632e1f5,0xee65,0
7676#endif
7777#endif
7878
79+ #define D3D11_ROLLING_SCANLINE_SIMULATION
80+
7981/* Temporary workaround for d3d11 not being able to poll flags during init */
8082static gfx_ctx_driver_t d3d11_fake_context ;
8183
@@ -3025,7 +3027,23 @@ static bool d3d11_gfx_frame(
30253027 context , width , height , pitch , d3d11 -> format , frame , & d3d11 -> frame .texture [0 ]);
30263028 }
30273029
3028- context -> lpVtbl -> RSSetState (context , d3d11 -> scissor_disabled );
3030+ #ifdef D3D11_ROLLING_SCANLINE_SIMULATION
3031+ if ( (video_info -> shader_subframes > 1 )
3032+ && (video_info -> scan_subframes )
3033+ && !black_frame_insertion
3034+ && !nonblock_state
3035+ && !runloop_is_slowmotion
3036+ && !runloop_is_paused
3037+ && (!(d3d11 -> flags & D3D11_ST_FLAG_MENU_ENABLE )))
3038+ {
3039+ context -> lpVtbl -> RSSetState (context , d3d11 -> scissor_enabled );
3040+ }
3041+ else
3042+ #endif // D3D11_ROLLING_SCANLINE_SIMULATION
3043+ {
3044+ context -> lpVtbl -> RSSetState (context , d3d11 -> scissor_disabled );
3045+ }
3046+
30293047 d3d11 -> context -> lpVtbl -> OMSetBlendState (
30303048 d3d11 -> context , d3d11 -> blend_disable ,
30313049 NULL , D3D11_DEFAULT_SAMPLE_MASK );
@@ -3158,6 +3176,41 @@ static bool d3d11_gfx_frame(
31583176 & d3d11 -> pass [i ].rt .rt_view , NULL );
31593177 context -> lpVtbl -> RSSetViewports (context , 1 , & d3d11 -> pass [i ].viewport );
31603178
3179+ #ifdef D3D11_ROLLING_SCANLINE_SIMULATION
3180+ if ( (video_info -> shader_subframes > 1 )
3181+ && (video_info -> scan_subframes )
3182+ && !black_frame_insertion
3183+ && !nonblock_state
3184+ && !runloop_is_slowmotion
3185+ && !runloop_is_paused
3186+ && (!(d3d11 -> flags & D3D11_ST_FLAG_MENU_ENABLE )))
3187+ {
3188+ D3D11_RECT scissor_rect ;
3189+
3190+ scissor_rect .left = 0 ;
3191+ scissor_rect .top = (unsigned int )(((float )d3d11 -> pass [i ].viewport .Height / (float )video_info -> shader_subframes )
3192+ * (float )video_info -> current_subframe );
3193+ scissor_rect .right = d3d11 -> pass [i ].viewport .Width ;
3194+ scissor_rect .bottom = (unsigned int )(((float )d3d11 -> pass [i ].viewport .Height / (float )video_info -> shader_subframes )
3195+ * (float )(video_info -> current_subframe + 1 ));
3196+
3197+ d3d11 -> context -> lpVtbl -> RSSetScissorRects (d3d11 -> context , 1 ,
3198+ & scissor_rect );
3199+ }
3200+ else
3201+ {
3202+ D3D11_RECT scissor_rect ;
3203+
3204+ scissor_rect .left = 0 ;
3205+ scissor_rect .top = 0 ;
3206+ scissor_rect .right = d3d11 -> pass [i ].viewport .Width ;
3207+ scissor_rect .bottom = d3d11 -> pass [i ].viewport .Height ;
3208+
3209+ d3d11 -> context -> lpVtbl -> RSSetScissorRects (d3d11 -> context , 1 ,
3210+ & scissor_rect );
3211+ }
3212+ #endif // D3D11_ROLLING_SCANLINE_SIMULATION
3213+
31613214 if (i == d3d11 -> shader_preset -> passes - 1 )
31623215 context -> lpVtbl -> Draw (context , 4 , 0 );
31633216 else
@@ -3204,6 +3257,33 @@ static bool d3d11_gfx_frame(
32043257 context -> lpVtbl -> VSSetConstantBuffers (context , 0 , 1 , & d3d11 -> frame .ubo );
32053258 }
32063259
3260+ #ifdef D3D11_ROLLING_SCANLINE_SIMULATION
3261+ if ( (video_info -> shader_subframes > 1 )
3262+ && (video_info -> scan_subframes )
3263+ && !black_frame_insertion
3264+ && !nonblock_state
3265+ && !runloop_is_slowmotion
3266+ && !runloop_is_paused
3267+ && (!(d3d11 -> flags & D3D11_ST_FLAG_MENU_ENABLE )))
3268+ {
3269+ D3D11_RECT scissor_rect ;
3270+
3271+ scissor_rect .left = 0 ;
3272+ scissor_rect .top = (unsigned int )(((float )video_height / (float )video_info -> shader_subframes )
3273+ * (float )video_info -> current_subframe );
3274+ scissor_rect .right = video_width ;
3275+ scissor_rect .bottom = (unsigned int )(((float )video_height / (float )video_info -> shader_subframes )
3276+ * (float )(video_info -> current_subframe + 1 ));
3277+
3278+ d3d11 -> context -> lpVtbl -> RSSetScissorRects (d3d11 -> context , 1 ,
3279+ & scissor_rect );
3280+ }
3281+ else
3282+ {
3283+ d3d11 -> context -> lpVtbl -> RSSetScissorRects (d3d11 -> context , 1 , & d3d11 -> scissor );
3284+ }
3285+ #endif // D3D11_ROLLING_SCANLINE_SIMULATION
3286+
32073287 context -> lpVtbl -> Draw (context , 4 , 0 );
32083288 context -> lpVtbl -> RSSetState (context , d3d11 -> scissor_enabled );
32093289 d3d11 -> context -> lpVtbl -> RSSetScissorRects (d3d11 -> context , 1 , & d3d11 -> scissor );
@@ -3458,6 +3538,10 @@ static bool d3d11_gfx_frame(
34583538 d3d11 -> flags |= D3D11_ST_FLAG_FRAME_DUPE_LOCK ;
34593539 for (k = 1 ; k < video_info -> shader_subframes ; k ++ )
34603540 {
3541+ #ifdef D3D11_ROLLING_SCANLINE_SIMULATION
3542+ video_info -> current_subframe = k ;
3543+ #endif // D3D11_ROLLING_SCANLINE_SIMULATION
3544+
34613545 if (d3d11 -> shader_preset )
34623546 for (m = 0 ; m < d3d11 -> shader_preset -> passes ; m ++ )
34633547 {
0 commit comments