mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-18 10:35:59 +01:00
parent
e6dd8f626a
commit
326dc95f9c
@ -62,6 +62,7 @@ Other changes:
|
|||||||
- Tools: binary_to_compressed_c: added -u8/-u32/-base85 export options.
|
- Tools: binary_to_compressed_c: added -u8/-u32/-base85 export options.
|
||||||
- Demo: example tree used by Property Editor & Selection demos properly freed
|
- Demo: example tree used by Property Editor & Selection demos properly freed
|
||||||
on application closure. (#8158) [@Legulysse]
|
on application closure. (#8158) [@Legulysse]
|
||||||
|
- Misc: use SSE 4.2 crc32 instructions when available. (#8169, #4933) [@Teselka]
|
||||||
- Backends: Vulkan: Make user-provided descriptor pool optional. As a convenience,
|
- Backends: Vulkan: Make user-provided descriptor pool optional. As a convenience,
|
||||||
when setting init_info->DescriptorPoolSize then the backend will create and manage
|
when setting init_info->DescriptorPoolSize then the backend will create and manage
|
||||||
one itself. (#8172, #4867) [@zeux]
|
one itself. (#8172, #4867) [@zeux]
|
||||||
|
18
imgui.cpp
18
imgui.cpp
@ -2150,6 +2150,7 @@ void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef IMGUI_ENABLE_SSE4_2
|
||||||
// CRC32 needs a 1KB lookup table (not cache friendly)
|
// CRC32 needs a 1KB lookup table (not cache friendly)
|
||||||
// Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily:
|
// Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily:
|
||||||
// - avoid an unnecessary branch/memory tap, - keep the ImHashXXX functions usable by static constructors, - make it thread-safe.
|
// - avoid an unnecessary branch/memory tap, - keep the ImHashXXX functions usable by static constructors, - make it thread-safe.
|
||||||
@ -2173,6 +2174,7 @@ static const ImU32 GCrc32LookupTable[256] =
|
|||||||
0xE330A81A,0x115B2B19,0x020BD8ED,0xF0605BEE,0x24AA3F05,0xD6C1BC06,0xC5914FF2,0x37FACCF1,0x69E9F0D5,0x9B8273D6,0x88D28022,0x7AB90321,0xAE7367CA,0x5C18E4C9,0x4F48173D,0xBD23943E,
|
0xE330A81A,0x115B2B19,0x020BD8ED,0xF0605BEE,0x24AA3F05,0xD6C1BC06,0xC5914FF2,0x37FACCF1,0x69E9F0D5,0x9B8273D6,0x88D28022,0x7AB90321,0xAE7367CA,0x5C18E4C9,0x4F48173D,0xBD23943E,
|
||||||
0xF36E6F75,0x0105EC76,0x12551F82,0xE03E9C81,0x34F4F86A,0xC69F7B69,0xD5CF889D,0x27A40B9E,0x79B737BA,0x8BDCB4B9,0x988C474D,0x6AE7C44E,0xBE2DA0A5,0x4C4623A6,0x5F16D052,0xAD7D5351
|
0xF36E6F75,0x0105EC76,0x12551F82,0xE03E9C81,0x34F4F86A,0xC69F7B69,0xD5CF889D,0x27A40B9E,0x79B737BA,0x8BDCB4B9,0x988C474D,0x6AE7C44E,0xBE2DA0A5,0x4C4623A6,0x5F16D052,0xAD7D5351
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Known size hash
|
// Known size hash
|
||||||
// It is ok to call ImHashData on a string with known length but the ### operator won't be supported.
|
// It is ok to call ImHashData on a string with known length but the ### operator won't be supported.
|
||||||
@ -2181,10 +2183,16 @@ ImGuiID ImHashData(const void* data_p, size_t data_size, ImGuiID seed)
|
|||||||
{
|
{
|
||||||
ImU32 crc = ~seed;
|
ImU32 crc = ~seed;
|
||||||
const unsigned char* data = (const unsigned char*)data_p;
|
const unsigned char* data = (const unsigned char*)data_p;
|
||||||
|
#ifndef IMGUI_ENABLE_SSE4_2
|
||||||
const ImU32* crc32_lut = GCrc32LookupTable;
|
const ImU32* crc32_lut = GCrc32LookupTable;
|
||||||
while (data_size-- != 0)
|
while (data_size-- != 0)
|
||||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++];
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++];
|
||||||
return ~crc;
|
return ~crc;
|
||||||
|
#else
|
||||||
|
while (data_size-- != 0)
|
||||||
|
crc = _mm_crc32_u8(crc, *data++);
|
||||||
|
return ~crc;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zero-terminated string hash, with support for ### to reset back to seed value
|
// Zero-terminated string hash, with support for ### to reset back to seed value
|
||||||
@ -2198,7 +2206,9 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed)
|
|||||||
seed = ~seed;
|
seed = ~seed;
|
||||||
ImU32 crc = seed;
|
ImU32 crc = seed;
|
||||||
const unsigned char* data = (const unsigned char*)data_p;
|
const unsigned char* data = (const unsigned char*)data_p;
|
||||||
|
#ifndef IMGUI_ENABLE_SSE4_2
|
||||||
const ImU32* crc32_lut = GCrc32LookupTable;
|
const ImU32* crc32_lut = GCrc32LookupTable;
|
||||||
|
#endif
|
||||||
if (data_size != 0)
|
if (data_size != 0)
|
||||||
{
|
{
|
||||||
while (data_size-- != 0)
|
while (data_size-- != 0)
|
||||||
@ -2206,7 +2216,11 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed)
|
|||||||
unsigned char c = *data++;
|
unsigned char c = *data++;
|
||||||
if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#')
|
if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#')
|
||||||
crc = seed;
|
crc = seed;
|
||||||
|
#ifndef IMGUI_ENABLE_SSE4_2
|
||||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
||||||
|
#else
|
||||||
|
crc = _mm_crc32_u8(crc, c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2215,7 +2229,11 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed)
|
|||||||
{
|
{
|
||||||
if (c == '#' && data[0] == '#' && data[1] == '#')
|
if (c == '#' && data[0] == '#' && data[1] == '#')
|
||||||
crc = seed;
|
crc = seed;
|
||||||
|
#ifndef IMGUI_ENABLE_SSE4_2
|
||||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
||||||
|
#else
|
||||||
|
crc = _mm_crc32_u8(crc, c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ~crc;
|
return ~crc;
|
||||||
|
@ -61,6 +61,10 @@ Index of this file:
|
|||||||
#if (defined __SSE__ || defined __x86_64__ || defined _M_X64 || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1))) && !defined(IMGUI_DISABLE_SSE)
|
#if (defined __SSE__ || defined __x86_64__ || defined _M_X64 || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1))) && !defined(IMGUI_DISABLE_SSE)
|
||||||
#define IMGUI_ENABLE_SSE
|
#define IMGUI_ENABLE_SSE
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
|
#if (defined __AVX__ || defined __SSE4_2__)
|
||||||
|
#define IMGUI_ENABLE_SSE4_2
|
||||||
|
#include <nmmintrin.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Visual Studio warnings
|
// Visual Studio warnings
|
||||||
|
Loading…
Reference in New Issue
Block a user