mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-15 14:42:40 +00:00
gl/vk: Better handling of inter-format data copies
- RGBA8->RG16 does not require special instructions so the overlay pass is disabled for OGL
This commit is contained in:
parent
896c8991de
commit
3fbc960c44
@ -199,9 +199,10 @@ namespace gl
|
||||
}
|
||||
};
|
||||
|
||||
struct rgba8_rg16_convert_pass : public overlay_pass
|
||||
struct rgba8_unorm_rg16_sfloat_convert_pass : public overlay_pass
|
||||
{
|
||||
rgba8_rg16_convert_pass()
|
||||
//Not really needed since directly copying data via ARB_copy_image works out fine
|
||||
rgba8_unorm_rg16_sfloat_convert_pass()
|
||||
{
|
||||
vs_src =
|
||||
{
|
||||
@ -222,13 +223,8 @@ namespace gl
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" uvec4 rgba_in = uvec4(texelFetch(fs0, ivec2(gl_FragCoord.xy), 0) * 255. + vec4(0.5)).wyzx;\n"
|
||||
" uint value = rgba_in.x | rgba_in.y << 8 | rgba_in.z << 16 | rgba_in.w << 24;\n"
|
||||
" uint value = packUnorm4x8(texelFetch(fs0, ivec2(gl_FragCoord.xy), 0).zyxw);\n"
|
||||
" ocol.xy = unpackHalf2x16(value);\n"
|
||||
" if (isnan(ocol.x)) ocol.x = 1.;\n"
|
||||
" if (isnan(ocol.y)) ocol.y = 1.;\n"
|
||||
" if (isinf(ocol.x)) ocol.x = 65504.;\n"
|
||||
" if (isinf(ocol.y)) ocol.y = 65504.;\n"
|
||||
"}\n"
|
||||
};
|
||||
}
|
||||
|
@ -580,7 +580,6 @@ namespace gl
|
||||
private:
|
||||
|
||||
blitter m_hw_blitter;
|
||||
gl::rgba8_rg16_convert_pass m_rgba8_rg16_converter;
|
||||
std::vector<u32> m_temporary_surfaces;
|
||||
|
||||
cached_texture_section& create_texture(u32 id, u32 texaddr, u32 texsize, u32 w, u32 h, u32 depth, u32 mipmaps)
|
||||
@ -654,16 +653,6 @@ namespace gl
|
||||
//Empty GL_ERROR
|
||||
glGetError();
|
||||
|
||||
if (ifmt != sized_internal_fmt)
|
||||
{
|
||||
if (sized_internal_fmt == GL_RG16F && ifmt == GL_RGBA8_EXT)
|
||||
{
|
||||
//TODO: Better sized internal format detection
|
||||
m_rgba8_rg16_converter.run(width, height, dst_id, src_id);
|
||||
return dst_id;
|
||||
}
|
||||
}
|
||||
|
||||
glCopyImageSubData(src_id, GL_TEXTURE_2D, 0, x, y, 0,
|
||||
dst_id, dst_type, 0, 0, 0, 0, width, height, 1);
|
||||
|
||||
@ -833,8 +822,6 @@ namespace gl
|
||||
{
|
||||
m_hw_blitter.init();
|
||||
g_hw_blitter = &m_hw_blitter;
|
||||
|
||||
m_rgba8_rg16_converter.create();
|
||||
}
|
||||
|
||||
void destroy() override
|
||||
@ -842,8 +829,6 @@ namespace gl
|
||||
clear();
|
||||
g_hw_blitter = nullptr;
|
||||
m_hw_blitter.destroy();
|
||||
|
||||
m_rgba8_rg16_converter.destroy();
|
||||
}
|
||||
|
||||
bool is_depth_texture(const u32 rsx_address, const u32 rsx_size) override
|
||||
|
@ -465,7 +465,7 @@ namespace vk
|
||||
tex.destroy();
|
||||
}
|
||||
|
||||
vk::image_view* create_temporary_subresource_view_impl(vk::command_buffer& cmd, vk::image* source, VkImageType image_type, VkImageViewType view_type, u16 x, u16 y, u16 w, u16 h)
|
||||
vk::image_view* create_temporary_subresource_view_impl(vk::command_buffer& cmd, vk::image* source, VkImageType image_type, VkImageViewType view_type, u32 gcm_format, u16 x, u16 y, u16 w, u16 h)
|
||||
{
|
||||
VkImageAspectFlags aspect = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
|
||||
@ -480,6 +480,13 @@ namespace vk
|
||||
break;
|
||||
}
|
||||
|
||||
VkFormat dst_format = vk::get_compatible_sampler_format(gcm_format);
|
||||
if (aspect & VK_IMAGE_ASPECT_DEPTH_BIT ||
|
||||
vk::get_format_texel_width(dst_format) != vk::get_format_texel_width(source->info.format))
|
||||
{
|
||||
dst_format = source->info.format;
|
||||
}
|
||||
|
||||
VkImageSubresourceRange subresource_range = { aspect, 0, 1, 0, 1 };
|
||||
|
||||
std::unique_ptr<vk::image> image;
|
||||
@ -487,12 +494,12 @@ namespace vk
|
||||
|
||||
image.reset(new vk::image(*vk::get_current_renderer(), m_memory_types.device_local, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||
image_type,
|
||||
source->info.format,
|
||||
dst_format,
|
||||
w, h, 1, 1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, source->info.flags));
|
||||
|
||||
VkImageSubresourceRange view_range = { aspect & ~(VK_IMAGE_ASPECT_STENCIL_BIT), 0, 1, 0, 1 };
|
||||
view.reset(new vk::image_view(*vk::get_current_renderer(), image->value, view_type, source->info.format, source->native_component_map, view_range));
|
||||
view.reset(new vk::image_view(*vk::get_current_renderer(), image->value, view_type, dst_format, source->native_component_map, view_range));
|
||||
|
||||
VkImageLayout old_src_layout = source->current_layout;
|
||||
|
||||
@ -518,9 +525,9 @@ namespace vk
|
||||
return m_discardable_storage.back().view.get();
|
||||
}
|
||||
|
||||
vk::image_view* create_temporary_subresource_view(vk::command_buffer& cmd, vk::image* source, u32 /*gcm_format*/, u16 x, u16 y, u16 w, u16 h) override
|
||||
vk::image_view* create_temporary_subresource_view(vk::command_buffer& cmd, vk::image* source, u32 gcm_format, u16 x, u16 y, u16 w, u16 h) override
|
||||
{
|
||||
return create_temporary_subresource_view_impl(cmd, source, source->info.imageType, VK_IMAGE_VIEW_TYPE_2D, x, y, w, h);
|
||||
return create_temporary_subresource_view_impl(cmd, source, source->info.imageType, VK_IMAGE_VIEW_TYPE_2D, gcm_format, x, y, w, h);
|
||||
}
|
||||
|
||||
vk::image_view* create_temporary_subresource_view(vk::command_buffer& cmd, vk::image** source, u32 gcm_format, u16 x, u16 y, u16 w, u16 h) override
|
||||
|
Loading…
x
Reference in New Issue
Block a user