a problem with an unordered access view buffer.

Started by
1 comment, last by pnt1614 8 years, 9 months ago

I want to render to the motion blur effect by making a prism which is rasterized to fragments.

- In the first pass, transfroming vertices with 2 matrices at the previous ( time t0) and the current frame (time t1) in the vertex shader. In the geometry shader, using 2 triangles to make a prism representing a moving triangle, and a side rectangle is subdivied into 2 triangles for rasterization. In the pixel shader, I just store all fragments into a read/write structured buffer.

- Fragment has 6 values, a float4 and an uint2.

- In the second pass, I just load all fragments which belongs to the current pixel, and return a color (ex: green).

- An error occurs when the camera go inside or near an model. But it is okay when the object is far away.

normal

image.jpg

Error (go inside a teapot)

loi.jpg

Is there anybody has experienced this problem? Please help me.

Advertisement

The error still occurs even a fragment has a single float2.

This is C++ source code for creating a UAV buffer.


        D3D11_BUFFER_DESC descBuf;
	memset(&descBuf, 0, sizeof(descBuf));
	descBuf.StructureByteStride = sizeof(FragmentLink);
	descBuf.ByteWidth = mFrameWidth * mFrameHeight * mNumOfElements * descBuf.StructureByteStride;
	descBuf.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
	descBuf.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE;
	descBuf.Usage = D3D11_USAGE_DEFAULT;
	descBuf.CPUAccessFlags = 0;

	
	hr = md3dDevice->CreateBuffer(&descBuf, NULL, &m_pFragmentLink);
	SetDebugName(m_pFragmentLink, "Fragment Link Buffer");

	// create UAV
	D3D11_UNORDERED_ACCESS_VIEW_DESC descUAV;
	memset(&descUAV, 0, sizeof(descUAV));
	descUAV.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
	descUAV.Format = DXGI_FORMAT_UNKNOWN;
	descUAV.Buffer.FirstElement = 0;
	descUAV.Buffer.NumElements = mFrameWidth * mFrameHeight * mNumOfElements;
	descUAV.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_COUNTER;
	//V_RETURN(md3dDevice->CreateUnorderedAccessView(m_pFragmentLink, &descUAV, &m_pFragmentLinkUAV));
	hr = md3dDevice->CreateUnorderedAccessView(m_pFragmentLink, &descUAV, &m_pFragmentLinkUAV);
	SetDebugName(m_pFragmentLinkUAV, "FragmentLinkUAV");

I have thought about the overflow problem, and the error disappear when I increase the maximum number of fragments (mNumOfElements) from 20 to 50. However, when I use add more values into a fragment ( a float4 instead of a float2), then the error occurs again. I am considering about the memory access but I do not know how to use multipasses for debugging.

This topic is closed to new replies.

Advertisement