MCPcopy Create free account
hub / github.com/TheRealMJP/Shadows / ReadFromFile

Method ReadFromFile

Shadows/SampleFramework11/GraphicsTypes.cpp:498–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496}
497
498void StructuredBuffer::ReadFromFile(const wchar* path, ID3D11Device* device)
499{
500 // Open the file
501 HANDLE fileHandle = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
502 if(fileHandle == INVALID_HANDLE_VALUE)
503 Win32Call(false);
504
505 // Read the buffer info
506 bool32 useAsUAV, hiddenCounter, appendConsume;
507 DWORD bytesRead = 0;
508 Win32Call(ReadFile(fileHandle, &Size, 4, &bytesRead, nullptr));
509 Win32Call(ReadFile(fileHandle, &Stride, 4, &bytesRead, nullptr));
510 Win32Call(ReadFile(fileHandle, &NumElements, 4, &bytesRead, nullptr));
511 Win32Call(ReadFile(fileHandle, &useAsUAV, 4, &bytesRead, nullptr));
512 Win32Call(ReadFile(fileHandle, &hiddenCounter, 4, &bytesRead, nullptr));
513 Win32Call(ReadFile(fileHandle, &appendConsume, 4, &bytesRead, nullptr));
514
515 // Read the buffer data
516 UINT8* bufferData = new UINT8[Size];
517 Win32Call(ReadFile(fileHandle, bufferData, Size, &bytesRead, nullptr));
518
519 // Close the file
520 Win32Call(CloseHandle(fileHandle));
521
522 // Init
523 Initialize(device, Stride, NumElements, useAsUAV, appendConsume, hiddenCounter, bufferData);
524
525 // Clean up
526 delete [] bufferData;
527}
528
529// == StagingBuffer ===============================================================================
530

Callers

nothing calls this directly

Calls 2

Win32CallFunction · 0.85
InitializeFunction · 0.85

Tested by

no test coverage detected