Search code examples
c++directxhlsl

How can I define an array with a large dimension in HLSL?


Is there a way to define a large array in HLSL or any alternative to this as I'm trying to move some of my calculations to the GPU.

I currently have

struct Buffer
{
    float3 image[640 * 480];   
};

but I am getting the error

error X3059: array dimension must be between 1 and 65536

It would be great if I didn't have to split this up and then merge them together back on the CPU.

Is there a way around this?

Update

As mentioned in the comments, it would make more sense to store this data as a texture, as the array I'm trying to create stores pixel data. I have tried to define my Texture2D in the HLSL file, but I can't seem to edit the data, or write to the texture file.

Does anyone know how to do this?


Solution

  • I couldn't find a solution to this but as I am manipulating image data, using RWTexture2D<float4> and providing read write access seems to work fine for what I want to achieve.