rate up
1
rate down
Application hung up on "WaitForSingleObject"
main.cpp: .[https://gist.github.com/TarcoGames/b3dce026c505e04c944916de60bf2af2][Gist] stdafx.h: .[https://gist.github.com/TarcoGames/d873de112ba7080716abc81df6a7f6f2][Gist] It keeps getting hung up on WaitForSingleObject in WaitForPreviousFrame.
Comments
It is easier for me to use gists.
on Jan 15 `18
Caseofgames
Did you debug it and check what's in fenceEvent?? many errors and fails are because of not valid data
on Jan 16 `18
maxiorek82
Caseofgames, which line is calling WaitForPreviousFrame which is causing the block? it's possible like maxiorek82 said that your waiting on the wrong fence value
on Jan 16 `18
iedoc
Chosen Answer
rate up
0
rate down
In your main function, you call "WaitForPreviousFrame" before you enter your main loop. the first thing you do in your main loop is you call "WaitForPreviousFrame", so you are calling this function twice. the second call to it is blocking because you did not command the queue to signal that second fence value int WINAPI WinMain(HINSTANCE hInstance, //Main windows function HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { // create the window if (!InitializeWindow(hInstance, nShowCmd, Width, Height, FullScreen)) { MessageBox(0, L"Window Initialization - Failed", L"Error", MB_OK); return 0; } if (!InitD3D()) { throw std::exception(); } WaitForPreviousFrame(); // start the main loop mainloop(); CloseHandle(fenceEvent); CleanUp(); return 0; } I know you are following my tutorials, so your mistake is that you placed the call to "mainloop()" below the "WaitForPreviousFrame()" call, you should switch the order of these two function calls
rate up
0
rate down
I did that and now I am getting another error. on line 213 of the gist, I an getting an exception.
Comments
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = rtvDescHeap->GetCPUDescriptorHandleForHeapStart(); this is your problem. Debug and check your rtvDescHeap definition if is correctly allocated and to be honest, I think you miss there something
on Jan 17 `18
maxiorek82
rate up
0
rate down
ok, I think I got it :) first the headers :) #include <windows.h> #include <VersionHelpers.h> #include <d2d1_3.h> #include <d3d12.h> #include <dxgi1_4.h> #include <D3Dcompiler.h> #include <DirectXMath.h> #include "d3dx12.h" next step what was wrong was in swap chain DXGI_SWAP_CHAIN_DESC scDesc; scDesc.BufferCount = FBC; scDesc.BufferDesc.Width = Width; scDesc.BufferDesc.Height = Height; scDesc.BufferDesc.RefreshRate.Numerator = 0; scDesc.BufferDesc.RefreshRate.Denominator = 1; scDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; scDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; scDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; scDesc.OutputWindow = hwnd; scDesc.SampleDesc.Count = 1; scDesc.SampleDesc.Quality = 0; scDesc.Windowed = !FullScreen; scDesc.Flags = 0; note that RefreshRate if here static but you can determinate it depending on you GPU third modification will be in UpdatePipeline CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(rtvDescHeap->GetCPUDescriptorHandleForHeapStart(), frameIndex, rtvDescSize); //rtvHandle.ptr += rtvDescHeap->GetCPUDescriptorHandleForHeapStart().ptr + frameIndex * rtvDescSize; this was the line which caused the program hangs and the last modification is in WaitForPreviousFrame at the start of the function const UINT64 currentFenceValue = fenceValue[frameIndex]; ThrowIfFailed(cmdQueue->Signal(fence[frameIndex], currentFenceValue)); all of this cause the window will apear in color you like :) of course remember one more thing, float is not an integer ;) so const float clearColor[] = { 0.0f, 0.2f, 0.4f, 1.0f }; is not const float clearColor[] = { 0, 0.2f, 0.4f, 1 }; there is only a error on exiting but I leave it to you :) hope it helps
Sign in to answer!