@@ -317,7 +317,7 @@ bool GPU_HW::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
317
317
void GPU_HW::RestoreDeviceContext ()
318
318
{
319
319
g_gpu_device->SetTextureSampler (0 , m_vram_read_texture.get (), g_gpu_device->GetNearestSampler ());
320
- g_gpu_device->SetFramebuffer (m_vram_framebuffer .get ());
320
+ g_gpu_device->SetRenderTarget (m_vram_texture. get (), m_vram_depth_texture .get ());
321
321
g_gpu_device->SetViewport (0 , 0 , m_vram_texture->GetWidth (), m_vram_texture->GetHeight ());
322
322
SetScissor ();
323
323
m_batch_ubo_dirty = true ;
@@ -649,20 +649,6 @@ bool GPU_HW::CreateBuffers()
649
649
GL_OBJECT_NAME (m_display_private_texture, " Display Texture" );
650
650
GL_OBJECT_NAME (m_vram_readback_texture, " VRAM Readback Texture" );
651
651
652
- // vram framebuffer has both colour and depth
653
- if (!(m_vram_framebuffer = g_gpu_device->CreateFramebuffer (m_vram_texture.get (), m_vram_depth_texture.get ())) ||
654
- !(m_vram_update_depth_framebuffer = g_gpu_device->CreateFramebuffer (m_vram_depth_texture.get ())) ||
655
- !(m_vram_readback_framebuffer = g_gpu_device->CreateFramebuffer (m_vram_readback_texture.get ())) ||
656
- !(m_display_framebuffer = g_gpu_device->CreateFramebuffer (m_display_private_texture.get ())))
657
- {
658
- return false ;
659
- }
660
-
661
- GL_OBJECT_NAME (m_vram_framebuffer, " VRAM Framebuffer" );
662
- GL_OBJECT_NAME (m_vram_update_depth_framebuffer, " VRAM Update Depth Framebuffer" );
663
- GL_OBJECT_NAME (m_vram_readback_framebuffer, " VRAM Readback Framebuffer" );
664
- GL_OBJECT_NAME (m_display_framebuffer, " Display Framebuffer" );
665
-
666
652
if (!(m_vram_upload_buffer =
667
653
g_gpu_device->CreateTextureBuffer (GPUTextureBuffer::Format::R16UI, GPUDevice::MIN_TEXEL_BUFFER_ELEMENTS)))
668
654
{
@@ -679,11 +665,9 @@ bool GPU_HW::CreateBuffers()
679
665
GPUTexture::Type::Texture, VRAM_RT_FORMAT)) ||
680
666
!(m_downsample_render_texture = g_gpu_device->CreateTexture (texture_width, texture_height, 1 , 1 , 1 ,
681
667
GPUTexture::Type::RenderTarget, VRAM_RT_FORMAT)) ||
682
- !(m_downsample_framebuffer = g_gpu_device->CreateFramebuffer (m_downsample_render_texture.get ())) ||
683
668
!(m_downsample_weight_texture =
684
669
g_gpu_device->CreateTexture (texture_width >> (levels - 1 ), texture_height >> (levels - 1 ), 1 , 1 , 1 ,
685
- GPUTexture::Type::RenderTarget, GPUTexture::Format::R8)) ||
686
- !(m_downsample_weight_framebuffer = g_gpu_device->CreateFramebuffer (m_downsample_weight_texture.get ())))
670
+ GPUTexture::Type::RenderTarget, GPUTexture::Format::R8)))
687
671
{
688
672
return false ;
689
673
}
@@ -693,14 +677,13 @@ bool GPU_HW::CreateBuffers()
693
677
const u32 downsample_scale = GetBoxDownsampleScale (m_resolution_scale);
694
678
if (!(m_downsample_render_texture =
695
679
g_gpu_device->CreateTexture (VRAM_WIDTH * downsample_scale, VRAM_HEIGHT * downsample_scale, 1 , 1 , 1 ,
696
- GPUTexture::Type::RenderTarget, VRAM_RT_FORMAT)) ||
697
- !(m_downsample_framebuffer = g_gpu_device->CreateFramebuffer (m_downsample_render_texture.get ())))
680
+ GPUTexture::Type::RenderTarget, VRAM_RT_FORMAT)))
698
681
{
699
682
return false ;
700
683
}
701
684
}
702
685
703
- g_gpu_device->SetFramebuffer (m_vram_framebuffer .get ());
686
+ g_gpu_device->SetRenderTarget (m_vram_texture. get (), m_vram_depth_texture .get ());
704
687
SetFullVRAMDirtyRectangle ();
705
688
return true ;
706
689
}
@@ -719,15 +702,9 @@ void GPU_HW::DestroyBuffers()
719
702
ClearDisplayTexture ();
720
703
721
704
m_vram_upload_buffer.reset ();
722
- m_downsample_weight_framebuffer.reset ();
723
705
m_downsample_weight_texture.reset ();
724
- m_downsample_framebuffer.reset ();
725
706
m_downsample_render_texture.reset ();
726
707
m_downsample_texture.reset ();
727
- m_display_framebuffer.reset ();
728
- m_vram_readback_framebuffer.reset ();
729
- m_vram_update_depth_framebuffer.reset ();
730
- m_vram_framebuffer.reset ();
731
708
m_vram_read_texture.reset ();
732
709
m_vram_depth_texture.reset ();
733
710
m_vram_texture.reset ();
@@ -833,8 +810,7 @@ bool GPU_HW::CompilePipelines()
833
810
plconfig.input_layout .vertex_stride = sizeof (BatchVertex);
834
811
plconfig.rasterization = GPUPipeline::RasterizationState::GetNoCullState ();
835
812
plconfig.primitive = GPUPipeline::Primitive::Triangles;
836
- plconfig.color_format = VRAM_RT_FORMAT;
837
- plconfig.depth_format = VRAM_DS_FORMAT;
813
+ plconfig.SetTargetFormats (VRAM_RT_FORMAT, VRAM_DS_FORMAT);
838
814
plconfig.samples = m_multisamples;
839
815
plconfig.per_sample_shading = m_per_sample_shading;
840
816
plconfig.geometry_shader = nullptr ;
@@ -1080,8 +1056,7 @@ bool GPU_HW::CompilePipelines()
1080
1056
return false ;
1081
1057
1082
1058
plconfig.fragment_shader = fs.get ();
1083
- plconfig.color_format = GPUTexture::Format::Unknown;
1084
- plconfig.depth_format = VRAM_DS_FORMAT;
1059
+ plconfig.SetTargetFormats (GPUTexture::Format::Unknown, VRAM_DS_FORMAT);
1085
1060
plconfig.depth = GPUPipeline::DepthState::GetAlwaysWriteState ();
1086
1061
plconfig.blend .write_mask = 0 ;
1087
1062
@@ -1093,8 +1068,7 @@ bool GPU_HW::CompilePipelines()
1093
1068
progress.Increment ();
1094
1069
}
1095
1070
1096
- plconfig.color_format = VRAM_RT_FORMAT;
1097
- plconfig.depth_format = GPUTexture::Format::Unknown;
1071
+ plconfig.SetTargetFormats (VRAM_RT_FORMAT);
1098
1072
plconfig.depth = GPUPipeline::DepthState::GetNoTestsState ();
1099
1073
plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState ();
1100
1074
plconfig.samples = 1 ;
@@ -1181,7 +1155,7 @@ bool GPU_HW::CompilePipelines()
1181
1155
return false ;
1182
1156
GL_OBJECT_NAME (fs, " Downsample Blur Pass Fragment Shader" );
1183
1157
plconfig.fragment_shader = fs.get ();
1184
- plconfig.color_format = GPUTexture::Format::R8;
1158
+ plconfig.SetTargetFormats ( GPUTexture::Format::R8) ;
1185
1159
if (!(m_downsample_blur_pass_pipeline = g_gpu_device->CreatePipeline (plconfig)))
1186
1160
return false ;
1187
1161
GL_OBJECT_NAME (m_downsample_blur_pass_pipeline, " Downsample Blur Pass Pipeline" );
@@ -1193,7 +1167,7 @@ bool GPU_HW::CompilePipelines()
1193
1167
GL_OBJECT_NAME (fs, " Downsample Composite Pass Fragment Shader" );
1194
1168
plconfig.layout = GPUPipeline::Layout::MultiTextureAndPushConstants;
1195
1169
plconfig.fragment_shader = fs.get ();
1196
- plconfig.color_format = VRAM_RT_FORMAT;
1170
+ plconfig.SetTargetFormats ( VRAM_RT_FORMAT) ;
1197
1171
if (!(m_downsample_composite_pass_pipeline = g_gpu_device->CreatePipeline (plconfig)))
1198
1172
return false ;
1199
1173
GL_OBJECT_NAME (m_downsample_composite_pass_pipeline, " Downsample Blur Pass Pipeline" );
@@ -1310,14 +1284,15 @@ void GPU_HW::UpdateDepthBufferFromMaskBit()
1310
1284
1311
1285
// Viewport should already be set full, only need to fudge the scissor.
1312
1286
g_gpu_device->SetScissor (0 , 0 , m_vram_texture->GetWidth (), m_vram_texture->GetHeight ());
1313
- g_gpu_device->SetFramebuffer (m_vram_update_depth_framebuffer.get ());
1287
+ g_gpu_device->InvalidateRenderTarget (m_vram_depth_texture.get ());
1288
+ g_gpu_device->SetRenderTargets (nullptr , 0 , m_vram_depth_texture.get ());
1314
1289
g_gpu_device->SetPipeline (m_vram_update_depth_pipeline.get ());
1315
1290
g_gpu_device->SetTextureSampler (0 , m_vram_texture.get (), g_gpu_device->GetNearestSampler ());
1316
1291
g_gpu_device->Draw (3 , 0 );
1317
1292
1318
1293
// Restore.
1319
1294
g_gpu_device->SetTextureSampler (0 , m_vram_read_texture.get (), g_gpu_device->GetNearestSampler ());
1320
- g_gpu_device->SetFramebuffer (m_vram_framebuffer .get ());
1295
+ g_gpu_device->SetRenderTarget (m_vram_texture. get (), m_vram_depth_texture .get ());
1321
1296
SetScissor ();
1322
1297
}
1323
1298
@@ -2061,7 +2036,7 @@ bool GPU_HW::BlitVRAMReplacementTexture(const TextureReplacementTexture* tex, u3
2061
2036
}
2062
2037
}
2063
2038
2064
- g_gpu_device->SetFramebuffer (m_vram_framebuffer .get ()); // TODO: needed?
2039
+ g_gpu_device->SetRenderTarget (m_vram_texture. get (), m_vram_depth_texture .get ()); // TODO: needed?
2065
2040
g_gpu_device->SetTextureSampler (0 , m_vram_replacement_texture.get (), g_gpu_device->GetLinearSampler ());
2066
2041
g_gpu_device->SetPipeline (m_copy_pipeline.get ());
2067
2042
g_gpu_device->SetViewportAndScissor (dst_x, dst_y, width, height);
@@ -2364,7 +2339,7 @@ void GPU_HW::ReadVRAM(u32 x, u32 y, u32 width, u32 height)
2364
2339
2365
2340
// Encode the 24-bit texture as 16-bit.
2366
2341
const u32 uniforms[4 ] = {copy_rect.left , copy_rect.top , copy_rect.GetWidth (), copy_rect.GetHeight ()};
2367
- g_gpu_device->SetFramebuffer (m_vram_readback_framebuffer .get ());
2342
+ g_gpu_device->SetRenderTarget (m_vram_readback_texture .get ());
2368
2343
g_gpu_device->SetPipeline (m_vram_readback_pipeline.get ());
2369
2344
g_gpu_device->SetTextureSampler (0 , m_vram_texture.get (), g_gpu_device->GetNearestSampler ());
2370
2345
g_gpu_device->SetViewportAndScissor (0 , 0 , encoded_width, encoded_height);
@@ -2811,7 +2786,7 @@ void GPU_HW::UpdateDisplay()
2811
2786
if (interlaced == InterlacedRenderMode::None)
2812
2787
g_gpu_device->InvalidateRenderTarget (m_display_private_texture.get ());
2813
2788
2814
- g_gpu_device->SetFramebuffer (m_display_framebuffer .get ());
2789
+ g_gpu_device->SetRenderTarget (m_display_private_texture .get ());
2815
2790
g_gpu_device->SetPipeline (
2816
2791
m_display_pipelines[BoolToUInt8 (m_GPUSTAT.display_area_color_depth_24 )][static_cast <u8 >(interlaced)].get ());
2817
2792
g_gpu_device->SetTextureSampler (0 , m_vram_texture.get (), g_gpu_device->GetNearestSampler ());
@@ -2883,7 +2858,7 @@ void GPU_HW::DownsampleFramebufferAdaptive(GPUTexture* source, u32 left, u32 top
2883
2858
uniforms.lod = static_cast <float >(level - 1 );
2884
2859
2885
2860
g_gpu_device->ClearRenderTarget (m_downsample_render_texture.get (), 0 );
2886
- g_gpu_device->SetFramebuffer (m_downsample_framebuffer .get ());
2861
+ g_gpu_device->SetRenderTarget (m_downsample_render_texture .get ());
2887
2862
g_gpu_device->SetViewportAndScissor (0 , 0 , level_width, level_height);
2888
2863
g_gpu_device->SetPipeline ((level == 1 ) ? m_downsample_first_pass_pipeline.get () :
2889
2864
m_downsample_mid_pass_pipeline.get ());
@@ -2912,7 +2887,7 @@ void GPU_HW::DownsampleFramebufferAdaptive(GPUTexture* source, u32 left, u32 top
2912
2887
2913
2888
m_downsample_render_texture->MakeReadyForSampling ();
2914
2889
g_gpu_device->ClearRenderTarget (m_downsample_weight_texture.get (), 0 );
2915
- g_gpu_device->SetFramebuffer (m_downsample_weight_framebuffer .get ());
2890
+ g_gpu_device->SetRenderTarget (m_downsample_weight_texture .get ());
2916
2891
g_gpu_device->SetTextureSampler (0 , m_downsample_render_texture.get (), g_gpu_device->GetNearestSampler ());
2917
2892
g_gpu_device->SetViewportAndScissor (0 , 0 , last_width, last_height);
2918
2893
g_gpu_device->SetPipeline (m_downsample_blur_pass_pipeline.get ());
@@ -2926,7 +2901,7 @@ void GPU_HW::DownsampleFramebufferAdaptive(GPUTexture* source, u32 left, u32 top
2926
2901
GL_SCOPE (" Composite" );
2927
2902
2928
2903
g_gpu_device->ClearRenderTarget (m_downsample_render_texture.get (), 0 );
2929
- g_gpu_device->SetFramebuffer (m_downsample_framebuffer .get ());
2904
+ g_gpu_device->SetRenderTarget (m_downsample_render_texture .get ());
2930
2905
g_gpu_device->SetTextureSampler (0 , m_downsample_texture.get (), m_downsample_composite_sampler.get ());
2931
2906
g_gpu_device->SetTextureSampler (1 , m_downsample_weight_texture.get (), m_downsample_lod_sampler.get ());
2932
2907
g_gpu_device->SetViewportAndScissor (0 , 0 , width, height);
@@ -2953,7 +2928,7 @@ void GPU_HW::DownsampleFramebufferBoxFilter(GPUTexture* source, u32 left, u32 to
2953
2928
source->MakeReadyForSampling ();
2954
2929
2955
2930
g_gpu_device->ClearRenderTarget (m_downsample_render_texture.get (), 0 );
2956
- g_gpu_device->SetFramebuffer (m_downsample_framebuffer .get ());
2931
+ g_gpu_device->SetRenderTarget (m_downsample_render_texture .get ());
2957
2932
g_gpu_device->SetPipeline (m_downsample_first_pass_pipeline.get ());
2958
2933
g_gpu_device->SetTextureSampler (0 , source, g_gpu_device->GetNearestSampler ());
2959
2934
g_gpu_device->SetViewportAndScissor (ds_left, ds_top, ds_width, ds_height);
0 commit comments