Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 454829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:18:36+00:00 2026-05-12T22:18:36+00:00

Hello and sorry for the obscure title :} I`ll try to explain the best

  • 0

Hello and sorry for the obscure title :}
I`ll try to explain the best i can.

First of all, i am new to HLSL but i understand about the pipeline and stuff that are from the fairy world. What i`m trying to do is use the gpu for general computations (GPGPU).

What i don`t know is: how can i read* the vertices (that have been transformed using vertex shaders) back to my xna application? I read something about using the texture memory of the gpu but i can’t find anything solid…

Thanks in advance for any info/tip! 🙂

*not sure if possible bacause of the rasterizer and the pixel shader (if any), i mean, in the end it’s all about pixels, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:18:36+00:00Added an answer on May 12, 2026 at 10:18 pm

    As far as I know this isn’t generally possible.

    What exactly are you trying to do? There is probably another solution

    EDIT:: Taking into account the comment. If all you want to do is general vector calculations on the GPU try doing them in the pixel shader rather than the vertex shader.

    So for example, say you want to do cross two vectors, first we need to write the data into a texture

    //Data must be in the 0-1 range before writing into the texture, so you'll need to scale everything appropriately
    Vector4 a = new Vector4(1, 0, 1, 1);
    Vector4 b = new Vector4(0, 1, 0, 0);
    
    Texture2D dataTexture = new Texture2D(device, 2, 1);
    dataTexture.SetData<Vector4>(new Vector4[] { a, b });
    

    So now we’ve got a 2*1 texture with the data in, render the texture simply using spritebatch and an effect:

    Effect gpgpu;
    gpgpu.Begin();
    gpgpu.CurrentTechnique = gpgpu.Techniques["DotProduct"];
    gpgpu.CurrentTechnique.Begin();
    spriteBatch.Begin();
    gpgpu.CurrentTechnique.Passes[0].Begin();
    spriteBatch.Draw(dataTexture, new Rectangle(0,0,2,1), Color.White);
    spriteBatch.end();
    gpgpu.CurrentTechnique.Passes[0].End();
    gpgpu.CurrentTechnique.End();
    

    All we need now is the gpgpu effect I’ve shown above. That’s just a standard post processing shader, looking something like this:

    sampler2D DataSampler = sampler_state
    {
        MinFilter = Point;
        MagFilter = Point;
        MipFilter = Point;
        AddressU = Clamp;
        AddressV = Clamp;
    };
    
    float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0
    {
        float4 A = tex2D(s, texCoord);
        float4 B = tex2D(s, texCoord + float2(0.5, 0); //0.5 is the size of 1 pixel, 1 / textureWidth
        float d = dot(a, b)
        return float4(d, 0, 0, 0);
    }
    
    technique DotProduct
    {
        pass Pass1
        {
            PixelShader = compile ps_3_0 PixelShaderFunction();
        }
    }
    

    This will write out the dot product of A and B into the first pixel, and the dot product of B and B into the second pixel. Then you can read these answers back (ignoring the useless ones)

    Vector4[] v = new Vector4[2];
    dataTexture.GetData(v);
    float dotOfAandB = v[0];
    float dotOfBandB = v[1];
    

    tada!
    There are a whole load of little issues with trying to do this on a larger scale, comment here and I’ll try to help you with any you run into 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
hello there and sorry for the stupid question but i think i might be
Question: Hello All, Sorry that this is kind of a noob question. I just
Hello I'm stuck on a simple Java exercise, I hope someone can help. Sorry
(I am sorry, I wanted to ask this question on meta first, but it
Hello (sorry for the poor title) I have a user control which loads different
Hello I was writing a Regular Expression (first time in my life I might
Hello can anybody solve this please I'm creating the object in the action class
Hello I am compiling a program with make but I get the error of
Hello there and Merry Christmas !!! I am new to WPF and I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.