Implement an abstraction layer for buffers and resources #280
Labels
Feature
New feature to the engine
Graphics
Graphical feature
Refactoring
Something that needs a refactoring
Problem this feature should fix
Buffers and resources such as shaders and textures currently use direct OpenGL calls to create/destroy/bind/unbind/resize... This causes the implementation of a proper HAL (Hardware Abstraction Layer) more tedious.
Expected solution
Following #277, the proposed HAL solution should be expanded to cover buffer and resource manipulation.
Additional Information
Libraries like BGFX usually provide functions in their HAL to manipulate buffers and resources, i.e.:
https://github.com/bkaradzic/bgfx/blob/07be0f213acd73a4f6845dc8f7b20b93f66b7cc4/include/bgfx/bgfx.h#L2779
Texture Creation
Texture Read
Bind Index Buffer
Buffers and Resource classes should then use these driver functions in their cpp implementation.
Early investigations
The idea behind is to have 2 levels for resources:
Storing a ResourceHandle inside of a DriverResource allows us to make this connection between an engine/driver resource, vs an internal graphics API resource.
The Driver and GraphicsAPI will be responsible for implementing methods to:
Provide other utility functions like reading back a pixel from a texture.
Another approach that I'm exploring would be to have resources (mainly buffers), with CPU/CPU copies of the underlying data, with the ability to upload data from the CPU to GPU using synchronization points (typically before rendering a frame you would process the buffer data upload all at once, to avoid unnecessary operations and potentially run these operations in parallel). Buffers could be created with flags like
IMMEDIATE_BUFFER_TRANSFER
andSYNCHRONIZED_BUFFER_TRANSFER
.Further considerations
We could also separate the HAL from
OvRendering
by introducingOvHAL
orOvGraphics
. This project would be 100% focused on providing a platform-agnostic way to manage graphics context, whileOvRendering
would provide a layer of abstraction and rendering features (lighting, post-processing, shadow casting, material system, etc...).The text was updated successfully, but these errors were encountered: