Advertisement

Unable to load a texture in D3D12 compute pipeline

Started by September 01, 2024 11:08 AM
7 comments, last by isu diss 3 months, 1 week ago

I'm trying to render some clouds using compute shader. Somehow it doesn't load the resource, no debugging indicates any errors as well. here's my weather texture loading mechanism.

void SkyClouds::CreateWeatherTexture()
{
	ComPtr<ID3D12Resource> texture = nullptr;
	ResourceUploadBatch resourceUpload(md3dDevice.Get());
	resourceUpload.Begin(D3D12_COMMAND_LIST_TYPE_COMPUTE);
	ThrowIfFailed(CreateWICTextureFromFile(md3dDevice.Get(), resourceUpload, L"Resources\\Clouds\\WeatherTexture.png", texture.GetAddressOf(), true));

resourceUpload.Transition(texture.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
	auto uploadResourcesFinished = resourceUpload.End(mCommandQueue.Get());

	uploadResourcesFinished.wait();

	D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
	srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
	srvDesc.Format = texture->GetDesc().Format;
	srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
	srvDesc.Texture2D.MipLevels = 1;

	CD3DX12_CPU_DESCRIPTOR_HANDLE srvHandle(mSrvWeatherHeap->GetCPUDescriptorHandleForHeapStart());
	md3dDevice->CreateShaderResourceView(texture.Get(), &srvDesc, srvHandle);
}

Can anyone spot the problem even chatgpt says it seems to be correct? all commandlist, commandqueue are in compute pipeline

I've got a similar problem!!!

Its giving me the debug error that I have corrupted parameter 3 or NULL resource, on the shader resource view that is the texture2d im sending to the compute shader with CSSetShaderResources.

Make sure u have debug mode turned on so you can get the debug messages in the program output.

So I don't know the problem sorry, I ended up leaving it without solving it, but I cant read texture2d's in a compute shader either at the moment. complete mystery. It just gives me a 0 result for the read in the compute shader, it actually doesnt set, the texture2d creates, but it doesnt set the shader resource.

Advertisement

Thanks for commenting my post. I have enabled the debug layer. it doesn't output anything suspicious yet resource created wicloader is not nullptr. somehow it doesn't get binded . PIX confirmed it. I didn't have this problem on D3D11 only on D3D12 Compute pipeline. I'm using Win10 on RX6700XT GPU

shouldn't srvDesc… ignore. Try with regular upload buffer (without using ResourceUploadBatch. It doesn't require any waiting.

Since I couldn't find a solution, I generate the weather texture on the fly. Thanks

This is pretty bad, none of us can even load a texture into a compute shader! 🙂 shows how good we are at it.

Advertisement

I KNOW WHY IT IS!!

are u sure your d3d device is the same device as the direct compute device?

You cant read a texture crossing devices!!

yes im using the same 12 device to 12device 5 for RT

This topic is closed to new replies.

Advertisement