mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-14 01:27:00 +00:00
gl: Separate BGRA8 storage from RGBA8
This commit is contained in:
parent
f4e85af53c
commit
09824a718f
@ -27,7 +27,7 @@ color_format rsx::internals::surface_color_format_to_gl(rsx::surface_color_forma
|
||||
{ ::gl::texture::channel::zero, ::gl::texture::channel::r, ::gl::texture::channel::g, ::gl::texture::channel::b } };
|
||||
|
||||
case rsx::surface_color_format::x8r8g8b8_z8r8g8b8:
|
||||
return{ ::gl::texture::type::uint_8_8_8_8, ::gl::texture::format::bgra, ::gl::texture::internal_format::rgba8, false,
|
||||
return{ ::gl::texture::type::uint_8_8_8_8, ::gl::texture::format::bgra, ::gl::texture::internal_format::bgra8, false,
|
||||
{ ::gl::texture::channel::zero, ::gl::texture::channel::r, ::gl::texture::channel::g, ::gl::texture::channel::b } };
|
||||
|
||||
case rsx::surface_color_format::x8b8g8r8_o8b8g8r8:
|
||||
@ -39,7 +39,7 @@ color_format rsx::internals::surface_color_format_to_gl(rsx::surface_color_forma
|
||||
{ ::gl::texture::channel::zero, ::gl::texture::channel::b, ::gl::texture::channel::g, ::gl::texture::channel::r } };
|
||||
|
||||
case rsx::surface_color_format::x8r8g8b8_o8r8g8b8:
|
||||
return{ ::gl::texture::type::uint_8_8_8_8, ::gl::texture::format::bgra, ::gl::texture::internal_format::rgba8, false,
|
||||
return{ ::gl::texture::type::uint_8_8_8_8, ::gl::texture::format::bgra, ::gl::texture::internal_format::bgra8, false,
|
||||
{ ::gl::texture::channel::one, ::gl::texture::channel::r, ::gl::texture::channel::g, ::gl::texture::channel::b } };
|
||||
|
||||
case rsx::surface_color_format::w16z16y16x16:
|
||||
|
@ -77,7 +77,7 @@ namespace gl
|
||||
case CELL_GCM_TEXTURE_A1R5G5B5: return GL_RGB5_A1;
|
||||
case CELL_GCM_TEXTURE_A4R4G4B4: return GL_RGBA4;
|
||||
case CELL_GCM_TEXTURE_R5G6B5: return GL_RGB565;
|
||||
case CELL_GCM_TEXTURE_A8R8G8B8: return GL_RGBA8;
|
||||
case CELL_GCM_TEXTURE_A8R8G8B8: return GL_BGRA8;
|
||||
case CELL_GCM_TEXTURE_G8B8: return GL_RG8;
|
||||
case CELL_GCM_TEXTURE_R6G5B5: return GL_RGB565;
|
||||
case CELL_GCM_TEXTURE_DEPTH24_D8: return GL_DEPTH24_STENCIL8;
|
||||
@ -91,7 +91,7 @@ namespace gl
|
||||
case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT: return GL_RGBA32F;
|
||||
case CELL_GCM_TEXTURE_X32_FLOAT: return GL_R32F;
|
||||
case CELL_GCM_TEXTURE_D1R5G5B5: return GL_RGB5_A1;
|
||||
case CELL_GCM_TEXTURE_D8R8G8B8: return GL_RGBA8;
|
||||
case CELL_GCM_TEXTURE_D8R8G8B8: return GL_BGRA8;
|
||||
case CELL_GCM_TEXTURE_Y16_X16_FLOAT: return GL_RG16F;
|
||||
case CELL_GCM_TEXTURE_COMPRESSED_DXT1: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
case CELL_GCM_TEXTURE_COMPRESSED_DXT23: return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
||||
@ -166,6 +166,8 @@ namespace gl
|
||||
case texture::internal_format::rgba4:
|
||||
return { GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, false };
|
||||
case texture::internal_format::rgba8:
|
||||
return { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, false };
|
||||
case texture::internal_format::bgra8:
|
||||
return { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, false };
|
||||
case texture::internal_format::rgba16f:
|
||||
return { GL_RGBA, GL_HALF_FLOAT, 2, true };
|
||||
@ -185,25 +187,7 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto ret = get_format_type(ifmt);
|
||||
auto ret = get_format_type(tex->get_internal_format());
|
||||
if (tex->format_class() == RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32)
|
||||
{
|
||||
ret.type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
|
||||
@ -508,6 +492,7 @@ namespace gl
|
||||
pack_info, {});
|
||||
return;
|
||||
case gl::texture::internal_format::rgba8:
|
||||
case gl::texture::internal_format::bgra8:
|
||||
gl::get_compute_task<gl::cs_rgba8_to_ssbo>()->run(cmd,
|
||||
const_cast<gl::viewable_image*>(as_vi), dst, dst_offset,
|
||||
{ {src_region.x, src_region.y}, {src_region.width, src_region.height} },
|
||||
@ -990,6 +975,7 @@ namespace gl
|
||||
case GL_RG16:
|
||||
case GL_RG16F:
|
||||
case GL_RGBA8:
|
||||
case GL_BGRA8:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
|
@ -818,6 +818,7 @@ namespace gl
|
||||
case CELL_GCM_TEXTURE_A8R8G8B8:
|
||||
case CELL_GCM_TEXTURE_D8R8G8B8:
|
||||
return (ifmt == gl::texture::internal_format::rgba8 ||
|
||||
ifmt == gl::texture::internal_format::bgra8 ||
|
||||
ifmt == gl::texture::internal_format::depth24_stencil8 ||
|
||||
ifmt == gl::texture::internal_format::depth32f_stencil8);
|
||||
case CELL_GCM_TEXTURE_B8:
|
||||
|
@ -6,6 +6,11 @@
|
||||
|
||||
namespace gl
|
||||
{
|
||||
static GLenum sizedfmt_to_ifmt(GLenum sized)
|
||||
{
|
||||
return sized == GL_BGRA8 ? GL_RGBA8 : sized;
|
||||
}
|
||||
|
||||
texture::texture(GLenum target, GLuint width, GLuint height, GLuint depth, GLuint mipmaps, GLenum sized_format, rsx::format_class format_class)
|
||||
{
|
||||
glGenTextures(1, &m_id);
|
||||
@ -13,22 +18,23 @@ namespace gl
|
||||
// Must bind to initialize the new texture
|
||||
gl::get_command_context()->bind_texture(GL_TEMP_IMAGE_SLOT, target, m_id);
|
||||
|
||||
const GLenum storage_fmt = sizedfmt_to_ifmt(sized_format);
|
||||
switch (target)
|
||||
{
|
||||
default:
|
||||
fmt::throw_exception("Invalid image target 0x%X", target);
|
||||
case GL_TEXTURE_1D:
|
||||
glTexStorage1D(target, mipmaps, sized_format, width);
|
||||
glTexStorage1D(target, mipmaps, storage_fmt, width);
|
||||
height = depth = 1;
|
||||
break;
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
glTexStorage2D(target, mipmaps, sized_format, width, height);
|
||||
glTexStorage2D(target, mipmaps, storage_fmt, width, height);
|
||||
depth = 1;
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
glTexStorage3D(target, mipmaps, sized_format, width, height, depth);
|
||||
glTexStorage3D(target, mipmaps, storage_fmt, width, height, depth);
|
||||
break;
|
||||
case GL_TEXTURE_BUFFER:
|
||||
break;
|
||||
@ -221,7 +227,7 @@ namespace gl
|
||||
void texture_view::create(texture* data, GLenum target, GLenum sized_format, GLenum aspect_flags, const GLenum* argb_swizzle)
|
||||
{
|
||||
m_target = target;
|
||||
m_format = sized_format;
|
||||
m_format = sizedfmt_to_ifmt(sized_format);
|
||||
m_image_data = data;
|
||||
m_aspect_flags = aspect_flags;
|
||||
|
||||
@ -237,7 +243,7 @@ namespace gl
|
||||
}
|
||||
|
||||
glGenTextures(1, &m_id);
|
||||
glTextureView(m_id, target, data->id(), sized_format, 0, data->levels(), 0, num_layers);
|
||||
glTextureView(m_id, target, data->id(), m_format, 0, data->levels(), 0, num_layers);
|
||||
|
||||
if (argb_swizzle)
|
||||
{
|
||||
|
@ -10,6 +10,8 @@ using namespace ::rsx::format_class_;
|
||||
|
||||
namespace gl
|
||||
{
|
||||
#define GL_BGRA8 0x80E1 // Enumerant of GL_BGRA8_EXT from the GL_EXT_texture_format_BGRA8888
|
||||
|
||||
class buffer;
|
||||
class buffer_view;
|
||||
class command_context;
|
||||
@ -99,6 +101,7 @@ namespace gl
|
||||
|
||||
//Sized internal formats, see opengl spec document on glTexImage2D, table 3
|
||||
rgba8 = GL_RGBA8,
|
||||
bgra8 = GL_BGRA8,
|
||||
rgb565 = GL_RGB565,
|
||||
rgb5a1 = GL_RGB5_A1,
|
||||
rgba4 = GL_RGBA4,
|
||||
|
Loading…
x
Reference in New Issue
Block a user