Hello, I have been developing a little game engine which started off as coursework but kept going as a hobby project. Currently I'm trying to figure out a scalable way of setting resources and settings to the GPU, such as shaders, primitive topology, shader resource views and constant buffers.
The way I've been doing it so far is sending all rendering data to a renderer class, then have the renderer look at the resources and figure out what resources and settings to set. This renderer class is a singleton which contains a lot of data, such as shaders, g-buffers, a constant buffer for WVP matrices, etc...
void DeferredRenderer::DrawGeometryPass(RenderObject* renderObject, ID3D11DeviceContext * DeviceContext)
{
bool UseBumpMap = renderObject->renderdata->SRV_bump;
bool UseDisplacementMap = renderObject->renderdata->SRV_disp;
if (UseDisplacementMap)
{
}
else if (UseBumpMap)
{
}
else
{
}
}
But this isn't sustainable at all. With more types of renderables being implemented, the renderer would have to check more fields. So by scalable/sustainable I describe a method of figuring out what settings and resources to set that does not result in increasingly messy code (more code is fine, messy is not) and substantially degrading performance with more renderable types. I've had a few ideas such as a material class which contains and sets its own resources, or a material ID which is used by the renderer to figure out what resources to look for and set. But I'm feeling very uncertain about both of these options.
Do you have any experience or ideas on how to handle this type of problem? I've been googling and looking up books to try and figure this out, so trust me, I am hungry to hear any idea!