1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-24 11:43:05 +01:00

gl: Clean up format bitcast checks and register D32F type for FORMAT_CLASS16F

- Also hides a dangerous export for vulkan, same as GL
This commit is contained in:
kd-11 2022-01-25 21:53:53 +03:00 committed by kd-11
parent 3fa45ff994
commit ffe00e8619
5 changed files with 19 additions and 6 deletions

View File

@ -507,9 +507,9 @@ void gl::render_target::memory_barrier(gl::command_context& cmd, rsx::surface_ac
else
{
// Mem cast, generate typeless xfer info
if (!formats_are_bitcast_compatible(static_cast<GLenum>(get_internal_format()), static_cast<GLenum>(src_texture->get_internal_format())) ||
aspect() != src_texture->aspect())
if (!formats_are_bitcast_compatible(this, src_texture))
{
ensure(aspect() != src_texture->aspect());
typeless_info.src_is_typeless = true;
typeless_info.src_context = rsx::texture_upload_context::framebuffer_storage;
typeless_info.src_native_format_override = static_cast<u32>(get_internal_format());

View File

@ -838,6 +838,7 @@ namespace gl
case GL_RGBA32F:
return 16;
case GL_DEPTH_COMPONENT16:
case GL_DEPTH_COMPONENT32F:
return 2;
case GL_DEPTH24_STENCIL8:
case GL_DEPTH32F_STENCIL8:
@ -869,6 +870,7 @@ namespace gl
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
return { false, 4 };
case GL_DEPTH_COMPONENT16:
case GL_DEPTH_COMPONENT32F:
return { true, 2 };
case GL_DEPTH24_STENCIL8:
case GL_DEPTH32F_STENCIL8:
@ -906,6 +908,18 @@ namespace gl
return false;
}
bool formats_are_bitcast_compatible(const texture* texture1, const texture* texture2)
{
if (const u32 transfer_class = texture1->format_class() | texture2->format_class();
transfer_class & RSX_FORMAT_CLASS_DEPTH_FLOAT_MASK)
{
// If any one of the two images is a depth float, the other must match exactly or bust
return (texture1->format_class() == texture2->format_class());
}
return formats_are_bitcast_compatible(static_cast<GLenum>(texture1->get_internal_format()), static_cast<GLenum>(texture2->get_internal_format()));
}
void copy_typeless(texture * dst, const texture * src, const coord3u& dst_region, const coord3u& src_region)
{
const auto src_bpp = src->pitch() / src->width();

View File

@ -40,7 +40,7 @@ namespace gl
viewable_image* create_texture(u32 gcm_format, u16 width, u16 height, u16 depth, u16 mipmaps, rsx::texture_dimension_extended type);
bool formats_are_bitcast_compatible(GLenum format1, GLenum format2);
bool formats_are_bitcast_compatible(const texture* texture1, const texture* texture2);
void copy_typeless(texture* dst, const texture* src, const coord3u& dst_region, const coord3u& src_region);
void copy_typeless(texture* dst, const texture* src);

View File

@ -145,8 +145,8 @@ namespace gl
if (!slice.src)
continue;
const bool typeless = dst_aspect != slice.src->aspect() ||
!formats_are_bitcast_compatible(static_cast<GLenum>(slice.src->get_internal_format()), static_cast<GLenum>(dst_image->get_internal_format()));
const bool typeless = !formats_are_bitcast_compatible(slice.src, dst_image);
ensure(typeless || dst_aspect == slice.src->aspect());
std::unique_ptr<gl::texture> tmp;
auto src_image = slice.src;

View File

@ -23,7 +23,6 @@ namespace vk
u8 get_format_texel_width(VkFormat format);
std::pair<u8, u8> get_format_element_size(VkFormat format);
std::pair<bool, u32> get_format_convert_flags(VkFormat format);
bool formats_are_bitcast_compatible(VkFormat format1, VkFormat format2);
bool formats_are_bitcast_compatible(image* image1, image* image2);
minification_filter get_min_filter(rsx::texture_minify_filter min_filter);