Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

The title might not be precise. Let's say I have one material consisting of vertex and pixel shader, another one consisting of vertex, geometry and pixel shader, and yet another one consisting of vertex, hull, domain and pixel shader. I use these 3 materials (shaders) for 3 different objects. If I want to render all 3 objects in one frame can I just apply the first material, render the first object, apply the second one, render the second object and the same with the third one? Is there any restriction to "mixing" shader types this way?

I think there isn't but I'm asking because I'm getting a strange bug in my application. I have 1 material using only vertex and pixel shader and another one using tessellation (vertex, hull, domain and pixel). When I render only 1st object everythings works fine. If I render only 2nd object everythings works fine, as well. But when I try to render both in one frame my application seems to freeze/crash and I get system notification that my graphics card driver crashed. Am I using shaders incorrectly or should I just look for some bug in my code?

Update:

When I assigned a tessellation shader to my first object as well and tried to render both objects... it worked. Or at least it didn't crash like before. And it's a different shader (material) but with the same stages (vertex, hull, domain, pixel) as the other object's material.

Again - is there any restriction to mixing tessellation shader with non-tessellation one?

Update:

Found the culprit - my tessellation shader (vertex, hull, domain and pixel) set 4 stages as active and my other shader (vertex and pixel) used only 2. But I never disabled the unused shader stages (hull and domain) which caused the crash. Still, the main question was "Is it ok to mix shader stages?" which Sean's just answered.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

No, there is no restriction to mixing up use shader stages.

The crash is being caused either by something specific you're doing incorrectly or a driver bug. Turn on the debug layer or trying using the WARP driver when setting up your D3D context. You can also try running under a graphics debugger; NVIDIA, AMD, and Intel have hardware-specific tools and Microsoft supplies hardware-independent tools.

And of course, make sure your driver is up to date, all Windows patches are applied, etc.

share|improve this answer
    
I was just about to write another update to my question! I'll do that in a sec. Anyway, I still wanted to know if I can mix shaders so thank you for answering that. –  NPS Mar 23 at 20:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.