shaders/sampling: allow taking the sampler2D as an argument

Merged Niklas Haas requested to merge src_refactor into master

Requested by VLC, which wants to abstract the texture binding and coordinates (vertex attribute) away from the actual shader doing the scaling.

This requires adding a new type of shader signature, PL_SHADER_SIG_SAMPLER2D, and also extending pl_sample_src to allow specifying samplers in this way.

The main glaring note here is that I realized the compute shader does some hacks w.r.t the texture coordinate which does not actually work in a general sense, since it relies on the mapping logic being performed by the pl_dispatch. That being said, it's not entirely clear how vertex attributes should work at all for compute shaders like this.

It's entirely possible we may need to work around this either by having the thread 0 in the work group broadcast its position to the rest of the work group (instead of abusing tex_map), or alternatively, we could maybe move some of the pl_dispatch simulation code from the dispatch mechanism to the actual shader binding mechanism, so that generated compute shaders won't have vertex attributes to begin with.

Merge request reports