rsx: Fix texture depth read

This commit is contained in:
eladash 2018-10-01 09:14:52 +03:00 committed by kd-11
parent 4174d7274d
commit fa723f6dc4
4 changed files with 7 additions and 13 deletions

View File

@ -527,22 +527,18 @@ u8 get_format_block_size_in_bytes(rsx::surface_color_format format)
size_t get_placed_texture_storage_size(u16 width, u16 height, u32 depth, u8 format, u16 mipmap, bool cubemap, size_t row_pitch_alignment, size_t mipmap_alignment)
{
size_t w = width;
size_t h = height;
size_t d = std::max<u16>(depth, 1);
format &= ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
size_t block_edge = get_format_block_size_in_texel(format);
size_t block_size_in_byte = get_format_block_size_in_bytes(format);
size_t height_in_blocks = (h + block_edge - 1) / block_edge;
size_t width_in_blocks = (w + block_edge - 1) / block_edge;
size_t height_in_blocks = (height + block_edge - 1) / block_edge;
size_t width_in_blocks = (width + block_edge - 1) / block_edge;
size_t result = 0;
for (u16 i = 0; i < mipmap; ++i)
{
size_t rowPitch = align(block_size_in_byte * width_in_blocks, row_pitch_alignment);
result += align(rowPitch * height_in_blocks * d, mipmap_alignment);
result += align(rowPitch * height_in_blocks * depth, mipmap_alignment);
height_in_blocks = std::max<size_t>(height_in_blocks / 2, 1);
width_in_blocks = std::max<size_t>(width_in_blocks / 2, 1);
}

View File

@ -1762,7 +1762,7 @@ namespace rsx
const bool is_compressed_format = (format == CELL_GCM_TEXTURE_COMPRESSED_DXT1 || format == CELL_GCM_TEXTURE_COMPRESSED_DXT23 || format == CELL_GCM_TEXTURE_COMPRESSED_DXT45);
const auto extended_dimension = tex.get_extended_texture_dimension();
u16 depth = 0;
u16 depth;
u16 tex_height = (u16)tex.height();
const u16 tex_width = tex.width();
u16 tex_pitch = is_compressed_format? (u16)(get_texture_size(tex) / tex_height) : tex.pitch(); //NOTE: Compressed textures dont have a real pitch (tex_size = (w*h)/6)

View File

@ -563,9 +563,7 @@ 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 bool is_cubemap = type == rsx::texture_dimension_extended::texture_dimension_cubemap;
size_t texture_data_sz = get_placed_texture_storage_size(width, height, depth, gcm_format, mipmaps, is_cubemap, 256, 512);
size_t texture_data_sz = get_placed_texture_storage_size(width, height, depth, gcm_format, mipmaps, type == rsx::texture_dimension_extended::texture_dimension_cubemap, 256, 512);
std::vector<gsl::byte> data_upload_buf(texture_data_sz);
GLenum target;

View File

@ -268,7 +268,7 @@ namespace rsx
u16 fragment_texture::depth() const
{
return registers[NV4097_SET_TEXTURE_CONTROL3 + m_index] >> 20;
return dimension() == rsx::texture_dimension::dimension3d ? (registers[NV4097_SET_TEXTURE_CONTROL3 + m_index] >> 20) : 1;
}
u32 fragment_texture::pitch() const
@ -406,7 +406,7 @@ namespace rsx
u16 vertex_texture::depth() const
{
return registers[NV4097_SET_VERTEX_TEXTURE_CONTROL3 + (m_index * 8)] >> 20;
return dimension() == rsx::texture_dimension::dimension3d ? (registers[NV4097_SET_VERTEX_TEXTURE_CONTROL3 + (m_index * 8)] >> 20) : 1;
}
u32 vertex_texture::pitch() const