divide on subsystems

Started by
10 comments, last by cr88192 10 years ago
...

Could you say how do you make such layers?

Layered software is a common approach where higher layers use lower layers to do their job, usually provide support for higher layers, but without knowing about layers above self. In the case of graphic rendering the lowest layer is the 3rd party graphics API like OpenGL v4.x or v3.x, OpenGLES v3.x or v2.x, D3D v11 or v10, whatever.

The next higher layer, the one that is the lowest w.r.t. to the own implementation, is an abstraction of said graphics API and is called GraphicDevice in my case. A GraphicDevice abstracts the API and gives it a unified interface. This interface is data driven: A given list of graphic rendering jobs is processed. Each job consists of state setting commands and a draw call (you probably / hopefully knowns of the threads that deal with such a rendering approach).

The next higher level obviously generates such rendering jobs. It does so by processing the scene, determining which objects need to be rendered, requesting the necessary parameter sets, generating mentioned rendering jobs, and pushing the jobs into the current job queue. This layer is actually given mainly in form of a graphic rendering pipeline (i.e. the place where the distinction between forward rendering, deferred rendering and such is implemented; I hope some day it is programmable by a node system, but for now it is modularized but hard coded :) ). On the other hand, this layer of Graphic is coupled to some Services instances. A specific Services is GraphicServices where abstracted graphic rendering resources like rendering targets, "code units" (actually shader script snippets), textures, and similar things are managed. The already mentioned rendering jobs often contain simple indices that refer to an abstraction stored within the GraphicServices. The GraphicDevice then is able to get information about abstracted resources and deal with them as needed for the underlying 3rd party graphic API. Other Services used by the graphic rendering pipeline provide the placement or materials to be used.

One may say that above the graphics pipeline layer there is the producer layer. Its job is to generate resources like meshes for freshly spawned particles or the skinning of skeletons. But that does not fit really good into the pattern, because such a layer would not need the next lower one (the graphic rendering pipeline) to do so. Moreover, from an optimization point of view, generating meshes for objects that are not visible is a waste of time, and culling is done in the layer below, so to say. So producing has not really an own layer in this sense.

From an implementation point of view, layers are a collection of instances that together provide an API for a specific, well defined task. It often uses another layer but this is (mostly) not visible to own clients. The higher a layer the higher is the level of dealing with a problem. E.g. the graphic rendering pipeline layer looks at the scene and picks what to render, but it isn't interested in the details like sorting the jobs by material / script / or whatever.

Advertisement

in my case, my engine is basically divided up somewhat...

renderer stuff:

"lbxgl": high-level renderer, ex: scene/model/animation/materials/...

"pdgl": low-level renderer, ex: texture loading, OS interfaces (WGL, GLX, ...), various utility stuff.

common:

"btgecm": lots of stuff needed by both client and server, ex: voxel terrain, map loading, some file-format code, ...

"bgbbtjpg": graphics library, deals with image loading/saving, video codecs / AVI / ..., compressed-texture formats, ...

"bgbmid1": audio library, deals with mixing, MIDI, text-to-speech, several audio codecs, ...

client:

"btgecl": deals with "client side stuff", mostly sending/recieving messages from server, updating the scene-graph, ...

server:

"btgesv": server-side stuff (game logic, simple "Quake-like" physics, mobs / AI, ...).

"libbsde": rigid-body physics simulation stuff, largely not used at present in favor of simpler physics.

script / infrastructure (back-end):

"bgbgc": garbage collector

"bgbdy": dynamic types, object-system stuff, VFS (virtual filesystem), ...

"bgbsvm": script VM

...

generally I had split libraries up when it gets sufficiently big that it is either unwieldy or takes a long time to rebuild.

in the past, this had generally been somewhere around 50 kLOC.

this is not always the case, for example, my high-level renderer ("lbxgl") is ~ 111 kLOC and is not split up.

adding up a few renderer related libraries, works out to around 303 kLOC.

current project line-count: 879 kLOC.

granted, this project has kind of been ongoing for a while...

Do you need it such wide and heavy (800k lines is big, my all own personal codes last 5 years framework + prototypes is 100k lines

only)

it is big mostly because there is a lot of stuff that it does.

often, stuff seems simple until one needs code to do it, and more code to do it reasonably efficiently (scaling things up to more realistic world-sizes and workloads, ...).

the code then has a way of getting bigger.

sometimes things can also expand when they need to be generalized, say what could otherwise be done with a big function of doom needs to be broken up into smaller general-purpose sub-functions, but potentially resulting in a higher overall line count than had it been a single one-off function, ...

periodically I prune things down to try to keep things from getting too far out of control though.

also, a lot of doing stuff myself without much use of 3rd party libraries (I am not really personally much of a fan of having lots of external dependencies).

some things can also get a little hairy though.

video stuff, texture-compression, getting stuff packed into large combined VBOs in an attempt to avoid killing performance with endless small draw-calls, making a script-interpreter perform acceptably (and do useful levels of stuff), ... it all takes code.

nothing in particular is particularly huge, mostly just lots of little things.

in comparison to a lot of other codebases, for what stuff it does, it doesn't really seem to be doing all that terribly though.

This topic is closed to new replies.

Advertisement