mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-13 02:08:49 +12:00
rsx: Hack around using data regions as transfer targets
This commit is contained in:
parent
4182f9984d
commit
88290d9fab
6 changed files with 73 additions and 31 deletions
|
@ -21,6 +21,13 @@ namespace rsx
|
||||||
srgb_nonlinear = 1
|
srgb_nonlinear = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum surface_usage_flags : u32
|
||||||
|
{
|
||||||
|
unknown = 0,
|
||||||
|
attachment = 1,
|
||||||
|
storage = 2
|
||||||
|
};
|
||||||
|
|
||||||
//Sampled image descriptor
|
//Sampled image descriptor
|
||||||
struct sampled_image_descriptor_base
|
struct sampled_image_descriptor_base
|
||||||
{
|
{
|
||||||
|
|
|
@ -134,6 +134,8 @@ namespace rsx
|
||||||
GcmTileInfo *tile = nullptr;
|
GcmTileInfo *tile = nullptr;
|
||||||
rsx::surface_antialiasing write_aa_mode = rsx::surface_antialiasing::center_1_sample;
|
rsx::surface_antialiasing write_aa_mode = rsx::surface_antialiasing::center_1_sample;
|
||||||
|
|
||||||
|
flags32_t usage = surface_usage_flags::unknown;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
rsx::surface_color_format gcm_color_format;
|
rsx::surface_color_format gcm_color_format;
|
||||||
|
|
|
@ -2459,11 +2459,24 @@ namespace rsx
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.back().is_clipped && !allow_clipped)
|
|
||||||
{
|
|
||||||
for (auto It = list.rbegin(); It != list.rend(); ++It)
|
for (auto It = list.rbegin(); It != list.rend(); ++It)
|
||||||
{
|
{
|
||||||
if (!It->is_clipped)
|
if (!(It->surface->usage & rsx::surface_usage_flags::attachment))
|
||||||
|
{
|
||||||
|
// HACK
|
||||||
|
// TODO: Properly analyse the input here to determine if it can properly fit what we need
|
||||||
|
// This is a problem due to chunked transfer
|
||||||
|
// First 2 512x720 blocks go into a cpu-side buffer but suddenly when its time to render the final 256x720
|
||||||
|
// it falls onto some storage buffer in surface cache that has bad dimensions
|
||||||
|
// Proper solution is to always merge when a cpu resource is created (it should absorb the render targets in range)
|
||||||
|
// We then should not have any 'dst-is-rendertarget' surfaces in use
|
||||||
|
// Option 2: Make surfaces here part of surface cache and do not pad them for optimization
|
||||||
|
// Surface cache is good at merging for resolve operations. This keeps integrity even when drawing to the rendertgargets
|
||||||
|
// This option needs a lot more work
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!It->is_clipped || allow_clipped)
|
||||||
{
|
{
|
||||||
return *It;
|
return *It;
|
||||||
}
|
}
|
||||||
|
@ -2490,9 +2503,6 @@ namespace rsx
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
|
||||||
|
|
||||||
return list.back();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if src/dst are parts of render targets
|
// Check if src/dst are parts of render targets
|
||||||
|
|
|
@ -188,6 +188,7 @@ struct gl_render_target_traits
|
||||||
std::array<GLenum, 4> native_layout = { (GLenum)format.swizzle.a, (GLenum)format.swizzle.r, (GLenum)format.swizzle.g, (GLenum)format.swizzle.b };
|
std::array<GLenum, 4> native_layout = { (GLenum)format.swizzle.a, (GLenum)format.swizzle.r, (GLenum)format.swizzle.g, (GLenum)format.swizzle.b };
|
||||||
result->set_native_component_layout(native_layout);
|
result->set_native_component_layout(native_layout);
|
||||||
|
|
||||||
|
result->usage = rsx::surface_usage_flags::attachment;
|
||||||
result->set_cleared(false);
|
result->set_cleared(false);
|
||||||
result->queue_tag(address);
|
result->queue_tag(address);
|
||||||
result->add_ref();
|
result->add_ref();
|
||||||
|
@ -215,6 +216,7 @@ struct gl_render_target_traits
|
||||||
result->set_native_component_layout(native_layout);
|
result->set_native_component_layout(native_layout);
|
||||||
result->set_format(surface_depth_format);
|
result->set_format(surface_depth_format);
|
||||||
|
|
||||||
|
result->usage = rsx::surface_usage_flags::attachment;
|
||||||
result->set_cleared(false);
|
result->set_cleared(false);
|
||||||
result->queue_tag(address);
|
result->queue_tag(address);
|
||||||
result->add_ref();
|
result->add_ref();
|
||||||
|
@ -234,6 +236,7 @@ struct gl_render_target_traits
|
||||||
const auto new_h = rsx::apply_resolution_scale(prev.height, true, ref->get_surface_height());
|
const auto new_h = rsx::apply_resolution_scale(prev.height, true, ref->get_surface_height());
|
||||||
|
|
||||||
sink.reset(new gl::render_target(new_w, new_h, internal_format));
|
sink.reset(new gl::render_target(new_w, new_h, internal_format));
|
||||||
|
sink->usage = rsx::surface_usage_flags::storage;
|
||||||
sink->add_ref();
|
sink->add_ref();
|
||||||
sink->format_info = ref->format_info;
|
sink->format_info = ref->format_info;
|
||||||
sink->set_native_pitch(prev.width * ref->get_bpp());
|
sink->set_native_pitch(prev.width * ref->get_bpp());
|
||||||
|
@ -272,10 +275,17 @@ struct gl_render_target_traits
|
||||||
info->bpp = surface->get_bpp();
|
info->bpp = surface->get_bpp();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prepare_rtt_for_drawing(gl::command_context&, gl::render_target*) {}
|
static void prepare_rtt_for_drawing(gl::command_context&, gl::render_target* rtt)
|
||||||
static void prepare_rtt_for_sampling(gl::command_context&, gl::render_target*) {}
|
{
|
||||||
|
rtt->usage |= rsx::surface_usage_flags::attachment;
|
||||||
|
}
|
||||||
|
|
||||||
static void prepare_ds_for_drawing(gl::command_context&, gl::render_target*) {}
|
static void prepare_ds_for_drawing(gl::command_context&, gl::render_target* ds)
|
||||||
|
{
|
||||||
|
ds->usage |= rsx::surface_usage_flags::attachment;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void prepare_rtt_for_sampling(gl::command_context&, gl::render_target*) {}
|
||||||
static void prepare_ds_for_sampling(gl::command_context&, gl::render_target*) {}
|
static void prepare_ds_for_sampling(gl::command_context&, gl::render_target*) {}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -292,6 +302,7 @@ struct gl_render_target_traits
|
||||||
surface->queue_tag(address);
|
surface->queue_tag(address);
|
||||||
surface->set_cleared(false);
|
surface->set_cleared(false);
|
||||||
surface->last_use_tag = 0;
|
surface->last_use_tag = 0;
|
||||||
|
surface->usage = rsx::surface_usage_flags::unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -197,6 +197,7 @@ namespace rsx
|
||||||
change_image_layout(cmd, rtt.get(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT));
|
change_image_layout(cmd, rtt.get(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT));
|
||||||
|
|
||||||
rtt->set_format(format);
|
rtt->set_format(format);
|
||||||
|
rtt->usage = rsx::surface_usage_flags::attachment;
|
||||||
rtt->native_component_map = fmt.second;
|
rtt->native_component_map = fmt.second;
|
||||||
rtt->rsx_pitch = (u16)pitch;
|
rtt->rsx_pitch = (u16)pitch;
|
||||||
rtt->native_pitch = (u16)width * get_format_block_size_in_bytes(format);
|
rtt->native_pitch = (u16)width * get_format_block_size_in_bytes(format);
|
||||||
|
@ -235,7 +236,9 @@ namespace rsx
|
||||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT| VK_IMAGE_USAGE_TRANSFER_SRC_BIT| VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT,
|
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT| VK_IMAGE_USAGE_TRANSFER_SRC_BIT| VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||||
0));
|
0));
|
||||||
|
|
||||||
|
|
||||||
ds->set_format(format);
|
ds->set_format(format);
|
||||||
|
ds->usage = rsx::surface_usage_flags::attachment;
|
||||||
ds->native_component_map = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R };
|
ds->native_component_map = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R };
|
||||||
change_image_layout(cmd, ds.get(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, range);
|
change_image_layout(cmd, ds.get(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, range);
|
||||||
|
|
||||||
|
@ -277,6 +280,7 @@ namespace rsx
|
||||||
|
|
||||||
sink->add_ref();
|
sink->add_ref();
|
||||||
sink->format_info = ref->format_info;
|
sink->format_info = ref->format_info;
|
||||||
|
sink->usage = rsx::surface_usage_flags::storage;
|
||||||
sink->native_component_map = ref->native_component_map;
|
sink->native_component_map = ref->native_component_map;
|
||||||
sink->native_pitch = u16(prev.width * ref->get_bpp());
|
sink->native_pitch = u16(prev.width * ref->get_bpp());
|
||||||
sink->surface_width = prev.width;
|
sink->surface_width = prev.width;
|
||||||
|
@ -315,6 +319,7 @@ namespace rsx
|
||||||
{
|
{
|
||||||
surface->change_layout(cmd, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
surface->change_layout(cmd, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
surface->frame_tag = 0;
|
surface->frame_tag = 0;
|
||||||
|
surface->usage |= rsx::surface_usage_flags::attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prepare_rtt_for_sampling(vk::command_buffer& cmd, vk::render_target *surface)
|
static void prepare_rtt_for_sampling(vk::command_buffer& cmd, vk::render_target *surface)
|
||||||
|
@ -326,6 +331,7 @@ namespace rsx
|
||||||
{
|
{
|
||||||
surface->change_layout(cmd, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
surface->change_layout(cmd, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
surface->frame_tag = 0;
|
surface->frame_tag = 0;
|
||||||
|
surface->usage |= rsx::surface_usage_flags::attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prepare_ds_for_sampling(vk::command_buffer& cmd, vk::render_target *surface)
|
static void prepare_ds_for_sampling(vk::command_buffer& cmd, vk::render_target *surface)
|
||||||
|
@ -345,6 +351,7 @@ namespace rsx
|
||||||
surface->queue_tag(address);
|
surface->queue_tag(address);
|
||||||
surface->dirty = true;
|
surface->dirty = true;
|
||||||
surface->last_use_tag = 0;
|
surface->last_use_tag = 0;
|
||||||
|
surface->usage = rsx::surface_usage_flags::unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void notify_surface_invalidated(const std::unique_ptr<vk::render_target> &surface)
|
static void notify_surface_invalidated(const std::unique_ptr<vk::render_target> &surface)
|
||||||
|
|
|
@ -27,6 +27,11 @@ namespace rsx
|
||||||
using utils::page_end;
|
using utils::page_end;
|
||||||
using utils::next_page;
|
using utils::next_page;
|
||||||
|
|
||||||
|
using flags64_t = uint64_t;
|
||||||
|
using flags32_t = uint32_t;
|
||||||
|
using flags16_t = uint16_t;
|
||||||
|
using flags8_t = uint8_t;
|
||||||
|
|
||||||
// Definitions
|
// Definitions
|
||||||
class thread;
|
class thread;
|
||||||
extern thread* g_current_renderer;
|
extern thread* g_current_renderer;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue