mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-11-01 12:57:52 +00:00
texture_cache: Implement GPU Dirty Flags
This commit is contained in:
parent
94f2be5473
commit
5192521dc3
1 changed files with 22 additions and 15 deletions
|
@ -81,17 +81,22 @@ public:
|
||||||
if (!gpu_addr) {
|
if (!gpu_addr) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (gpu_addr == 0x1b7ec0000) {
|
|
||||||
// __debugbreak();
|
|
||||||
}
|
|
||||||
const auto params{SurfaceParams::CreateForTexture(system, config, entry)};
|
const auto params{SurfaceParams::CreateForTexture(system, config, entry)};
|
||||||
return GetSurface(gpu_addr, params, true).second;
|
return GetSurface(gpu_addr, params, true).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
TView GetDepthBufferSurface(bool preserve_contents) {
|
TView GetDepthBufferSurface(bool preserve_contents) {
|
||||||
const auto& regs{system.GPU().Maxwell3D().regs};
|
auto& maxwell3d = system.GPU().Maxwell3D();
|
||||||
|
|
||||||
|
if (!maxwell3d.dirty_flags.zeta_buffer) {
|
||||||
|
return depth_buffer.view;
|
||||||
|
}
|
||||||
|
maxwell3d.dirty_flags.zeta_buffer = false;
|
||||||
|
|
||||||
|
const auto& regs{maxwell3d.regs};
|
||||||
const auto gpu_addr{regs.zeta.Address()};
|
const auto gpu_addr{regs.zeta.Address()};
|
||||||
if (!gpu_addr || !regs.zeta_enable) {
|
if (!gpu_addr || !regs.zeta_enable) {
|
||||||
|
SetEmptyDepthBuffer();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const auto depth_params{SurfaceParams::CreateForDepthBuffer(
|
const auto depth_params{SurfaceParams::CreateForDepthBuffer(
|
||||||
|
@ -101,6 +106,8 @@ public:
|
||||||
auto surface_view = GetSurface(gpu_addr, depth_params, preserve_contents);
|
auto surface_view = GetSurface(gpu_addr, depth_params, preserve_contents);
|
||||||
if (depth_buffer.target)
|
if (depth_buffer.target)
|
||||||
depth_buffer.target->MarkAsProtected(false);
|
depth_buffer.target->MarkAsProtected(false);
|
||||||
|
depth_buffer.target = surface_view.first;
|
||||||
|
depth_buffer.view = surface_view.second;
|
||||||
if (depth_buffer.target)
|
if (depth_buffer.target)
|
||||||
depth_buffer.target->MarkAsProtected(true);
|
depth_buffer.target->MarkAsProtected(true);
|
||||||
return surface_view.second;
|
return surface_view.second;
|
||||||
|
@ -108,8 +115,13 @@ public:
|
||||||
|
|
||||||
TView GetColorBufferSurface(std::size_t index, bool preserve_contents) {
|
TView GetColorBufferSurface(std::size_t index, bool preserve_contents) {
|
||||||
ASSERT(index < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets);
|
ASSERT(index < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets);
|
||||||
|
auto& maxwell3d = system.GPU().Maxwell3D();
|
||||||
|
if (!maxwell3d.dirty_flags.color_buffer[index]) {
|
||||||
|
return render_targets[index].view;
|
||||||
|
}
|
||||||
|
maxwell3d.dirty_flags.color_buffer.reset(index);
|
||||||
|
|
||||||
const auto& regs{system.GPU().Maxwell3D().regs};
|
const auto& regs{maxwell3d.regs};
|
||||||
if (index >= regs.rt_control.count || regs.rt[index].Address() == 0 ||
|
if (index >= regs.rt_control.count || regs.rt[index].Address() == 0 ||
|
||||||
regs.rt[index].format == Tegra::RenderTargetFormat::NONE) {
|
regs.rt[index].format == Tegra::RenderTargetFormat::NONE) {
|
||||||
SetEmptyColorBuffer(index);
|
SetEmptyColorBuffer(index);
|
||||||
|
@ -128,6 +140,7 @@ public:
|
||||||
if (render_targets[index].target)
|
if (render_targets[index].target)
|
||||||
render_targets[index].target->MarkAsProtected(false);
|
render_targets[index].target->MarkAsProtected(false);
|
||||||
render_targets[index].target = surface_view.first;
|
render_targets[index].target = surface_view.first;
|
||||||
|
render_targets[index].view = surface_view.second;
|
||||||
if (render_targets[index].target)
|
if (render_targets[index].target)
|
||||||
render_targets[index].target->MarkAsProtected(true);
|
render_targets[index].target->MarkAsProtected(true);
|
||||||
return surface_view.second;
|
return surface_view.second;
|
||||||
|
@ -154,7 +167,6 @@ public:
|
||||||
void SetEmptyColorBuffer(std::size_t index) {
|
void SetEmptyColorBuffer(std::size_t index) {
|
||||||
if (render_targets[index].target != nullptr) {
|
if (render_targets[index].target != nullptr) {
|
||||||
render_targets[index].target->MarkAsProtected(false);
|
render_targets[index].target->MarkAsProtected(false);
|
||||||
std::memset(&render_targets[index].config, sizeof(RenderTargetConfig), 0);
|
|
||||||
render_targets[index].target = nullptr;
|
render_targets[index].target = nullptr;
|
||||||
render_targets[index].view = nullptr;
|
render_targets[index].view = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -545,13 +557,7 @@ private:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RenderInfo {
|
struct FramebufferTargetInfo {
|
||||||
RenderTargetConfig config;
|
|
||||||
TSurface target;
|
|
||||||
TView view;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DepthBufferInfo {
|
|
||||||
TSurface target;
|
TSurface target;
|
||||||
TView view;
|
TView view;
|
||||||
};
|
};
|
||||||
|
@ -580,8 +586,9 @@ private:
|
||||||
/// previously been used. This is to prevent surfaces from being constantly created and
|
/// previously been used. This is to prevent surfaces from being constantly created and
|
||||||
/// destroyed when used with different surface parameters.
|
/// destroyed when used with different surface parameters.
|
||||||
std::unordered_map<SurfaceParams, std::vector<TSurface>> surface_reserve;
|
std::unordered_map<SurfaceParams, std::vector<TSurface>> surface_reserve;
|
||||||
std::array<RenderInfo, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> render_targets;
|
std::array<FramebufferTargetInfo, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets>
|
||||||
DepthBufferInfo depth_buffer;
|
render_targets;
|
||||||
|
FramebufferTargetInfo depth_buffer;
|
||||||
|
|
||||||
std::vector<u8> staging_buffer;
|
std::vector<u8> staging_buffer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue