Antialiasing workaround

This commit is contained in:
DHrpcs3 2016-03-08 18:51:10 +03:00
parent 220d48a980
commit 4d429ca918
3 changed files with 55 additions and 3 deletions

View File

@ -1196,6 +1196,7 @@ void GLGSRender::init_buffers(bool skip_reading)
else
{
gl::texture_info info = surface_info(m_surface.color_format, offset, location, m_surface.width, m_surface.height, pitch);
info.antialiasing = m_surface.antialias;
cached_color_buffers[index] = &m_texture_cache.entry(info, skip_reading ? gl::cache_buffers::none : gl::cache_buffers::local);
draw_fbo.color[index] = cached_color_buffers[index]->view();
}

View File

@ -146,6 +146,31 @@ namespace gl
pixels = linear_pixels.get();
}
if (info->antialiasing != rsx::surface_antialiasing::center_1_sample)
{
std::unique_ptr<u8[]> tmp(std::move(linear_pixels));
switch (info->antialiasing)
{
case rsx::surface_antialiasing::square_centered_4_samples:
case rsx::surface_antialiasing::square_rotated_4_samples:
linear_pixels.reset(new u8[info->size() * 4]);
for (u32 y = 0; y < info->height; ++y)
{
for (u32 x = 0; x < info->width; ++x)
{
u32 value = *(u32*)((u8*)pixels + (y * 2 + 0) * info->pitch + (x * 2 + 0) * sizeof(u32));
*(u32*)((u8*)linear_pixels.get() + info->pitch * y + x * sizeof(u32)) = value;
}
}
pixels = linear_pixels.get();
break;
}
}
gl::pixel_unpack_settings{}
.row_length(info->pitch / info->format.bpp)
.aligment(1)
@ -230,7 +255,34 @@ namespace gl
.swap_bytes((info->format.flags & gl::texture_flags::swap_bytes) != gl::texture_flags::none)
.apply();
__glcheck glGetTexImage((GLenum)info->target, 0, (GLenum)info->format.format, (GLenum)info->format.type, vm::base_priv(info->start_address));
if (info->antialiasing == rsx::surface_antialiasing::square_centered_4_samples ||
info->antialiasing == rsx::surface_antialiasing::square_rotated_4_samples)
{
//TODO
std::unique_ptr<u8[]> tmp(new u8[info->size()]);
glGetTexImage((GLenum)info->target, 0, (GLenum)info->format.format, (GLenum)info->format.type, tmp.get());
u8 *dst = (u8*)vm::base_priv(info->start_address);
for (u32 y = 0; y < info->height; ++y)
{
for (u32 x = 0; x < info->width; ++x)
{
u32 value = *(u32*)((u8*)tmp.get() + info->pitch * y + x * sizeof(u32));
*(u32*)(dst + (y * 2 + 0) * info->pitch + (x * 2 + 0) * sizeof(u32)) = value;
*(u32*)(dst + (y * 2 + 0) * info->pitch + (x * 2 + 1) * sizeof(u32)) = value;
*(u32*)(dst + (y * 2 + 1) * info->pitch + (x * 2 + 0) * sizeof(u32)) = value;
*(u32*)(dst + (y * 2 + 1) * info->pitch + (x * 2 + 1) * sizeof(u32)) = value;
}
}
}
else
{
__glcheck glGetTexImage((GLenum)info->target, 0, (GLenum)info->format.format, (GLenum)info->format.type, vm::base_priv(info->start_address));
}
}
ignore(gl::cache_buffers::all);
@ -561,7 +613,6 @@ namespace gl
cached_texture &texture_cache::entry(const texture_info &info, cache_buffers sync)
{
//u32 aligned_address = info.start_address & ~(vm::page_size - 1);
u32 aligned_address;
u32 aligned_size;

View File

@ -2,7 +2,6 @@
#include <vector>
#include "Utilities/types.h"
#include "gl_helpers.h"
#include <array>
namespace gl
{
@ -64,6 +63,7 @@ namespace gl
texture::target target;
texture_format format;
rsx::surface_antialiasing antialiasing;
bool swizzled;
u32 start_address;