@@ -3305,7 +3305,6 @@ static bool d3d11_gfx_frame(
33053305 bool d3d11_hdr_enable = (d3d11 -> flags & D3D11_ST_FLAG_HDR_ENABLE ) ? true : false;
33063306 bool video_hdr_enable = video_info -> hdr_enable ;
33073307 DXGI_FORMAT back_buffer_format = d3d11 -> shader_preset && d3d11 -> shader_preset -> passes ? glslang_format_to_dxgi (d3d11 -> pass [d3d11 -> shader_preset -> passes - 1 ].semantics .format ) : d3d11 -> chain_formats [d3d11 -> chain_bit_depth ];
3308- bool use_back_buffer = back_buffer_format != d3d11 -> chain_formats [d3d11 -> chain_bit_depth ];
33093308#endif
33103309
33113310 if (d3d11 -> flags & D3D11_ST_FLAG_WAITABLE_SWAPCHAINS )
@@ -3736,50 +3735,36 @@ static bool d3d11_gfx_frame(
37363735 }
37373736 }
37383737
3739-
3740- #ifdef HAVE_DXGI_HDR
3741- if ( (d3d11 -> flags & D3D11_ST_FLAG_HDR_ENABLE )
3742- && use_back_buffer )
3743- {
3744- context -> lpVtbl -> OMSetRenderTargets (context , 1 ,
3745- & d3d11 -> back_buffer .rt_view , NULL );
3746- context -> lpVtbl -> ClearRenderTargetView (context ,
3747- d3d11 -> back_buffer .rt_view , d3d11 -> clearcolor );
3748- }
3749- else
3750- #endif
3751- {
3752- context -> lpVtbl -> OMSetRenderTargets (context , 1 , & rtv , NULL );
3753- context -> lpVtbl -> ClearRenderTargetView (context , rtv , d3d11 -> clearcolor );
3754- }
3738+ context -> lpVtbl -> OMSetRenderTargets (context , 1 , & rtv , NULL );
3739+ context -> lpVtbl -> ClearRenderTargetView (context , rtv , d3d11 -> clearcolor );
37553740
37563741 context -> lpVtbl -> RSSetViewports (context , 1 , & d3d11 -> frame .viewport );
37573742
37583743 if (texture )
37593744 {
37603745#ifdef HAVE_DXGI_HDR
3761- if ((d3d11 -> flags & D3D11_ST_FLAG_HDR_ENABLE )
3762- && !use_back_buffer )
3746+ if (d3d11 -> flags & D3D11_ST_FLAG_HDR_ENABLE )
37633747 {
37643748 d3d11_shader_t * shader = & d3d11 -> shaders [VIDEO_SHADER_STOCK_HDR ];
37653749 context -> lpVtbl -> IASetInputLayout (context , shader -> layout );
37663750 context -> lpVtbl -> VSSetShader (context , shader -> vs , NULL , 0 );
37673751 context -> lpVtbl -> PSSetShader (context , shader -> ps , NULL , 0 );
37683752 context -> lpVtbl -> GSSetShader (context , shader -> gs , NULL , 0 );
37693753
3770- if ( d3d11 -> hdr .ubo_values .source_size .width != width || d3d11 -> hdr .ubo_values .source_size .height != height ||
3771- d3d11 -> hdr .ubo_values .output_size .width != d3d11 -> frame .output_size .x || d3d11 -> hdr .ubo_values .output_size .height != d3d11 -> frame .output_size .y )
37723754 {
37733755 d3d11 -> hdr .ubo_values .source_size .width = width ;
37743756 d3d11 -> hdr .ubo_values .source_size .height = height ;
37753757
37763758 d3d11 -> hdr .ubo_values .output_size .width = d3d11 -> frame .output_size .x ;
37773759 d3d11 -> hdr .ubo_values .output_size .height = d3d11 -> frame .output_size .y ;
37783760
3761+ settings_t * settings = config_get_ptr ();
3762+ d3d11 -> hdr .ubo_values .scanlines = settings -> bools .video_hdr_scanlines ? 1.0f : 0.0f ;
3763+
37793764 D3D11_MAPPED_SUBRESOURCE mapped_ubo ;
37803765
37813766 d3d11 -> context -> lpVtbl -> Map (
3782- d3d11 -> context , (D3D11Resource )d3d11 -> hdr .ubo , 0 , D3D11_MAP_WRITE_NO_OVERWRITE , 0 , & mapped_ubo );
3767+ d3d11 -> context , (D3D11Resource )d3d11 -> hdr .ubo , 0 , D3D11_MAP_WRITE_DISCARD , 0 , & mapped_ubo );
37833768 {
37843769 dxgi_hdr_uniform_t * ubo = (dxgi_hdr_uniform_t * )mapped_ubo .pData ;
37853770 * ubo = d3d11 -> hdr .ubo_values ;
@@ -3837,6 +3822,19 @@ static bool d3d11_gfx_frame(
38373822
38383823 context -> lpVtbl -> Draw (context , 4 , 0 );
38393824
3825+ #ifdef HAVE_DXGI_HDR
3826+ if ((d3d11 -> flags & D3D11_ST_FLAG_HDR_ENABLE ) &&
3827+ (d3d11 -> flags & D3D11_ST_FLAG_MENU_ENABLE ))
3828+ {
3829+ context -> lpVtbl -> OMSetRenderTargets (context , 1 ,
3830+ & d3d11 -> back_buffer .rt_view , NULL );
3831+
3832+ float clear_colour [4 ] = { 0.0f , 0.0f , 0.0f , 0.0f };
3833+ context -> lpVtbl -> ClearRenderTargetView (context ,
3834+ d3d11 -> back_buffer .rt_view , clear_colour );
3835+ }
3836+ #endif
3837+
38403838 context -> lpVtbl -> RSSetState (context , d3d11 -> scissor_enabled );
38413839 d3d11 -> context -> lpVtbl -> RSSetScissorRects (d3d11 -> context , 1 , & d3d11 -> scissor );
38423840 context -> lpVtbl -> OMSetBlendState (context , d3d11 -> blend_enable ,
@@ -3973,12 +3971,11 @@ static bool d3d11_gfx_frame(
39733971
39743972#ifdef HAVE_DXGI_HDR
39753973 /* Copy over back buffer to swap chain render targets */
3976- if ( (d3d11 -> flags & D3D11_ST_FLAG_HDR_ENABLE )
3977- && use_back_buffer )
3974+ if ( (d3d11 -> flags & D3D11_ST_FLAG_HDR_ENABLE ) &&
3975+ ( d3d11 -> flags & D3D11_ST_FLAG_MENU_ENABLE ) )
39783976 {
39793977 ID3D11ShaderResourceView * nullSRV [1 ] = {NULL };
39803978 context -> lpVtbl -> OMSetRenderTargets (context , 1 , & rtv , NULL );
3981- context -> lpVtbl -> ClearRenderTargetView (context , rtv , d3d11 -> clearcolor );
39823979 context -> lpVtbl -> RSSetViewports (context , 1 , & d3d11 -> viewport );
39833980 context -> lpVtbl -> RSSetScissorRects (context , 1 , & d3d11 -> scissor );
39843981
@@ -3989,15 +3986,29 @@ static bool d3d11_gfx_frame(
39893986 context -> lpVtbl -> PSSetShader (context , shader -> ps , NULL , 0 );
39903987 context -> lpVtbl -> GSSetShader (context , shader -> gs , NULL , 0 );
39913988 }
3989+
3990+ {
3991+ d3d11 -> hdr .ubo_values .scanlines = false;
3992+
3993+ D3D11_MAPPED_SUBRESOURCE mapped_ubo ;
3994+
3995+ d3d11 -> context -> lpVtbl -> Map (
3996+ d3d11 -> context , (D3D11Resource )d3d11 -> hdr .ubo , 0 , D3D11_MAP_WRITE_DISCARD , 0 , & mapped_ubo );
3997+ {
3998+ dxgi_hdr_uniform_t * ubo = (dxgi_hdr_uniform_t * )mapped_ubo .pData ;
3999+ * ubo = d3d11 -> hdr .ubo_values ;
4000+ }
4001+ d3d11 -> context -> lpVtbl -> Unmap (d3d11 -> context , (D3D11Resource )d3d11 -> hdr .ubo , 0 );
4002+ }
4003+
39924004 context -> lpVtbl -> VSSetConstantBuffers (context , 0 , 1 , & d3d11 -> hdr .ubo );
4005+ context -> lpVtbl -> PSSetConstantBuffers (context , 0 , 1 , & d3d11 -> hdr .ubo );
39934006 context -> lpVtbl -> PSSetShaderResources (
39944007 context , 0 , 1 ,
39954008 & d3d11 -> back_buffer .view );
39964009 context -> lpVtbl -> PSSetSamplers (
39974010 context , 0 , 1 ,
39984011 & d3d11 -> samplers [RARCH_FILTER_UNSPEC ][RARCH_WRAP_DEFAULT ]);
3999- context -> lpVtbl -> PSSetConstantBuffers (
4000- context , 0 , 1 , & d3d11 -> hdr .ubo );
40014012 {
40024013 UINT stride = sizeof (d3d11_vertex_t );
40034014 UINT offset = 0 ;
@@ -4006,7 +4017,7 @@ static bool d3d11_gfx_frame(
40064017 }
40074018
40084019 context -> lpVtbl -> RSSetState (context , d3d11 -> scissor_disabled );
4009- d3d11 -> context -> lpVtbl -> OMSetBlendState (d3d11 -> context , d3d11 -> blend_disable ,
4020+ d3d11 -> context -> lpVtbl -> OMSetBlendState (d3d11 -> context , d3d11 -> blend_enable ,
40104021 NULL , D3D11_DEFAULT_SAMPLE_MASK );
40114022 context -> lpVtbl -> IASetPrimitiveTopology (context ,
40124023 D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP );
@@ -4016,8 +4027,6 @@ static bool d3d11_gfx_frame(
40164027 context -> lpVtbl -> PSSetShaderResources (
40174028 context , 0 , 1 , nullSRV );
40184029 context -> lpVtbl -> RSSetState (context , d3d11 -> scissor_enabled );
4019- d3d11 -> context -> lpVtbl -> OMSetBlendState (d3d11 -> context , d3d11 -> blend_enable ,
4020- NULL , D3D11_DEFAULT_SAMPLE_MASK );
40214030 context -> lpVtbl -> IASetPrimitiveTopology (context ,
40224031 D3D11_PRIMITIVE_TOPOLOGY_POINTLIST );
40234032 }
0 commit comments