Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


HLSL question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 lomateron   Members   -  Reputation: 434

Like
0Likes
Like

Posted 14 May 2013 - 02:31 PM

I there any way to do something like this:

 

 

technique10 MyTechnique
{
    float4 t= TextureA.Load(uint3(2,10,0))+TextureB.Load(uint3(1,20,0));
 
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
    }
}
 
so now 't' variable can be used inside VS() PS() functions, it will improve performance

Edited by lomateron, 14 May 2013 - 02:42 PM.


Sponsor:

#2 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3736

Like
0Likes
Like

Posted 14 May 2013 - 02:44 PM

So you are basically loading a single pixel of a texture and then adding another pixel?

 

Then you could just pass a variable to the shader instead, I think?

 

Please correct me If I'm wrong...


FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/cuboidzone.wordpress.com/


#3 lomateron   Members   -  Reputation: 434

Like
0Likes
Like

Posted 14 May 2013 - 02:53 PM

Its an example to show what the general idea of the question is, the general idea is if there is a way to load texels one time so i dont have to load them every time there is a different vertex or different pixel.

 

"Then you could just pass a variable to the shader instead"

describe it more, passing a variable in wich way, from CPU to GPU?(that cant be done because the variable is in a texel in GPU, and passing it to CPU by mapping it and then again to GPU is not so good for performance)


Edited by lomateron, 14 May 2013 - 03:12 PM.


#4 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3736

Like
0Likes
Like

Posted 14 May 2013 - 03:11 PM

Do it on the CPU side and pass it to the shader?

 

As you only "load texels one time"...


FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/cuboidzone.wordpress.com/


#5 lomateron   Members   -  Reputation: 434

Like
0Likes
Like

Posted 14 May 2013 - 03:18 PM

ok, then it can't be done.

what i am doing is creating a view matrix from some particles positions that are in a texture so i dont only have to load texels but make some rotations of vectors too and doing those operations again and again in every vertex shader is a waste in performance, the texture is big passing it to CPU and then again to GPU, i think it will be worse in performance and a pain because the texel of the texture is not in the same place, changes a lot and depends on the value of another texel of another texture.


Edited by lomateron, 14 May 2013 - 03:22 PM.


#6 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3736

Like
0Likes
Like

Posted 14 May 2013 - 03:42 PM

PS. I will be gone for a while...

 

I assume that when you call TextureA.Load it basically loads a pixel at specific coordinates, BTW, can you post the shader to make it easier for us?

 

So let me just get this straight, you will ONLY get the color of one pixel in a whole execution of one shader? So the color is basically a constant throughout the process?

 

If this is the case, I would recommend getting the color of the pixel at the CPU side and then sending this color to the GPU / shader, that would generally do what you would wan't me to do.

 

So at the CPU:

 

D3DXCOLOR t = GetPixelAt(x, y); // your method here...

Send to GPU...

 

GPU: (PS. are you using FX?)

 

float4 t; // then use this value

Can anyone confirm if my suggestion is right?

 

If you don't know how to send a variable from the CPU to the GPU, you could read this:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb509581(v=vs.85).aspx

 

Now if you're using FX, you could read this:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb206299(v=vs.85).aspx

 

PS. I don't know if what you are trying to do can be done, but this method might be easier...


FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/cuboidzone.wordpress.com/


#7 mhagain   Crossbones+   -  Reputation: 9823

Like
0Likes
Like

Posted 14 May 2013 - 04:34 PM

Don't try to second-guess the driver or GPU!  Profile your code, determine if it actually is slow, and act accordingly.  Right now you're just assuming that Loading the texture is going to be slower, but you may be surprised - it may not be.  In this case it's quite likely that your GPU's texture cache is going to mean that only the first Load is going to have any meaningful performance loss, and subsequent Loads (assuming that the coords remain the same) will just be fetched from cache.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#8 phil_t   Crossbones+   -  Reputation: 5761

Like
0Likes
Like

Posted 14 May 2013 - 04:59 PM

Presumably you have a lot less VS instances being run than PS, so at the very least you could do your texture sample in the VS and pass the result on through to the PS.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS