ok this may seem like a stupid question, but I've just implemented my mesh and shader pipeline under dx11 in my new engine and have found that everything is cool while one shader is used on all meshes, but when I apply a different shader(useing sm_5_0), the meshes disappear. when I set it back to the original shader the mesh is visible again.
does anyone know why this happens or is there something I'm missing in applying different shaders. I was thinking maybe the CBuffers can't be shared accross multiple shaders or something. there are no errors, the meshes with the new shader just disappear, which I assume would be the matrix and othe cbuffer data might be stopped going to the shader hence my comment about sharing CBuffers accross multiple shaders.
this wasn't an issue with dx9 and I'm hopeing I'm just missing a flag or function that allows the shaders to be set to the current mesh being drawn. I can't really post any code right now but wondering if anyone has had similar issues and can point out anything obvious I might have missed or point me to an example where 2 different sm_5_0 shaders are used in the same rendering pipeline.
I will get to the bottom of it eventually but while I'm looking into it I thought I would ask.
dx11 and multiple shaders...
Started by David Gallagher, Jan 09 2012 08:50 AM
6 replies to this topic
#1
Posted 09 January 2012 - 08:50 AM
#2
Posted 09 January 2012 - 09:19 AM
I'm not aware of any reason you wouldn't be able to share constant buffers amongst shaders. Indeed one of the most common ways to use them is to put all per-frame constants (e.g. camera position, world-to-clip matrix etc.) in one cbuffer that's used by all shaders, then the per-shader constants in additional cbuffers that are used by the individual shaders.
Double-check that the math is correct in your second shader, and the meshes aren't getting transformed to zero or something like that? Also, double-check your render states and ensure you're not doing something weird with the cull state or some such.
Double-check that the math is correct in your second shader, and the meshes aren't getting transformed to zero or something like that? Also, double-check your render states and ensure you're not doing something weird with the cull state or some such.
reedbeta.com - developer blog, OpenGL demos, and other projects
#3
Posted 09 January 2012 - 09:25 AM
watch out for blend state, render state, double check both of those- just like reedbeta says, if your using multiple render targets make sure the blend state is set on every one. dx10/dx11 has a few gotchas when porting from dx9, dont worry i had to go through it all too.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.
#4
Posted 09 January 2012 - 09:09 PM
Thanks for the advice guys, will look into this now. good to know that I can share cbuffers as that's how I had set it up and will save me any rewrites there. ok off to it i go...
#5
Posted 09 January 2012 - 09:51 PM
I think I have found the issue, rather than switching to and from a tessellation and default shader I switched between 2 different tessellation shaders and the mesh was drawn no problem. the default shader works if is applied first but switching to a tessellation shader from the default shader makes it go invisible.
the only major difference is the default shader only has a VS and PS while the tessellation shader has VS,HS,DS and PS. Is there anything special i have to do when switching shaders that do/don't have HS and DS in the pipeline when drawing meshes if the shader does/doesn't require them? Thanks for any info in this.
the only major difference is the default shader only has a VS and PS while the tessellation shader has VS,HS,DS and PS. Is there anything special i have to do when switching shaders that do/don't have HS and DS in the pipeline when drawing meshes if the shader does/doesn't require them? Thanks for any info in this.
#6
Posted 09 January 2012 - 09:58 PM
got it, setting the hs and ds to null when the shader doesn't require them fixed everything. didn't know that had to be done... thanks again guys!
gD3D_DeviceContext->HSSetShader(NULL, 0, 0); gD3D_DeviceContext->DSSetShader(NULL, 0, 0);
#7
Posted 09 January 2012 - 10:11 PM
oh! thats happened to me before! watch out dx11 is nasty.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












