Jump to content
  • Advertisement
Sign in to follow this  

What's the point of having a single render device?

This topic is 2704 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sorry for the vague title, my whole question wouldn't fit, which is:

What's the point of having a single render device, when so many things need different ways of handling?

I'm trying to implement my own rendering system, really basic, Dx9 and all that, and from overhauling some of my old code, I've found out that out that the more I keep responsibilities of objects/functions separate, the easier I can maintain and extend stuff, pretty much what people recommend anyways.

That means:
Avoid monolithic do-it-all god classes, right? Yes.

Isn't a render device pretty much monolithic, that way if one wants it to be actually substantial, and not just some sort of delegate thing that shoves data between specialized components?
Or is that the point of one, after all?

So, isn't it better to have things like "GuiWindowRenderer", "FontRenderer", "3dRenderer" that could maybe act as plugins, or well, components for a big class?
Or would it be better to completely split those things and use them on their own, when one wants to render a GuiWindow instead of an actual ingame object?
The only need for a RenderDevice I can see that way would be a common framework like thing, that access backbuffers, and flips them and all that, but in that case the renderdevice is not the main hero, but the shadow sidekick.

So, what are the "rendering system" blocks one can see in engine design diagrams really?
I'm aware that that question is kind of a bad one, since a monolithic, rigid spaghetti-like monster class could do it all, and still pass as a rendering system, but let's say we don't want it that way...
Instead...would you make the components the stars, and have the device be some sort of low level widget?
Or have the components act more like scripts, or plug ins something that wants to be rendered can use?
Like with 2D GUI rendering, if it were a script, it could set the device to use an orthogonal view, and then feed it a stream of vertices, and material data.
Then, when it's time to render some scene object, a different view would be used, and so on.

So in short, I'm having trouble designing a sort of layout plan for responsibilities, what should depend on what, etc.

Any resources that focus on that particular topic?
(Again I apologize for vagueness, please act as if this topic never happened if it's too vague for you. Don't want people to feel like they put effort into a reply in vain)

Share this post

Link to post
Share on other sites
To support multiple platforms, but still allow high-level rendering code to be ignorant of the actual platform, I always wrap the low-level device (e.g. D3D) in some kind of low-level rendering layer. My current low-level layer provides these classes:
[font="Courier New"][font="arial, verdana, tahoma, sans-serif"]
[/font][/font][font="Courier New"]StateGroup[/font]s => set of [font="Courier New"]RenderState[/font]s.
[font="Courier New"]State[/font]s => sub-classed into [font="Courier New"]RenderState[/font]s (blend mode, shader constants, shader programs, stream sources, etc) and [font="Courier New"]DrawCall[/font]s.
[font="Courier New"]CommandList[/font] => sequence of [font="Courier New"]State[/font]s.
[font="Courier New"]RenderInstance[/font] => a [font="Courier New"]DrawCall[/font] paired with a stack of [font="Courier New"]StateGroup[/font]s, and a sort-key.
[font="Courier New"]RenderGroup[/font] => a set of [font="Courier New"]RenderInstance[/font]s.

High-level rendering modules are then built on top of these classes (e.g. [font="Courier New"]GuiRenderer[/font], [font="Courier New"]LevelRenderer[/font], etc).
High-level 'Drawables' can exist in many different formats, as long as they can be converted into a [color="#1C2837"]RenderInstance (i.e. are composed of [font="Courier New"]DrawCall[/font]s and [font="Courier New"]StateGroup[/font]s).
These high-level modules then collect a list of 'Drawables' (each of which has a [font="Courier New"]DrawCall[/font] and stack of [font="Courier New"]StateGroup[/font]s), and gives them to a function along with a default/global [font="Courier New"]StateGroup[/font] (the default/global group is for states like the viewport/render-target that apply to every drawable in the list), which produces a [font="Courier New"]RenderGroup[/font]. This RenderGroup can then be handed to the low-level renderer.

The low-level module can sort the submitted [font="Courier New"]RenderGroup[/font]s and then convert them into [font="Courier New"]CommandList[/font]s, which are then executed by the device.

N.B. there's no global states in this design. One thing can't "set a ortho matrix" by itself -- that "set" command has to be part of a state-group, which is attached to a 'Drawable' somehow.

Share this post

Link to post
Share on other sites
Thank you for your reply, I might adapt my system to it as well, since it has some vague similarities already.
My very small and humble system so far uses commands as well, but it's the meshes that have them, and the meshes are being filled by the two simple components so far, window rendering, and static mesh rendering.

It goes like this:
My render device can only do one thing when it comes to rendering: clear, accept a list of meshes, flip.
Each mesh has vertex and index data, and a material.
A material has resources (or handles to them, the actual things are in a libary that get filled at load time) like vertex and pixelshaders, a vertex declaration, a constant table that is linked to variable emitters, info about which datastreams of the mesh are in use, and so on.

To actually produce data, a system like the window renderer takes a mesh, fills it with mesh data according to the states of the windows using it, then sets commands like "Clear the Zbuffer", "Change View to Orthogonal" for the material script, and sends the mesh on it's merry way.

It's a bit awkward when it comes to configuring it all, but it works.
I'm not sure if this 'passthrough' way of doing it is a good idea.

In essence, that window rendering system is just a mutator, it doesn't have much state info itself...does that fall under that gypsy wagon/poltergeist thing?

But again, thanks for the input, that looks a lot more structured than mine...

Hm, so no global state like that?
Interesting. Makes sense though, smaller lego blocks that can form many things, including a duplo block, like the OrthoMatrix thing are better than using duplos only.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!