mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-06 03:25:36 +00:00
GPU/HW: Fix MSAA+depth buffer combination
Clear should wipe out all samples, copy should copy all samples.
This commit is contained in:
parent
4a707afae1
commit
17dfb95d6a
@ -1687,21 +1687,19 @@ bool GPU_HW::CompilePipelines(Error* error)
|
||||
return false;
|
||||
}
|
||||
|
||||
plconfig.SetTargetFormats(VRAM_RT_FORMAT);
|
||||
plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags;
|
||||
plconfig.depth = GPUPipeline::DepthState::GetNoTestsState();
|
||||
plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState();
|
||||
plconfig.samples = 1;
|
||||
plconfig.per_sample_shading = false;
|
||||
|
||||
if (m_pgxp_depth_buffer)
|
||||
{
|
||||
std::unique_ptr<GPUShader> fs = g_gpu_device->CreateShader(GPUShaderStage::Fragment, shadergen.GetLanguage(),
|
||||
shadergen.GenerateCopyFragmentShader(), error);
|
||||
std::unique_ptr<GPUShader> fs = g_gpu_device->CreateShader(
|
||||
GPUShaderStage::Fragment, shadergen.GetLanguage(), shadergen.GenerateVRAMCopyDepthFragmentShader(msaa), error);
|
||||
if (!fs)
|
||||
return false;
|
||||
|
||||
plconfig.fragment_shader = fs.get();
|
||||
plconfig.render_pass_flags = GPUPipeline::NoRenderPassFlags;
|
||||
plconfig.depth = GPUPipeline::DepthState::GetNoTestsState();
|
||||
plconfig.blend = GPUPipeline::BlendState::GetNoBlendingState();
|
||||
plconfig.samples = m_multisamples;
|
||||
plconfig.per_sample_shading = true;
|
||||
plconfig.SetTargetFormats(VRAM_DS_COLOR_FORMAT);
|
||||
if (!(m_copy_depth_pipeline = g_gpu_device->CreatePipeline(plconfig, error)))
|
||||
return false;
|
||||
@ -1714,6 +1712,7 @@ bool GPU_HW::CompilePipelines(Error* error)
|
||||
SetScreenQuadInputLayout(plconfig);
|
||||
plconfig.vertex_shader = m_screen_quad_vertex_shader.get();
|
||||
plconfig.fragment_shader = fs.get();
|
||||
plconfig.per_sample_shading = false;
|
||||
if (!m_use_rov_for_shader_blend)
|
||||
{
|
||||
plconfig.SetTargetFormats(VRAM_RT_FORMAT, depth_buffer_format);
|
||||
|
@ -1917,6 +1917,27 @@ std::string GPU_HW_ShaderGen::GenerateVRAMUpdateDepthFragmentShader(bool msaa) c
|
||||
return std::move(ss).str();
|
||||
}
|
||||
|
||||
std::string GPU_HW_ShaderGen::GenerateVRAMCopyDepthFragmentShader(bool msaa) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
WriteHeader(ss);
|
||||
DefineMacro(ss, "MULTISAMPLED", msaa);
|
||||
DeclareTexture(ss, "samp0", 0, msaa);
|
||||
DeclareFragmentEntryPoint(ss, 0, 1, {}, msaa, 1, false, false, msaa, msaa, msaa);
|
||||
|
||||
ss << R"(
|
||||
{
|
||||
#if MULTISAMPLED
|
||||
o_col0 = float4(LOAD_TEXTURE_MS(samp0, int2(v_pos.xy), int(f_sample_index)).r, 0.0, 0.0, 0.0);
|
||||
#else
|
||||
o_col0 = float4(SAMPLE_TEXTURE(samp0, v_tex0).r, 0.0, 0.0, 0.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
return std::move(ss).str();
|
||||
}
|
||||
|
||||
std::string GPU_HW_ShaderGen::GenerateVRAMClearDepthFragmentShader(bool write_depth_as_rt) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
std::string GenerateVRAMFillFragmentShader(bool wrapped, bool interlaced, bool write_mask_as_depth,
|
||||
bool write_depth_as_rt) const;
|
||||
std::string GenerateVRAMUpdateDepthFragmentShader(bool msaa) const;
|
||||
std::string GenerateVRAMCopyDepthFragmentShader(bool msaa) const;
|
||||
std::string GenerateVRAMClearDepthFragmentShader(bool write_depth_as_rt) const;
|
||||
std::string GenerateVRAMExtractFragmentShader(u32 resolution_scale, u32 multisamples, bool color_24bit,
|
||||
bool depth_buffer) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user