Actually good way to get the MS bit
This commit is contained in:
parent
d24079e693
commit
57b5e16e6d
|
@ -21,6 +21,8 @@
|
|||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
#include "OpenGLSupport.h"
|
||||
|
||||
#include "GPU3D_Compute_shaders.h"
|
||||
|
@ -302,7 +304,7 @@ void ComputeRenderer::Reset(GPU& gpu)
|
|||
|
||||
void ComputeRenderer::SetRenderSettings(int scale, bool highResolutionCoordinates)
|
||||
{
|
||||
unsigned char TileScale;
|
||||
u8 TileScale;
|
||||
|
||||
CurGLCompositor.SetScaleFactor(scale);
|
||||
|
||||
|
@ -319,9 +321,12 @@ void ComputeRenderer::SetRenderSettings(int scale, bool highResolutionCoordinate
|
|||
|
||||
//Starting at 4.5x we want to double TileSize every time scale doubles
|
||||
TileScale = 2 * ScaleFactor / 9;
|
||||
TileScale &= ~(TileScale >> 1);
|
||||
TileScale = GetMSBit(TileScale);
|
||||
TileScale <<= 1;
|
||||
TileScale += TileScale == 0;
|
||||
|
||||
std::printf("Scale: %d\n", ScaleFactor);
|
||||
std::printf("TileScale: %d\n", TileScale);
|
||||
|
||||
TileSize = std::min(8 * TileScale, 32);
|
||||
CoarseTileCountY = TileSize < 32 ? 4 : 6;
|
||||
|
|
14
src/Utils.h
14
src/Utils.h
|
@ -38,6 +38,20 @@ std::pair<std::unique_ptr<u8[]>, u32> PadToPowerOf2(const u8* data, u32 len) noe
|
|||
|
||||
std::unique_ptr<u8[]> CopyToUnique(const u8* data, u32 len) noexcept;
|
||||
|
||||
template <typename T>
|
||||
T GetMSBit(T val)
|
||||
{
|
||||
val |= (val >> 1);
|
||||
val |= (val >> 2);
|
||||
val |= (val >> 4);
|
||||
|
||||
if constexpr(sizeof(val) > 1) val |= (val >> 8);
|
||||
if constexpr(sizeof(val) > 2) val |= (val >> 16);
|
||||
if constexpr(sizeof(val) > 4) val |= (val >> 32);
|
||||
|
||||
return val - (val >> 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // MELONDS_UTILS_H
|
||||
|
|
Loading…
Reference in New Issue