Currently attempting to dive into compute shaders and trying to google some of this stuff is kicking my butt.
Pretty sure I’ve got the basics down but I hit a roadblock attempting to write to the mipmaps for a RWTexture2DArray I created. My current relevant code excerpts:
RWTexture2DArray<float4> outputTexture : register(u0);
...
[numthreads(32, 32, 1)]
void Convolve(uint3 ThreadID : SV_DispatchThreadID)
{
...
outputTexture[ThreadID] = float4(1.0, 1.0, 1.0, 1.0);
}
It only seems to be able to write to mip 0 and outputTexture doesn’t accept a float4 to specify a mip level.
I feel like this has to be a thing (this page certainly would seem to imply such a thing is possible: Subresources (Direct3D 12 Graphics) - Win32 apps | Microsoft Learn) but I’m not exactly sure what to do with that information, especially in the context of Unity.
From what I gather, the subresource exists and I could sample it with a sampler, but how do I go about writing to it? Is there some Unity-specific thing I’m missing here? Unity’s compute shader documentation is, uh… lacking, to put it nicely.
For some background context: the whole reason I’m using RWTexture2DArray explicitly is that there appears to be no way to write to a TextureCube so I’m doing the compute logic in a 6-deep RWTexture2DArray instead, then copying back to a cubemap RenderTexture afterwards. If there’s a better way to do that, I’m all ears.