Skip to content

Split GL samplers into two variables

Jesse Natalie requested to merge separate-samplers into msclc-d3d12

As I was working on CL image support and realized I'd need to emit samplers instead of images to get access to texture ops like sampling, it occurred to me that GL, and therefore NIR and the converter as written so far treat a sampler object as both a texture and its sampling parameters. Since CL doesn't... that's kind of a deal breaker.

The solution I think is best here is to split GL samplers into two objects, which will match the NIR we get from the SPIRV->NIR converter. In the converter:

  • When a type is declared as a bare sampler in SPIR-V, the resulting NIR/GLSL type is glsl_bare_sampler_type(), which is just a sampler (dimension doesn't matter) which returns void.
  • When a type is declared as a sample-able image in SPIR-V, the resulting NIR/GLSL type is the corresponding GLSL sampler type.
  • When a type is declared as a combined image/sampler, the resulting NIR/GLSL type is just the type of the image, where the bare sampler type is thrown away.

So, GL SPIR-V will produce combined texture+samplers, where CL/VK SPIR-V will/can produce separate ones, where the sampler-only type is just this "bare" sampler. Since splitting is easier than combining, this seems like the right approach to me.

/cc @kusma @gerddie @lfrb

Merge request reports