mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 13:20:54 +00:00
Encode function instructions
This commit is contained in:
@@ -236,18 +236,36 @@ void FreeAlignedBuffer(byte *buf)
|
||||
|
||||
uint32_t Log2Floor(uint32_t value)
|
||||
{
|
||||
RDCASSERT(value > 0);
|
||||
if(!value)
|
||||
return ~0U;
|
||||
return 31 - Bits::CountLeadingZeroes(value);
|
||||
}
|
||||
|
||||
#if ENABLED(RDOC_X64)
|
||||
uint64_t Log2Floor(uint64_t value)
|
||||
{
|
||||
RDCASSERT(value > 0);
|
||||
if(!value)
|
||||
return ~0ULL;
|
||||
return 63 - Bits::CountLeadingZeroes(value);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t Log2Ceil(uint32_t value)
|
||||
{
|
||||
if(!value)
|
||||
return ~0U;
|
||||
return 32 - Bits::CountLeadingZeroes(value - 1);
|
||||
}
|
||||
|
||||
#if ENABLED(RDOC_X64)
|
||||
uint64_t Log2Ceil(uint64_t value)
|
||||
{
|
||||
if(!value)
|
||||
return ~0ULL;
|
||||
return 64 - Bits::CountLeadingZeroes(value - 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
// deliberately leak so it doesn't get destroyed before our static RenderDoc destructor needs it
|
||||
static rdcstr *logfile = new rdcstr;
|
||||
static FileIO::LogFileHandle *logfileHandle = NULL;
|
||||
|
||||
@@ -293,8 +293,10 @@ byte *AllocAlignedBuffer(uint64_t size, uint64_t alignment = 64);
|
||||
void FreeAlignedBuffer(byte *buf);
|
||||
|
||||
uint32_t Log2Floor(uint32_t value);
|
||||
uint32_t Log2Ceil(uint32_t value);
|
||||
#if ENABLED(RDOC_X64)
|
||||
uint64_t Log2Floor(uint64_t value);
|
||||
uint64_t Log2Ceil(uint64_t value);
|
||||
#endif
|
||||
|
||||
// super ugly - on apple size_t is a separate type, so we need a new overload
|
||||
@@ -307,6 +309,24 @@ inline size_t Log2Floor(size_t value)
|
||||
return (size_t)Log2Floor((uint32_t)value);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline size_t Log2Ceil(size_t value)
|
||||
{
|
||||
#if ENABLED(RDOC_X64)
|
||||
return (size_t)Log2Ceil((uint64_t)value);
|
||||
#else
|
||||
return (size_t)Log2Ceil((uint32_t)value);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline size_t Log2(size_t value)
|
||||
{
|
||||
#if ENABLED(RDOC_X64)
|
||||
return (size_t)Log2((uint64_t)value);
|
||||
#else
|
||||
return (size_t)Log2((uint32_t)value);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user