Fix a bug in Graphics Allocations constructors.

- There was a wrong cast in Graphics Allocation constructor resulting
in wrong GPU address generation in some sporadic scenarios.
- Problem appears in 32 bit applications where void* address is cast to
uint64_t value, if c style cast is used it makes trailing bit to be
populated to higher bits constructing wrong value

0xf000000 is being casted to 0xfffffffff0000000 while it should be casted to
0x00000000f0000000
- added special cast function for further use.

Change-Id: I56d53a8e13e17cbacd127566442eea3f6a089977
This commit is contained in:
Mrozek, Michal
2018-04-19 09:42:00 +02:00
parent d900bdffc6
commit 5bae27ae51
4 changed files with 34 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -51,3 +51,11 @@ TEST(PtrMath, addrToPtr) {
EXPECT_EQ(ptr32BitAddr, addrToPtr(addr32Bit));
EXPECT_EQ(ptr64BitAddr, addrToPtr(addr64Bit));
}
TEST(PtrMath, givenCastToUint64FunctionWhenItIsCalledThenProperValueIsReturned) {
uintptr_t address = 0xf0000000;
void *addressWithTrailingBitSet = reinterpret_cast<void *>(address);
uint64_t expectedUint64Address = 0xf0000000;
auto uintAddress = castToUint64(addressWithTrailingBitSet);
EXPECT_EQ(uintAddress, expectedUint64Address);
}