gl: Add surface offset calculations (broken atm/ WIP)

This commit is contained in:
kd-11 2017-03-15 23:36:02 +03:00
parent 30d45356a3
commit 25bdc076cd
3 changed files with 43 additions and 29 deletions

View file

@ -1056,15 +1056,27 @@ namespace gl
const areai src_area = {0, 0, src.width, src.slice_h};
const areai dst_area = {0, 0, dst.width, dst.height};
const position2i clip_offset = {dst.clip_x, dst.clip_y};
const position2i dst_offset = {dst.offset_x, dst.offset_y};
position2i dst_offset = {dst.offset_x, dst.offset_y};
const size2i clip_dimensions = {dst.clip_width, dst.clip_height};
const size2i dst_dimensions = {dst.pitch/(dst_is_argb8? 4: 2), dst.height};
auto old_cached_texture = find_texture(dst.rsx_address, dst.pitch * dst.height);
u32 dst_surface = 0;
if (old_cached_texture && old_cached_texture->matches(old_cached_texture->get_section_base(), dst.width, dst.height, 1))
if (old_cached_texture/* && old_cached_texture->matches(old_cached_texture->get_section_base(), dst.width, dst.height, 1)*/)
{
dst_surface = old_cached_texture->id();
const u32 address_offset = dst.rsx_address - old_cached_texture->get_section_base();
const u16 bpp = dst_is_argb8 ? 4 : 2;
const u16 offset_x = address_offset / dst.pitch;
const u16 offset_y = address_offset % dst.pitch;
dst_offset.x += offset_x / bpp;
dst_offset.y += offset_y / bpp;
}
u32 texture_id = m_hw_blitter.scale_image(tmp_tex, dst_surface, src_area, dst_area, dst_offset, clip_offset, dst_dimensions, clip_dimensions, dst_is_argb8);
glDeleteTextures(1, &tmp_tex);
@ -1083,7 +1095,7 @@ namespace gl
std::lock_guard<std::mutex> lock(m_section_mutex);
cached_texture_section &cached = create_texture(texture_id, dst.rsx_address, dst.pitch * dst.height, dst.width, dst.height, 1);
cached.protect(utils::protection::ro);
cached.protect(utils::protection::no);
cached.set_dirty(false);
return true;

View file

@ -58,6 +58,7 @@ namespace rsx
bool swizzled;
void *pixels;
u32 rsx_address;
};

View file

@ -543,36 +543,37 @@ namespace rsx
}
}
blit_src_info src_info;
blit_dst_info dst_info;
src_info.format = src_color_format;
src_info.width = in_w;
src_info.height = in_h;
src_info.pitch = in_pitch;
src_info.slice_h = slice_h;
src_info.offset_x = in_x;
src_info.offset_y = in_y;
src_info.pixels = pixels_src;
dst_info.format = dst_color_format;
dst_info.width = convert_w;
dst_info.height = convert_h;
dst_info.clip_x = clip_x;
dst_info.clip_y = clip_y;
dst_info.clip_width = clip_w;
dst_info.clip_height = clip_h;
dst_info.offset_x = out_x;
dst_info.offset_y = out_y;
dst_info.pitch = out_pitch;
dst_info.pixels = pixels_dst;
dst_info.rsx_address = get_address(dst_offset, dst_dma);
dst_info.swizzled = (method_registers.blit_engine_context_surface() == blit_engine::context_surface::swizzle2d);
if (need_convert)
{
//For now, only use this for actual scaled images, there are use cases that should not go through 3d engine, e.g program ucode transfer
//TODO: Figure out more instances where we can use this without problems
blit_src_info src_info;
blit_dst_info dst_info;
src_info.format = src_color_format;
src_info.width = in_w;
src_info.height = in_h;
src_info.pitch = in_pitch;
src_info.slice_h = slice_h;
src_info.offset_x = in_x;
src_info.offset_y = in_y;
src_info.pixels = pixels_src;
dst_info.format = dst_color_format;
dst_info.width = convert_w;
dst_info.height = convert_h;
dst_info.clip_x = clip_x;
dst_info.clip_y = clip_y;
dst_info.clip_width = clip_w;
dst_info.clip_height = clip_h;
dst_info.offset_x = out_x;
dst_info.offset_y = out_y;
dst_info.pitch = out_pitch;
dst_info.pixels = pixels_dst;
dst_info.rsx_address = get_address(dst_offset, dst_dma);
dst_info.swizzled = (method_registers.blit_engine_context_surface() == blit_engine::context_surface::swizzle2d);
if (rsx->scaled_image_from_memory(src_info, dst_info, in_inter == blit_engine::transfer_interpolator::foh))
return;
}