mirror of
https://github.com/g-truc/glm.git
synced 2024-11-22 08:54:35 +00:00
Fixed bitfieldInsert and bitfieldExtract
This commit is contained in:
parent
debe75a6e1
commit
062ee19ac7
@ -44,7 +44,7 @@ namespace detail
|
||||
{
|
||||
GLM_FUNC_QUALIFIER int mask(int Bits)
|
||||
{
|
||||
return ~((~0) << Bits);
|
||||
return Bits >= 32 ? 0xffffffff : (static_cast<int>(1) << Bits) - static_cast<int>(1);
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
|
@ -866,7 +866,7 @@ namespace sign
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::size_t const Count = 1000000000;
|
||||
std::size_t const Count = 10000000;
|
||||
std::vector<glm::int32> Input, Output;
|
||||
Input.resize(Count);
|
||||
Output.resize(Count);
|
||||
@ -913,7 +913,7 @@ namespace sign
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::size_t const Count = 1000000000;
|
||||
std::size_t const Count = 10000000;
|
||||
std::vector<glm::int32> Input, Output;
|
||||
Input.resize(Count);
|
||||
Output.resize(Count);
|
||||
@ -960,7 +960,7 @@ namespace sign
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::uint32 const Count = 1000000000;
|
||||
glm::uint32 const Count = 10000000;
|
||||
|
||||
std::clock_t Timestamp0 = std::clock();
|
||||
glm::int32 Sum = 0;
|
||||
|
@ -37,11 +37,12 @@ namespace bitfieldInsert
|
||||
|
||||
typeU32 const Data32[] =
|
||||
{
|
||||
{0x00000000, 0xffffffff, 0, 31, 0x7fffffff},
|
||||
{0x00000000, 0xffffffff, 0, 32, 0xffffffff},
|
||||
{0x00000000, 0xffffffff, 0, 0, 0x00000000},
|
||||
{0xff000000, 0x0000ff00, 8, 8, 0xff00ff00},
|
||||
{0xffff0000, 0x0000ffff, 16, 16, 0x00000000},
|
||||
{0x0000ffff, 0xffff0000, 16, 16, 0xffffffff},
|
||||
{0x00000000, 0xffffffff, 0, 32, 0xffffffff},
|
||||
{0x00000000, 0xffffffff, 0, 0, 0x00000000}
|
||||
{0x0000ffff, 0xffff0000, 16, 16, 0xffffffff}
|
||||
};
|
||||
|
||||
int test()
|
||||
@ -342,7 +343,7 @@ namespace findMSB
|
||||
|
||||
std::clock_t Timestamps1 = std::clock();
|
||||
|
||||
for(std::size_t k = 0; k < 10000000; ++k)
|
||||
for(std::size_t k = 0; k < 1000000; ++k)
|
||||
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
|
||||
{
|
||||
int Result = findMSB_095(Data[i].Value);
|
||||
@ -401,7 +402,7 @@ namespace findMSB
|
||||
|
||||
std::clock_t Timestamps1 = std::clock();
|
||||
|
||||
for(std::size_t k = 0; k < 10000000; ++k)
|
||||
for(std::size_t k = 0; k < 1000000; ++k)
|
||||
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
|
||||
{
|
||||
int Result = findMSB_nlz1(Data[i].Value);
|
||||
@ -536,7 +537,7 @@ namespace findMSB
|
||||
int Error(0);
|
||||
|
||||
Error += perf_950();
|
||||
Error += perf_ops();
|
||||
//Error += perf_ops();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
@ -103,10 +103,12 @@ namespace mask
|
||||
{
|
||||
type<glm::uint> const Data[] =
|
||||
{
|
||||
{0, 0x00000000},
|
||||
{1, 0x00000001},
|
||||
{2, 0x00000003},
|
||||
{3, 0x00000007}
|
||||
{ 0, 0x00000000},
|
||||
{ 1, 0x00000001},
|
||||
{ 2, 0x00000003},
|
||||
{ 3, 0x00000007},
|
||||
{31, 0x7fffffff},
|
||||
{32, 0xffffffff}
|
||||
};
|
||||
|
||||
int Error(0);
|
||||
@ -142,10 +144,12 @@ namespace mask
|
||||
{
|
||||
type<glm::ivec4> const Data[] =
|
||||
{
|
||||
{glm::ivec4(0), glm::ivec4(0x00000000)},
|
||||
{glm::ivec4(1), glm::ivec4(0x00000001)},
|
||||
{glm::ivec4(2), glm::ivec4(0x00000003)},
|
||||
{glm::ivec4(3), glm::ivec4(0x00000007)}
|
||||
{glm::ivec4( 0), glm::ivec4(0x00000000)},
|
||||
{glm::ivec4( 1), glm::ivec4(0x00000001)},
|
||||
{glm::ivec4( 2), glm::ivec4(0x00000003)},
|
||||
{glm::ivec4( 3), glm::ivec4(0x00000007)},
|
||||
{glm::ivec4(31), glm::ivec4(0x7fffffff)},
|
||||
{glm::ivec4(32), glm::ivec4(0xffffffff)}
|
||||
};
|
||||
|
||||
int Error(0);
|
||||
|
Loading…
Reference in New Issue
Block a user