mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-23 15:22:45 +01:00
gl_rasterizer_cache: Use dirty flags for the depth buffer
This commit is contained in:
parent
179ee963db
commit
b683e41fca
4 changed files with 23 additions and 3 deletions
|
@ -144,6 +144,16 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
|
||||||
dirty_flags.color_buffer |= 1u << static_cast<u32>(rt_index);
|
dirty_flags.color_buffer |= 1u << static_cast<u32>(rt_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zeta buffer
|
||||||
|
constexpr u32 registers_in_zeta = sizeof(regs.zeta) / sizeof(u32);
|
||||||
|
if (method_call.method == MAXWELL3D_REG_INDEX(zeta_enable) ||
|
||||||
|
method_call.method == MAXWELL3D_REG_INDEX(zeta_width) ||
|
||||||
|
method_call.method == MAXWELL3D_REG_INDEX(zeta_height) ||
|
||||||
|
(method_call.method >= MAXWELL3D_REG_INDEX(zeta) &&
|
||||||
|
method_call.method < MAXWELL3D_REG_INDEX(zeta) + registers_in_zeta)) {
|
||||||
|
dirty_flags.zeta_buffer = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Shader
|
// Shader
|
||||||
constexpr u32 shader_registers_count =
|
constexpr u32 shader_registers_count =
|
||||||
sizeof(regs.shader_config[0]) * Regs::MaxShaderProgram / sizeof(u32);
|
sizeof(regs.shader_config[0]) * Regs::MaxShaderProgram / sizeof(u32);
|
||||||
|
|
|
@ -1090,6 +1090,7 @@ public:
|
||||||
|
|
||||||
struct DirtyFlags {
|
struct DirtyFlags {
|
||||||
u8 color_buffer = 0xFF;
|
u8 color_buffer = 0xFF;
|
||||||
|
bool zeta_buffer = true;
|
||||||
|
|
||||||
bool shaders = true;
|
bool shaders = true;
|
||||||
|
|
||||||
|
@ -1098,6 +1099,7 @@ public:
|
||||||
|
|
||||||
void OnMemoryWrite() {
|
void OnMemoryWrite() {
|
||||||
color_buffer = 0xFF;
|
color_buffer = 0xFF;
|
||||||
|
zeta_buffer = true;
|
||||||
shaders = true;
|
shaders = true;
|
||||||
vertex_array = 0xFFFFFFFF;
|
vertex_array = 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
|
@ -919,9 +919,16 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextu
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) {
|
Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) {
|
||||||
const auto& regs{Core::System::GetInstance().GPU().Maxwell3D().regs};
|
auto& gpu{Core::System::GetInstance().GPU().Maxwell3D()};
|
||||||
|
const auto& regs{gpu.regs};
|
||||||
|
|
||||||
|
if (!gpu.dirty_flags.zeta_buffer) {
|
||||||
|
return last_depth_buffer;
|
||||||
|
}
|
||||||
|
gpu.dirty_flags.zeta_buffer = false;
|
||||||
|
|
||||||
if (!regs.zeta.Address() || !regs.zeta_enable) {
|
if (!regs.zeta.Address() || !regs.zeta_enable) {
|
||||||
return {};
|
return last_depth_buffer = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceParams depth_params{SurfaceParams::CreateForDepthBuffer(
|
SurfaceParams depth_params{SurfaceParams::CreateForDepthBuffer(
|
||||||
|
@ -929,7 +936,7 @@ Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) {
|
||||||
regs.zeta.memory_layout.block_width, regs.zeta.memory_layout.block_height,
|
regs.zeta.memory_layout.block_width, regs.zeta.memory_layout.block_height,
|
||||||
regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)};
|
regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)};
|
||||||
|
|
||||||
return GetSurface(depth_params, preserve_contents);
|
return last_depth_buffer = GetSurface(depth_params, preserve_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface RasterizerCacheOpenGL::GetColorBufferSurface(std::size_t index, bool preserve_contents) {
|
Surface RasterizerCacheOpenGL::GetColorBufferSurface(std::size_t index, bool preserve_contents) {
|
||||||
|
|
|
@ -398,6 +398,7 @@ private:
|
||||||
OGLBuffer copy_pbo;
|
OGLBuffer copy_pbo;
|
||||||
|
|
||||||
std::array<Surface, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> last_color_buffers;
|
std::array<Surface, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> last_color_buffers;
|
||||||
|
Surface last_depth_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace OpenGL
|
||||||
|
|
Loading…
Reference in a new issue