• 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
#Include Graphics

DX11
Vertex shader to pixel shader - way of sharing info?

9 posts in this topic

Hello everyone,

 

I am using DX9 and having trouble trying to optimize some SM 3.0 shaders, the thing is that I have all the passable through data between vertex shader and pixel shader full and I dont know how to do it in order to get all the operations only needed in the pixel shader be done just there...in the pixel shader wacko.png .

 

If it were a kind of instruction like SetStreamSource but directly for the pixel shader only to pass there too the same info like passed before to the vertex shader or any other way of reusing in the pixel shader the same info streamed into the vertex shader before like skining info or even instancing info without requiring the valuable few slots that DX9 have?.

 

So reached to this point and after wasting nice times, I think I need some ideas about, please be different of "Pass all to DX11" because atm this isnt a possible option hahaha.

 

Thanks in advance.

0

Share this post


Link to post
Share on other sites

Haha, well indeed I knew that since the beginning. I am asking if is there any way to share as a pre declaration variables those which can be used both for the pixel and vertex shader without having to pass that data through the tiny COLOR(n) TEXCOORDS(n) pipe which in DX9 is two for the color and eight for the texcoords.

 

This should be done for saving many calculations done in the vertex shader for the pixel shader and so...

0

Share this post


Link to post
Share on other sites

There are many things for which I want to make for, one is that I have a motion blur effect implemented which needs the actual and last screen position, I use skinning and instancing so the current world matrix must be calculated on the vertex shader, but the lastPosition should be in the pixel shader.

 

So to calculate that old world matrix there the skinning and instancing info must be passed via which seems the only way to do, COLOR(n) TEXCOORDS(n).

 

For me it seems a real waste of precious passing slots, and my answer is, is there any other way to do?

 

Thank you.

0

Share this post


Link to post
Share on other sites

The slots are there for communication from vertex shader to pixel shader: that's the way you pass info between them.

 

You need to get this "waste" mentality out of your head.  It's not a "waste" if you're using them for a purpose.  You need to pass the info, the slots are for passing the info, so just use (not "waste", "use") the slots.

2

Share this post


Link to post
Share on other sites


So to calculate that old world matrix there the skinning and instancing info must be passed via which seems the only way to do, COLOR(n) TEXCOORDS(n).

 

Can't you just pass the result of that (i.e. the "lastPosition") to the pixel shader? That's a lot less data than the matrix, skinning info, etc...

 


For me it seems a real waste of precious passing slots, and my answer is, is there any other way to do?

 

Well the other way to get data into a pixel shader is via the textures :-). So, thinking outside the box here, you can put the data you need in a texture. Obviously this data can't come from the vertex shader, it must have been written to in a previous draw call. But your vertex shader could possibly pass a texture coordinate to the pixel shader that tells it which part of the texture to sample from to get more data. That's a pretty complicated proposition though.

1

Share this post


Link to post
Share on other sites

The slots are there for communication from vertex shader to pixel shader: that's the way you pass info between them.

 

You need to get this "waste" mentality out of your head.  It's not a "waste" if you're using them for a purpose.  You need to pass the info, the slots are for passing the info, so just use (not "waste", "use") the slots.

 

Re: I will try it out, the thing is there should be a  way of having a vertex stream linked data as for the vertex shader is, for the pixel shader also too, it should be shared memory at the same cost because it is just the same info. Thank you.

 

Can't you just pass the result of that (i.e. the "lastPosition") to the pixel shader? That's a lot less data than the matrix, skinning info, etc...

 

Re: Yes, thats what I am doing right now, but there are many faces to be culled that will :

1. Adquire the last world matrix by skinning+instancing

2. Adquire then the worldviewmatrix to adquire the last position.

 

Well the other way to get data into a pixel shader is via the textures :-). So, thinking outside the box here, you can put the data you need in a texture. Obviously this data can't come from the vertex shader, it must have been written to in a previous draw call. But your vertex shader could possibly pass a texture coordinate to the pixel shader that tells it which part of the texture to sample from to get more data. That's a pretty complicated proposition though.

 

