• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
lomateron

HLSL question

7 posts in this topic

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
0

Share this post


Link to post
Share on other sites

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...

0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

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...

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

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  
Followers 0