diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 83d8fff1ce..b0e799ca0c 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -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(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(height_in_blocks / 2, 1); width_in_blocks = std::max(width_in_blocks / 2, 1); } diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 3fff718291..1fa239950f 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -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) diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index 809ae621a6..f147831f84 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -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& 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 data_upload_buf(texture_data_sz); GLenum target; diff --git a/rpcs3/Emu/RSX/RSXTexture.cpp b/rpcs3/Emu/RSX/RSXTexture.cpp index 8311ce8187..ca039dc9f2 100644 --- a/rpcs3/Emu/RSX/RSXTexture.cpp +++ b/rpcs3/Emu/RSX/RSXTexture.cpp @@ -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