mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 08:51:28 +12:00
rsx: Texture format fixes
- Implement SRGB (gamma corrected) textures (DXT1, DXT3, DXT5, RGBA8 only) - Fix channel map decode for XY data texture formats - Fix remap layout for X16 textures (verified with Mass Effect 3)
This commit is contained in:
parent
a35bcb131e
commit
5817f9fe3f
10 changed files with 92 additions and 24 deletions
|
@ -90,6 +90,24 @@ namespace gl
|
|||
fmt::throw_exception("Compressed or unknown texture format 0x%x" HERE, texture_format);
|
||||
}
|
||||
|
||||
GLenum get_srgb_format(GLenum in_format)
|
||||
{
|
||||
switch (in_format)
|
||||
{
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
|
||||
case GL_RGBA8:
|
||||
return GL_SRGB8_ALPHA8;
|
||||
default:
|
||||
//LOG_ERROR(RSX, "No gamma coversion for format 0x%X", in_format);
|
||||
return in_format;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum wrap_mode(rsx::texture_wrap_mode wrap)
|
||||
{
|
||||
switch (wrap)
|
||||
|
@ -288,7 +306,8 @@ namespace gl
|
|||
return{ GL_ONE, GL_RED, GL_RED, GL_RED };
|
||||
|
||||
case CELL_GCM_TEXTURE_X16:
|
||||
return{ GL_RED, GL_ONE, GL_RED, GL_ONE };
|
||||
//Blue component is also R (Mass Effect 3)
|
||||
return{ GL_RED, GL_ONE, GL_RED, GL_RED };
|
||||
|
||||
case CELL_GCM_TEXTURE_X32_FLOAT:
|
||||
return{ GL_RED, GL_RED, GL_RED, GL_RED };
|
||||
|
@ -317,7 +336,8 @@ namespace gl
|
|||
fmt::throw_exception("Unknown format 0x%x" HERE, texture_format);
|
||||
}
|
||||
|
||||
GLuint create_texture(u32 gcm_format, u16 width, u16 height, u16 depth, u16 mipmaps, rsx::texture_dimension_extended type)
|
||||
GLuint create_texture(u32 gcm_format, u16 width, u16 height, u16 depth, u16 mipmaps,
|
||||
rsx::texture_dimension_extended type, rsx::texture_colorspace colorspace)
|
||||
{
|
||||
if (is_compressed_format(gcm_format))
|
||||
{
|
||||
|
@ -331,6 +351,9 @@ namespace gl
|
|||
GLenum target;
|
||||
GLenum internal_format = get_sized_internal_format(gcm_format);
|
||||
|
||||
if (colorspace != rsx::texture_colorspace::rgb_linear)
|
||||
internal_format = get_srgb_format(internal_format);
|
||||
|
||||
glGenTextures(1, &id);
|
||||
|
||||
switch (type)
|
||||
|
@ -507,7 +530,8 @@ namespace gl
|
|||
}
|
||||
|
||||
void upload_texture(GLuint id, u32 texaddr, u32 gcm_format, u16 width, u16 height, u16 depth, u16 mipmaps, bool is_swizzled, rsx::texture_dimension_extended type,
|
||||
const std::vector<rsx_subresource_layout>& subresources_layout, const std::pair<std::array<u8, 4>, std::array<u8, 4>>& decoded_remap, bool static_state)
|
||||
const std::vector<rsx_subresource_layout>& subresources_layout, const std::pair<std::array<u8, 4>, std::array<u8, 4>>& decoded_remap, bool static_state,
|
||||
rsx::texture_colorspace colorspace)
|
||||
{
|
||||
const bool is_cubemap = type == rsx::texture_dimension_extended::texture_dimension_cubemap;
|
||||
|
||||
|
@ -564,7 +588,7 @@ namespace gl
|
|||
|
||||
//The rest of sampler state is now handled by sampler state objects
|
||||
const auto format_type = get_format_type(gcm_format);
|
||||
const GLenum gl_format = std::get<0>(format_type);
|
||||
const GLenum gl_format = (colorspace == rsx::texture_colorspace::rgb_linear)? std::get<0>(format_type) : get_srgb_format(std::get<0>(format_type));
|
||||
const GLenum gl_type = std::get<1>(format_type);
|
||||
fill_texture(type, mipmaps, gcm_format, width, height, depth, subresources_layout, is_swizzled, gl_format, gl_type, data_upload_buf);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue