d3dcoder / d3d12book

Sample code for the book "Introduction to 3D Game Programming with DirectX 12"
1.47k stars 571 forks source link

InstancingAndCulling sample crashes when a large number of skulls become visible in the camera frustum #8

Closed discosultan closed 7 years ago

discosultan commented 7 years ago

The sample crashes usually when around ~25 skulls become visible in the camera frustum.

D3D12 debug layer doesn't provide anything useful except for

D3D12 ERROR: ID3D12Device::RemoveDevice: Device removal has been triggered for the following reason (DXGI_ERROR_DEVICE_HUNG: The Device took an unreasonable amount of time to execute its commands, or the hardware crashed/hung. As a result, the TDR (Timeout Detection and Recovery) mechanism has been triggered. The current Device Context was executing commands when the hang occurred. The application may want to respawn and fallback to less aggressive use of the display hardware). [ EXECUTION ERROR #232: DEVICE_REMOVAL_PROCESS_AT_FAULT]

nameless323 commented 7 years ago

In InstancingAndCulilngApp.cpp, string 816 autor pass render items count, not the instance count and it cause to device removal. Should be for (int i = 0; i < FrameResource::NumFrameResources; i++) { _frameResources.push_back(std::make_unique<FrameResource>(_device.Get(), 1, _numInstances, (UINT)_materials.size())); } or something like that

discosultan commented 7 years ago

Fixed by e0cbac0a01173aac6d79df137e309f5b617fdcaa