[D3D11] Compute shader Problem RWTexture3D

Started by
0 comments, last by Alundra 10 years, 4 months ago

Hi all,

I have Texture3D initialized using R32G32_UINT data, SRV and UAV is created as well.

Here the code I use :


RWTexture3D<uint2> TestTexture3D: register(u0);

[numthreads(16, 16, 1)]
void main(uint3 dispatchThreadID : SV_DispatchThreadID)
{
  TestTexture3D[dispatchThreadID] = uint2(0, 0);
}

const UInt32 ThreadGroupCountX = CMath::Ceil( static_cast< float >( m_Width ) / 16.0f );
const UInt32 ThreadGroupCountY = CMath::Ceil( static_cast< float >( m_Height ) / 16.0f );
CDirect3D11Device::GetDeviceContext()->Dispatch( ThreadGroupCountX, ThreadGroupCountY, 256);

"TestTexture3D[dispatchThreadID] = uint2(0, 0);" is changed to 0 or 1 to see the change on output texture.

But the problem is I have value set on the bad coord.The result is like one rectangle of one color and after one rectangle of other.

Is it because of the texture is uint2 format and the GPU align data to uint4 ?

What is the best solution to avoid this problem ?

Thanks for the help

Advertisement

Solved using this texture desc :


D3D11_TEXTURE3D_DESC TextureDesc =
{
  m_GridWidth,
  m_GridHeight,
  256,
  1,
  DXGI_FORMAT_R32G32_UINT,
  D3D11_USAGE_DEFAULT,
  D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS,
  0,
  0
};
Apparently if the texture is D3D11_USAGE_DYNAMIC and D3D11_CPU_ACCESS_WRITE, that doesn't work.

This topic is closed to new replies.

Advertisement