DX9 and DX10): what is the default pixel (and vertex) shader? (OpenGL too, if possible.)

1.5k views Asked by At

I'm aware that I can optionally specify shaders in DX9, and that I'm required to specify a shader in DX10. The question I have is what happens if I say I want to use a shader and I don't specify one. In a phrase, what I'm looking for is the default behavior. Is there a default shader?

I'm interested in the following scenarios:

  • DX10, don't specify a pixel shader. (Do I have to call PSSetShader(NULL)? What if I don't?) What is the default shader that will run?
  • Same question, vertex shader.
  • DX9, if I specify that I'm going to use a pixel shader, but then don't specify one, what happens? Is there a default? Is there a default if I elect to use the fixed-function interface? Are those defaults the same?
  • Bonus question: What about OpenGL and GLSL? Same question as DX9.

I'd love to see a pointer to the documentation for this - I've perused the Microsoft online DX docs but have really gotten nowhere in finding any sort of default behavior.

Thanks!

1

There are 1 answers

1
datenwolf On BEST ANSWER

In OpenGL version <= 2.x if you enable shaders but don't supply any shader code the shader stage is incomplete and trying to render something will just cause an error.

In OpenGL version >= 3 core profile supplying shaders is mandatory. Without a shader it's the same situation as OpenGL-2 shaders enabled, but no shader supplied: Trying to render something => error. In OpenGL-3.x compatibility profile behaviour is just like OpenGL-2.x -- there's not a default shader to speak of, behavior matches the fixed function pipeline, which can be described by a shader, but no actual shader code is specified. Technically the OpenGL-2.x driver for a modern GPU will create a shader in-situ that matchs the currently set fixed function pipeline configuration.