🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DX12 Draw lines and triangles in one draw call?

Started by
1 comment, last by MJP 3 years, 3 months ago

I'm in a bit of dilemma. My whole renderer is designed around a list of objects that I need to draw. They are split up into a few groups depending on the draw type (lines, polygons, textured polygons etc). Each of the groups with their own set of root signature and pipeline state, shaders etc. For each group I record draw calls to command lists for fast execution later.

Now I have come across objects that consists of more than one draw type. Some objects consist of both lines and polygons. I just need to send in a line to the pipeline, and the geometry shader can produce the necessary triangles. The thing is I still want to keep these objects together instead of splitting them up into several groups.

Consider that I use command lists, I have a few questions:

  • Is it possible to draw triangles and lines in one draw call?
  • Is is possible to have a geometry shader output both triangles and lines in the same call?
  • Is it possible to draw several instances of the same object (DrawInstanced) with various types?

I'm afraid the answer is no to all of the above, especially when using command lists, because I would still have to switch pipeline state in the middle of executing a command list, right?

  • Is it possible to switch pipeline state quickly in the middle of executing a command list? How?
Advertisement

No, you can't switch the primitive type (or PSO in general) within a draw call. The best you can do is emulate lines by creating a quad made of two triangles.

Switching PSO's in the middle of a command list is fine, just bind the new PSO and issue another draw. It's not free, but it's a totally reasonable thing to do. If you'd like you can still sort draws by PSO to minimize switching.

This topic is closed to new replies.

Advertisement