Flickering geometry

Started by
17 comments, last by Mumsfilibaba 8 years, 6 months ago

It would be good to see your Present call and your SwapChain description too.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Advertisement

Here's the SwapChainDescription:


//setup default SwapChainDescription
RtlSecureZeroMemory(&this->swapChainDescription, sizeof(DXGI_SWAP_CHAIN_DESC));

this->swapChainDescription.BufferCount = 1;
this->swapChainDescription.BufferDesc.Width = 0;
this->swapChainDescription.BufferDesc.Height = 0;
this->swapChainDescription.BufferDesc.RefreshRate.Numerator = 0;
this->swapChainDescription.BufferDesc.RefreshRate.Denominator = 1;
this->swapChainDescription.BufferDesc.Scaling = DXGI_MODE_SCALING::DXGI_MODE_SCALING_UNSPECIFIED;
this->swapChainDescription.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER::DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
this->swapChainDescription.BufferDesc.Format = DXGI_FORMAT::DXGI_FORMAT_R8G8B8A8_UNORM;
this->swapChainDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
this->swapChainDescription.Flags = 0;
this->swapChainDescription.SampleDesc.Count = 1;
this->swapChainDescription.SampleDesc.Quality = 0;
this->swapChainDescription.SwapEffect = DXGI_SWAP_EFFECT::DXGI_SWAP_EFFECT_DISCARD;
this->swapChainDescription.Windowed = true;
this->swapChainDescription.OutputWindow = this->outputWindow;

And here's the present call:


bool GraphicsManager::present()
{
	HRESULT result = 0;

	//present swapchain
	if (this->verticalSync)
	{
		result = this->d3dHandle->getSwapChain()->Present(1, 0);
	}
	else
	{
		result = this->d3dHandle->getSwapChain()->Present(0, 0);
	}

	if (FAILED(result))
	{
		MessageBoxW(0, L"SwapChain presentation failed", L"ERROR", MB_OK | MB_ICONERROR);
		return false;
	}

	return true;
}

this->swapChainDescription.BufferDesc.RefreshRate.Numerator = 0;
this->swapChainDescription.BufferDesc.RefreshRate.Denominator = 1;

Shouldn't Numerator be 60 and Denominator 0 (for 60 Hz example)?

It also seems like you need to set BufferCount to 2 or more:

DXGI_SWAP_EFFECT_DISCARD

Use this flag to specify the bit-block transfer (bitblt) model and to specify that DXGI discard the contents of the back buffer after you call IDXGISwapChain1::Present1. This flag is valid for a swap chain with more than one back buffer, although, applications only have read and write access to buffer 0. Use this flag to enable the display driver to select the most efficient presentation technique for the swap chain.

.:vinterberg:.

Denominator must be at least 1, otherwise there will be a division with zero. Have tested to put 60 as numerator and 1 as denominator, but no change.

Well the buffercount thing is weird. I checked a couple of examples and they have buffercount = 1 and uses that flag. However I don't use a IDXGISwapChain1, I use a IDXGISwapChain. I don't now if that has something to do with it.

I use SwapEffectSequential with BufferCount=1. Maybe you can try that

I tried sequental, No change.

Hmm, I also found this, which may be related to your problem: http://gamedev.stackexchange.com/questions/15651/mapping-a-vertex-buffer-in-directx11

On an unrelated note: I'd premultiply the WorldViewProjection matrix outside of the shader, since it's the same for all vertices in a mesh

Have read that post a coupe of times, but can't find anything that could help me. His problem seems to be becuase he has uninitialized data in his buffer. If I have understood everything correctly I doesn't have any uninitialized data. But I can be wrong.

I really have no idea whats wrong

Ok, so after some "professional" detective work (maybe not professional) I think I've located the problem to the UpdateSubresource call, or maybe the constant buffer itself. My quess is that the matrices doesn't have a value some frames and then the geometry "dissapears" out of frame and I get the flickering.

Hmm, I also found this, which may be related to your problem: http://gamedev.stackexchange.com/questions/15651/mapping-a-vertex-buffer-in-directx11

On an unrelated note: I'd premultiply the WorldViewProjection matrix outside of the shader, since it's the same for all vertices in a mesh

So you problably were right...

EDIT:

Problem solved :D

The problem were that I transposed the projection matrix every frame, when the projection matrix itself weren't updated. So because of the way the transpose changes the matrix, the projectionmatrix were correct one frame, but the next frame it weren't, then it became correct again, and so on and so on.

Stupid me :D

But thanks so much to all of you gave some of your time to help me.

This topic is closed to new replies.

Advertisement