Skip to content

Resource system 2.0 #46

@einarf

Description

@einarf

The resource system so far has been fairly simple only referencing a path to a file. It stores the reference to the resource using path as a key. If the resource is previously loaded, we return the existing one. This however starts to become increasingly complicated as the data file we wish to load gets more complex.

A resource is not necessarily just a single path. It can be multiple paths as shown in shader loading. One file per shader type (vertex, geo, fragment.. etc). When we also add varying properties to this such as shader preprocessors, texture flipping and whatnot.. the responsibility of the resource system gets increasingly complicated.

With the introduction of pluggable loaders for all resources we would have to ask the user to provide some resource metadata class with a custom __hash__ method (and maybe even more) to suggest to the system if a resource is unique or not. This is just too much. The resource loading system should have one responsibility: To load the requested resource. It should not be in the business to caching resources internally. We don't know how our users intend to use the system.

EDIT: This also questions if the resource system should support deferred loading. It might still be reasonable to return a (meta, resource) tuple list when loading a pool.

Why we should still have some kind of registry

Effects and classes such as the TextWriter load resources on initialization. Unless we ask people to supply these resources on creation or somehow pre-load these resources on module import, we would load new resources for each instance.

Another problem is how a single effect can run with runeffect compared to issuing the run command. An effect package might also need a way to separately define its resources. This also needs to work for standalone classes such as the TextWriter since these are not actual effects.

The need for some kind of resource registry is still there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions