mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-06 18:40:36 +00:00
rsx: Proper support for typeless transform of ABGR framebuffers using the RGBA8 format
This commit is contained in:
parent
6850533b50
commit
b41349546c
@ -1022,7 +1022,7 @@ std::pair<u32, bool> get_compatible_gcm_format(rsx::surface_color_format format)
|
||||
case rsx::surface_color_format::x8b8g8r8_o8b8g8r8:
|
||||
case rsx::surface_color_format::x8b8g8r8_z8b8g8r8:
|
||||
case rsx::surface_color_format::a8b8g8r8:
|
||||
return{ CELL_GCM_TEXTURE_A8R8G8B8, false };
|
||||
return{ CELL_GCM_TEXTURE_A8R8G8B8, true };
|
||||
|
||||
case rsx::surface_color_format::w16z16y16x16:
|
||||
return{ CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT, true };
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "GLTexture.h"
|
||||
#include "GLCompute.h"
|
||||
#include "GLRenderTargets.h"
|
||||
#include "../GCM.h"
|
||||
#include "../RSXThread.h"
|
||||
#include "../RSXTexture.h"
|
||||
@ -133,6 +134,29 @@ namespace gl
|
||||
}
|
||||
}
|
||||
|
||||
pixel_buffer_layout get_format_type(const gl::texture* tex)
|
||||
{
|
||||
const auto ifmt = tex->get_internal_format();
|
||||
if (ifmt == gl::texture::internal_format::rgba8)
|
||||
{
|
||||
// Multiple RTT layouts can map to this format. Override ABGR formats
|
||||
if (auto rtt = dynamic_cast<const gl::render_target*>(tex))
|
||||
{
|
||||
switch (rtt->format_info.gcm_color_format)
|
||||
{
|
||||
case rsx::surface_color_format::x8b8g8r8_z8b8g8r8:
|
||||
case rsx::surface_color_format::x8b8g8r8_o8b8g8r8:
|
||||
case rsx::surface_color_format::a8b8g8r8:
|
||||
return { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, false };
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return get_format_type(ifmt);
|
||||
}
|
||||
|
||||
GLenum get_srgb_format(GLenum in_format)
|
||||
{
|
||||
switch (in_format)
|
||||
@ -780,8 +804,8 @@ namespace gl
|
||||
}
|
||||
|
||||
const auto& caps = gl::get_driver_caps();
|
||||
const auto pack_info = get_format_type(src->get_internal_format());
|
||||
const auto unpack_info = get_format_type(dst->get_internal_format());
|
||||
auto pack_info = get_format_type(src);
|
||||
auto unpack_info = get_format_type(dst);
|
||||
|
||||
// Start pack operation
|
||||
g_typeless_transfer_buffer.bind(buffer::target::pixel_pack);
|
||||
|
@ -395,10 +395,11 @@ namespace vk
|
||||
//8-bit
|
||||
case VK_FORMAT_R8_UNORM:
|
||||
case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
return{ false, 1 };
|
||||
case VK_FORMAT_B8G8R8A8_UNORM:
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
case VK_FORMAT_B8G8R8A8_SRGB:
|
||||
case VK_FORMAT_R8G8B8A8_SRGB:
|
||||
return{ true, 4 };
|
||||
//16-bit
|
||||
case VK_FORMAT_R16_UINT:
|
||||
|
@ -42,11 +42,8 @@ namespace vk
|
||||
|
||||
std::pair<VkFormat, VkComponentMapping> get_compatible_surface_format(rsx::surface_color_format color_format)
|
||||
{
|
||||
const VkComponentMapping abgr = { VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_A };
|
||||
const VkComponentMapping o_rgb = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ONE };
|
||||
const VkComponentMapping z_rgb = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ZERO };
|
||||
const VkComponentMapping o_bgr = { VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_ONE };
|
||||
const VkComponentMapping z_bgr = { VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_ZERO };
|
||||
|
||||
switch (color_format)
|
||||
{
|
||||
@ -57,13 +54,13 @@ namespace vk
|
||||
return std::make_pair(VK_FORMAT_B8G8R8A8_UNORM, vk::default_component_map());
|
||||
|
||||
case rsx::surface_color_format::a8b8g8r8:
|
||||
return std::make_pair(VK_FORMAT_B8G8R8A8_UNORM, abgr);
|
||||
return std::make_pair(VK_FORMAT_R8G8B8A8_UNORM, vk::default_component_map());
|
||||
|
||||
case rsx::surface_color_format::x8b8g8r8_o8b8g8r8:
|
||||
return std::make_pair(VK_FORMAT_B8G8R8A8_UNORM, o_bgr);
|
||||
return std::make_pair(VK_FORMAT_R8G8B8A8_UNORM, o_rgb);
|
||||
|
||||
case rsx::surface_color_format::x8b8g8r8_z8b8g8r8:
|
||||
return std::make_pair(VK_FORMAT_B8G8R8A8_UNORM, z_bgr);
|
||||
return std::make_pair(VK_FORMAT_R8G8B8A8_UNORM, z_rgb);
|
||||
|
||||
case rsx::surface_color_format::x8r8g8b8_z8r8g8b8:
|
||||
return std::make_pair(VK_FORMAT_B8G8R8A8_UNORM, z_rgb);
|
||||
|
@ -12,6 +12,7 @@ namespace
|
||||
{
|
||||
case VK_FORMAT_R5G6B5_UNORM_PACK16:
|
||||
return "r16ui";
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
case VK_FORMAT_B8G8R8A8_UNORM:
|
||||
return "rgba8";
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT:
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "VKFormats.h"
|
||||
#include "VKCompute.h"
|
||||
#include "VKRenderPass.h"
|
||||
#include "VKRenderTargets.h"
|
||||
|
||||
namespace vk
|
||||
{
|
||||
@ -265,8 +266,8 @@ namespace vk
|
||||
{
|
||||
vk::copy_image_to_buffer(cmd, src, scratch_buf, src_copy);
|
||||
|
||||
const auto src_convert = get_format_convert_flags(src->info.format);
|
||||
const auto dst_convert = get_format_convert_flags(dst->info.format);
|
||||
auto src_convert = get_format_convert_flags(src->info.format);
|
||||
auto dst_convert = get_format_convert_flags(dst->info.format);
|
||||
|
||||
if (src_convert.first || dst_convert.first)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user