Shaders

Started by
5 comments, last by Alkan 8 years, 6 months ago

Hello

I'm new to Direct3D, i come from the OpenGL world and my question is about shaders.

With OpenGL, you never bind a vertex shader or a pixel shader. Instead, you link both into a shader program then you bind the program (not the individual shaders). It seems like Direct3D work differently though.

So when sorting draw calls, do you sort by vertex shaders then by pixel shader ? Wouldn't it be simpler to sort by pair of vertex/pixel shaders ?

I must admit i don't really understand the idea of binding vertex and pixel shaders separately.

Advertisement
I emulate GL here - I create my own object that is a pair of pixel/vertex shaders (or a tuple of pixel/vertex/geometry shaders, etc...).
I then sort using the IDs of my "pair" objects.
I do what Hodgman does.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

If you go on this road, don't forget to keep capacity used of the sort array to avoid alloc each frame.

I am assuming you are doing some more sorting than just the shader states right, because eliminating state changes in my rendering loop gave me a good performance boost even doing this manually with keeping track of the current ids and just checking against what I would be setting next.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

I also do what Hodgman does :)

I am assuming you are doing some more sorting than just the shader states right, because eliminating state changes in my rendering loop gave me a good performance boost even doing this manually with keeping track of the current ids and just checking against what I would be setting next.

Yes, i sort opaque geometry by shader then by texture then by vbo then depth (front to back). Translucent geometry is sorted by depth only back to front.

This topic is closed to new replies.

Advertisement