Re: That is the only solution I reached to the skinning is done by textures so i will try passing the indexes to the pixel shader, I referred to that as a  waste because I dont understand why it cant be just streamed in as I did with the vertex shader as BLENDINDICES+BLENDWEIGHT... isnt really possible?

 

I thank you so much for all the people who answered this post, I am at the same point now, but at least I dont feel so that alone rolleyes.gif .

0

Share this post


Link to post
Share on other sites
The problem you are running into is simply because of the details of DX9 era hardware; the vertex and pixel shaders tended to be implemented in different silicon with different abilities and above all different interconnects to memory. For the longest time DX9 hardware didn't have a connection between the vertex shaders and the hardware for texture sampling, for example.

In this case the pixel shaders have access to three sources of information;
- textures
- data from previous vertex shader stages
- constant data "in registers"

Those are your 'data in paths' and only paths.

The only way to get a more complex memory subsystem is to break from hardware with those limits which means breaking from the API; D3D11 and OpenGL4.x allow you to attach many more streams of input data to the various shader stages (and indeed, output too with 11.1 allowing output buffers on all stages and OpenGL4.x having the same functionality).
1

Share this post


Link to post
Share on other sites

Thank you for that history appointment phantom, at least for me has been quite enlightening.

 

Also I would like to ask for forgiveness about if my english could inflict any eyes bleeding.

 

I will try to continue the way with this DX9 knowing this "era" was still quite dark between the relation of graphics pipeline programmers and hardware producers hahaha.

 

Welcome to the new DX11 era, I will want to get there fast :), maybe the jump to there from DX9 obviating DX10 will worth?. I am still supporting DX9 because of compatibility issues only.

0

Share this post


Link to post
Share on other sites
Avoiding DX10 is the best plan; DX11 works on the same hardware (via feature levels to expose what the hardware can do) and is a better API in general - there is no need to worry about the existence of DX10 at this point smile.png
1

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

  • Similar Content

    • By YixunLiu
      Hi,
      I have a surface mesh and I want to use a cone to cut a hole on the surface mesh.
      Anybody know a fast method to calculate the intersected boundary of these two geometries?
       
      Thanks.
       
      YL
       
    • By hiya83
      Hi, I tried searching for this but either I failed or couldn't find anything. I know there's D11/D12 interop and there are extensions for GL/D11 (though not very efficient). I was wondering if there's any Vulkan/D11 or Vulkan/D12 interop?
      Thanks!
    • By lonewolff
      Hi Guys,
      I am just wondering if it is possible to acquire the address of the backbuffer if an API (based on DX11) only exposes the 'device' and 'context' pointers?
      Any advice would be greatly appreciated
    • By MarcusAseth
      bool InitDirect3D::Init() { if (!D3DApp::Init()) { return false; } //Additional Initialization //Disable Alt+Enter Fullscreen Toggle shortkey IDXGIFactory* factory; CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&factory)); factory->MakeWindowAssociation(mhWindow, DXGI_MWA_NO_WINDOW_CHANGES); factory->Release(); return true; }  
      As stated on the title and displayed on the code above, regardless of it Alt+Enter still takes effect...
      I recall something from the book during the swapChain creation, where in order to create it one has to use the same factory used to create the ID3D11Device, therefore I tested and indeed using that same factory indeed it work.
      How is that one particular factory related to my window and how come the MakeWindowAssociation won't take effect with a newly created factory?
      Also what's even the point of being able to create this Factories if they won't work,?(except from that one associated with the ID3D11Device) 
    • By ProfL
      Can anyone recommend a wrapper for Direct3D 11 that is similarly simple to use as SFML? I don't need all the image formats etc. BUT I want a simple way to open a window, allocate a texture, buffer, shader.
  • Popular Now