diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 614d61db45..0932fadc2d 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -4,6 +4,7 @@ #include #include #include "common/assert.h" +#include "common/bit_util.h" #include "common/scope_exit.h" #include "common/settings.h" #include "core/core.h" @@ -259,12 +260,13 @@ u32 Maxwell3D::GetMaxCurrentVertices() { size_t Maxwell3D::EstimateIndexBufferSize() { GPUVAddr start_address = regs.index_buffer.StartAddress(); GPUVAddr end_address = regs.index_buffer.EndAddress(); - static constexpr std::array max_sizes = { - std::numeric_limits::max(), std::numeric_limits::max(), - std::numeric_limits::max(), std::numeric_limits::max()}; + static constexpr std::array max_sizes = {std::numeric_limits::max(), + std::numeric_limits::max(), + std::numeric_limits::max()}; const size_t byte_size = regs.index_buffer.FormatSizeInBytes(); + const size_t log2_byte_size = Common::Log2Ceil64(byte_size); return std::min( - memory_manager.GetMemoryLayoutSize(start_address, byte_size * max_sizes[byte_size]) / + memory_manager.GetMemoryLayoutSize(start_address, byte_size * max_sizes[log2_byte_size]) / byte_size, static_cast(end_address - start_address)); }