Skip to content

Commit

Permalink
Roolback: taken2009's ignore format reinterpretation
Browse files Browse the repository at this point in the history
  • Loading branch information
sickc committed Sep 14, 2018
1 parent 7232444 commit 9da7508
Showing 1 changed file with 8 additions and 73 deletions.
81 changes: 8 additions & 73 deletions src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
#include "common/math_util.h"
#include "common/microprofile.h"
#include "common/scope_exit.h"
#include "common/telemetry.h"
#include "common/vector_math.h"
#include "core/core.h"
#include "core/frontend/emu_window.h"
#include "core/memory.h"
#include "core/settings.h"
Expand Down Expand Up @@ -1506,45 +1504,6 @@ void RasterizerCacheOpenGL::DuplicateSurface(const Surface& src_surface,
}
}

static const char* PixelFormatAsString(SurfaceParams::PixelFormat format) {
switch (format) {
case SurfaceParams::PixelFormat::RGBA8:
return "RGBA8";
case SurfaceParams::PixelFormat::RGB8:
return "RGB8";
case SurfaceParams::PixelFormat::RGB5A1:
return "RGB5A1";
case SurfaceParams::PixelFormat::RGB565:
return "RGB565";
case SurfaceParams::PixelFormat::RGBA4:
return "RGBA4";
case SurfaceParams::PixelFormat::IA8:
return "IA8";
case SurfaceParams::PixelFormat::I8:
return "I8";
case SurfaceParams::PixelFormat::A8:
return "A8";
case SurfaceParams::PixelFormat::IA4:
return "IA4";
case SurfaceParams::PixelFormat::I4:
return "I4";
case SurfaceParams::PixelFormat::A4:
return "A4";
case SurfaceParams::PixelFormat::ETC1:
return "ETC1";
case SurfaceParams::PixelFormat::ETC1A4:
return "ETC1A4";
case SurfaceParams::PixelFormat::D16:
return "D16";
case SurfaceParams::PixelFormat::D24:
return "D24";
case SurfaceParams::PixelFormat::D24S8:
return "D24S8";
default:
return "Not a real pixel format";
}
}

void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, PAddr addr, u32 size) {
if (size == 0)
return;
Expand All @@ -1557,17 +1516,9 @@ void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, PAddr addr,
return;
}

auto validate_regions = surface->invalid_regions & validate_interval;
auto notify_validated = [&](SurfaceInterval interval) {
surface->invalid_regions.erase(interval);
validate_regions.erase(interval);
};

bool flushed_from_cpu = false;
std::set<u32> formats;
while (true) {
const auto it = validate_regions.begin();
if (it == validate_regions.end())
const auto it = surface->invalid_regions.find(validate_interval);
if (it == surface->invalid_regions.end())
break;

const auto interval = *it & validate_interval;
Expand All @@ -1579,7 +1530,7 @@ void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, PAddr addr,
if (copy_surface != nullptr) {
SurfaceInterval copy_interval = params.GetCopyableInterval(copy_surface);
CopySurface(copy_surface, surface, copy_interval);
notify_validated(copy_interval);
surface->invalid_regions.erase(copy_interval);
continue;
}

Expand All @@ -1599,7 +1550,7 @@ void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, PAddr addr,
ConvertD24S8toABGR(reinterpret_surface->texture.handle, src_rect,
surface->texture.handle, dest_rect);

notify_validated(convert_interval);
surface->invalid_regions.erase(convert_interval);
continue;
}
}
Expand All @@ -1612,11 +1563,10 @@ void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, PAddr addr,

// As this is a HACK, remove this when we get proper hw texture en/decoding support
if (VideoCore::g_use_format_reinterpret_hack) {
bool retry = false;
bool retry{};

for (const auto& pair : RangeFromInterval(dirty_regions, interval)) {
// Don't actually validate the region, and instead just skip it for now
validate_regions.erase(pair.first & interval);
formats.insert(static_cast<u32>(pair.second->pixel_format));
surface->invalid_regions.erase(pair.first & interval);
retry = true;
}

Expand All @@ -1629,22 +1579,7 @@ void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, PAddr addr,
surface->LoadGLBuffer(params.addr, params.end);
surface->UploadGLTexture(surface->GetSubRect(params), read_framebuffer.handle,
draw_framebuffer.handle);
notify_validated(params.GetInterval());
flushed_from_cpu = true;
}

if (!flushed_from_cpu && !formats.empty()) {
std::string s;
for (auto format : formats) {
s += PixelFormatAsString(static_cast<PixelFormat>(format));
s += ", ";
}
LOG_DEBUG(Debug_GPU,
"Validating surface with pixel format {} and found surfaces created on the gpu "
"that have the following pixel formats: {}",
PixelFormatAsString(surface->pixel_format), s);
Core::Telemetry().AddField(Telemetry::FieldType::Session, "VideoCore_FormatReinterpret",
true);
surface->invalid_regions.erase(params.GetInterval());
}
}

Expand Down

0 comments on commit 9da7508

Please sign in to comment.