Sign in to follow this  

Declare 2d array (800x640) in XNA

Recommended Posts

6 images 800x640 need to be rendered from a point of view, and based on these images one new image 800x640, a sort of fish-eye view, should be created.
At the moment the application draw each image and read the colors by calling this RenderTarget2D.GetData<Color> method and based on each pixel position it calculates new position for that final image. It works fine.
but since calling RenderTarget2D.GetData reduces the performance I tried to declare a 800x640 array in shader and then render 6 images consecutively. Then in pixel shader find the new coordinate of the new fish-eye view image.
    float4 PSTooBasic(VertexPSInput pin) : COLOR
        int xCoord = GetWaldXCoordinate(pin.PositionWS.x); 
        int yCoord = GetWaldYCoordinate(pin.PositionWS.y);
        WaldPixs[xCoord][yCoord] = 1; 
        return BlackColor;
But this array declaration line:
uniform int WaldPixs[800][640];
gives this compile error: error X3059: 'WaldPixs': array dimension must be between 1 and 65536
Any suggestion or workaround?

Share this post

Link to post
Share on other sites

I don't think this works with XNA, but with DirectX you could use constant buffers. Actually, if you use cbuffer you will find that it has similar limits on size. A tbuffer is something you might wish to look into .It should be able to handle up to 128 MiB.


But maybe you should try to render to some render targets. Draw to some render targets and use a full screen quad that samples those targets to compute what you need. The you can use the result in another full screen quad if needed. Or 800x640 in your case, not fullscreen.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this