Moving to D3DDDI_ALLOCATIONINFO v2
Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
parent
6a43b6b609
commit
75e427f2e8
|
@ -798,11 +798,11 @@ TEST_F(Wddm20Tests, givenOpenSharedHandleWhenZeroAllocationsThenReturnNull) {
|
|||
|
||||
TEST_F(Wddm20Tests, whenCreateAllocation64kFailsThenReturnFalse) {
|
||||
struct FailingCreateAllocation {
|
||||
static NTSTATUS APIENTRY mockCreateAllocation(D3DKMT_CREATEALLOCATION *param) {
|
||||
static NTSTATUS APIENTRY mockCreateAllocation2(D3DKMT_CREATEALLOCATION *param) {
|
||||
return STATUS_GRAPHICS_NO_VIDEO_MEMORY;
|
||||
};
|
||||
};
|
||||
gdi->createAllocation = FailingCreateAllocation::mockCreateAllocation;
|
||||
gdi->createAllocation2 = FailingCreateAllocation::mockCreateAllocation2;
|
||||
|
||||
void *fakePtr = reinterpret_cast<void *>(0x123);
|
||||
auto gmm = std::make_unique<Gmm>(rootDeviceEnvironemnt->getGmmClientContext(), fakePtr, 100, 0, false);
|
||||
|
@ -815,11 +815,11 @@ TEST_F(Wddm20Tests, whenCreateAllocation64kFailsThenReturnFalse) {
|
|||
TEST_F(Wddm20Tests, givenReadOnlyMemoryWhenCreateAllocationFailsWithNoVideoMemoryThenCorrectStatusIsReturned) {
|
||||
class MockCreateAllocation {
|
||||
public:
|
||||
static NTSTATUS APIENTRY mockCreateAllocation(D3DKMT_CREATEALLOCATION *param) {
|
||||
static NTSTATUS APIENTRY mockCreateAllocation2(D3DKMT_CREATEALLOCATION *param) {
|
||||
return STATUS_GRAPHICS_NO_VIDEO_MEMORY;
|
||||
};
|
||||
};
|
||||
gdi->createAllocation = MockCreateAllocation::mockCreateAllocation;
|
||||
gdi->createAllocation2 = MockCreateAllocation::mockCreateAllocation2;
|
||||
|
||||
OsHandleStorage handleStorage;
|
||||
OsHandleWin handle;
|
||||
|
@ -1260,7 +1260,7 @@ TEST_F(Wddm20WithMockGdiDllTests, whenSetDeviceInfoSucceedsThenDeviceCallbacksAr
|
|||
expectedDeviceCb.PagingQueue = wddm->getPagingQueue();
|
||||
expectedDeviceCb.PagingFence = wddm->getPagingQueueSyncObject();
|
||||
|
||||
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnAllocate = gdi->createAllocation;
|
||||
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnAllocate = gdi->createAllocation_;
|
||||
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnDeallocate = gdi->destroyAllocation;
|
||||
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnMapGPUVA = gdi->mapGpuVirtualAddress;
|
||||
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnMakeResident = gdi->makeResident;
|
||||
|
|
|
@ -39,7 +39,8 @@ bool Gdi::setupHwQueueProcAddresses() {
|
|||
bool Gdi::getAllProcAddresses() {
|
||||
openAdapterFromHdc = reinterpret_cast<PFND3DKMT_OPENADAPTERFROMHDC>(gdiDll.getProcAddress("D3DKMTOpenAdapterFromHdc"));
|
||||
openAdapterFromLuid = reinterpret_cast<PFND3DKMT_OPENADAPTERFROMLUID>(gdiDll.getProcAddress("D3DKMTOpenAdapterFromLuid"));
|
||||
createAllocation = reinterpret_cast<PFND3DKMT_CREATEALLOCATION>(gdiDll.getProcAddress("D3DKMTCreateAllocation"));
|
||||
createAllocation_ = reinterpret_cast<PFND3DKMT_CREATEALLOCATION>(gdiDll.getProcAddress("D3DKMTCreateAllocation"));
|
||||
createAllocation2 = reinterpret_cast<PFND3DKMT_CREATEALLOCATION>(gdiDll.getProcAddress("D3DKMTCreateAllocation2"));
|
||||
destroyAllocation = reinterpret_cast<PFND3DKMT_DESTROYALLOCATION>(gdiDll.getProcAddress("D3DKMTDestroyAllocation"));
|
||||
destroyAllocation2 = reinterpret_cast<PFND3DKMT_DESTROYALLOCATION2>(gdiDll.getProcAddress("D3DKMTDestroyAllocation2"));
|
||||
queryAdapterInfo = reinterpret_cast<PFND3DKMT_QUERYADAPTERINFO>(gdiDll.getProcAddress("D3DKMTQueryAdapterInfo"));
|
||||
|
@ -84,7 +85,7 @@ bool Gdi::getAllProcAddresses() {
|
|||
getDeviceState = reinterpret_cast<PFND3DKMT_GETDEVICESTATE>(gdiDll.getProcAddress("D3DKMTGetDeviceState"));
|
||||
|
||||
// clang-format off
|
||||
if (openAdapterFromHdc && openAdapterFromLuid && createAllocation && destroyAllocation
|
||||
if (openAdapterFromHdc && openAdapterFromLuid && createAllocation2 && destroyAllocation
|
||||
&& destroyAllocation2 && queryAdapterInfo && closeAdapter && createDevice
|
||||
&& destroyDevice && escape && createContext && destroyContext
|
||||
&& openResource && queryResourceInfo && lock && unlock && render
|
||||
|
|
|
@ -25,7 +25,8 @@ class Gdi {
|
|||
|
||||
ThkWrapper<IN OUT D3DKMT_OPENADAPTERFROMHDC *> openAdapterFromHdc{};
|
||||
ThkWrapper<IN OUT D3DKMT_OPENADAPTERFROMLUID *> openAdapterFromLuid{};
|
||||
ThkWrapper<IN OUT D3DKMT_CREATEALLOCATION *> createAllocation{};
|
||||
ThkWrapper<IN OUT D3DKMT_CREATEALLOCATION *> createAllocation_{};
|
||||
ThkWrapper<IN OUT D3DKMT_CREATEALLOCATION *> createAllocation2{};
|
||||
ThkWrapper<IN CONST D3DKMT_DESTROYALLOCATION *> destroyAllocation{};
|
||||
ThkWrapper<IN CONST D3DKMT_DESTROYALLOCATION2 *> destroyAllocation2{};
|
||||
ThkWrapper<IN CONST D3DKMT_QUERYADAPTERINFO *> queryAdapterInfo{};
|
||||
|
|
|
@ -512,7 +512,7 @@ bool Wddm::freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size)
|
|||
|
||||
NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKMT_HANDLE &outHandle, D3DKMT_HANDLE &outResourceHandle, D3DKMT_HANDLE *outSharedHandle) {
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
D3DDDI_ALLOCATIONINFO AllocationInfo = {0};
|
||||
D3DDDI_ALLOCATIONINFO2 AllocationInfo = {0};
|
||||
D3DKMT_CREATEALLOCATION CreateAllocation = {0};
|
||||
|
||||
if (gmm == nullptr)
|
||||
|
@ -534,10 +534,10 @@ NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKM
|
|||
CreateAllocation.Flags.CreateShared = outSharedHandle ? TRUE : FALSE;
|
||||
CreateAllocation.Flags.RestrictSharedAccess = FALSE;
|
||||
CreateAllocation.Flags.CreateResource = outSharedHandle || alignedCpuPtr ? TRUE : FALSE;
|
||||
CreateAllocation.pAllocationInfo = &AllocationInfo;
|
||||
CreateAllocation.pAllocationInfo2 = &AllocationInfo;
|
||||
CreateAllocation.hDevice = device;
|
||||
|
||||
status = getGdi()->createAllocation(&CreateAllocation);
|
||||
status = getGdi()->createAllocation2(&CreateAllocation);
|
||||
if (status != STATUS_SUCCESS) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
return status;
|
||||
|
@ -578,7 +578,7 @@ bool Wddm::setAllocationPriority(const D3DKMT_HANDLE *handles, uint32_t allocati
|
|||
|
||||
bool Wddm::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
D3DDDI_ALLOCATIONINFO AllocationInfo = {0};
|
||||
D3DDDI_ALLOCATIONINFO2 AllocationInfo = {0};
|
||||
D3DKMT_CREATEALLOCATION CreateAllocation = {0};
|
||||
|
||||
AllocationInfo.pSystemMem = 0;
|
||||
|
@ -590,10 +590,10 @@ bool Wddm::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
|
|||
CreateAllocation.pPrivateRuntimeData = NULL;
|
||||
CreateAllocation.pPrivateDriverData = NULL;
|
||||
CreateAllocation.Flags.CreateResource = FALSE;
|
||||
CreateAllocation.pAllocationInfo = &AllocationInfo;
|
||||
CreateAllocation.pAllocationInfo2 = &AllocationInfo;
|
||||
CreateAllocation.hDevice = device;
|
||||
|
||||
status = getGdi()->createAllocation(&CreateAllocation);
|
||||
status = getGdi()->createAllocation2(&CreateAllocation);
|
||||
|
||||
if (status != STATUS_SUCCESS) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
|
@ -608,7 +608,7 @@ bool Wddm::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
|
|||
|
||||
NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
D3DDDI_ALLOCATIONINFO AllocationInfo[maxFragmentsCount] = {{0}};
|
||||
D3DDDI_ALLOCATIONINFO2 AllocationInfo[maxFragmentsCount] = {{0}};
|
||||
D3DKMT_CREATEALLOCATION CreateAllocation = {0};
|
||||
|
||||
auto allocationCount = 0;
|
||||
|
@ -643,11 +643,11 @@ NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
|
|||
CreateAllocation.Flags.CreateShared = FALSE;
|
||||
CreateAllocation.Flags.RestrictSharedAccess = FALSE;
|
||||
CreateAllocation.Flags.CreateResource = FALSE;
|
||||
CreateAllocation.pAllocationInfo = AllocationInfo;
|
||||
CreateAllocation.pAllocationInfo2 = AllocationInfo;
|
||||
CreateAllocation.hDevice = device;
|
||||
|
||||
while (status == STATUS_UNSUCCESSFUL) {
|
||||
status = getGdi()->createAllocation(&CreateAllocation);
|
||||
status = getGdi()->createAllocation2(&CreateAllocation);
|
||||
|
||||
if (status != STATUS_SUCCESS) {
|
||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, __FUNCTION__ "status: %d", status);
|
||||
|
@ -1109,7 +1109,7 @@ bool Wddm::configureDeviceAddressSpace() {
|
|||
deviceCallbacks.PagingQueue = pagingQueue;
|
||||
deviceCallbacks.PagingFence = pagingQueueSyncObject;
|
||||
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnAllocate = getGdi()->createAllocation;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnAllocate = getGdi()->createAllocation_;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnDeallocate = getGdi()->destroyAllocation;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMapGPUVA = getGdi()->mapGpuVirtualAddress;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMakeResident = getGdi()->makeResident;
|
||||
|
|
|
@ -10,6 +10,7 @@ EXPORTS
|
|||
D3DKMTOpenAdapterFromHdc
|
||||
D3DKMTOpenAdapterFromLuid
|
||||
D3DKMTCreateAllocation
|
||||
D3DKMTCreateAllocation2
|
||||
D3DKMTDestroyAllocation
|
||||
D3DKMTDestroyAllocation2
|
||||
D3DKMTQueryAdapterInfo
|
||||
|
|
|
@ -131,7 +131,11 @@ NTSTATUS __stdcall D3DKMTDestroyContext(IN CONST D3DKMT_DESTROYCONTEXT *destroyC
|
|||
static D3DKMT_CREATEALLOCATION pallocation{};
|
||||
|
||||
NTSTATUS __stdcall D3DKMTCreateAllocation(IN OUT D3DKMT_CREATEALLOCATION *allocation) {
|
||||
D3DDDI_ALLOCATIONINFO *allocationInfo;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NTSTATUS __stdcall D3DKMTCreateAllocation2(IN OUT D3DKMT_CREATEALLOCATION *allocation) {
|
||||
D3DDDI_ALLOCATIONINFO2 *allocationInfo;
|
||||
int numOfAllocations;
|
||||
bool createResource;
|
||||
bool globalShare;
|
||||
|
@ -139,7 +143,7 @@ NTSTATUS __stdcall D3DKMTCreateAllocation(IN OUT D3DKMT_CREATEALLOCATION *alloca
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
pallocation = *allocation;
|
||||
allocationInfo = allocation->pAllocationInfo;
|
||||
allocationInfo = allocation->pAllocationInfo2;
|
||||
if (allocationInfo == NULL) {
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue