PENGUINLIONG / spirq-rs

Light weight SPIR-V reflection library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImageType is private in ty::SampledImageType?

ktmattson-alion opened this issue · comments

ImageType is accessible in Type::Image(ImageType), but is a private field in
ty::SampledImageType, so the image details cant be extracted from Type::SampledImage(SampledImageType).

Is there a particular reason for this? Or for having ty::SampledImageType at all, rather than just using Type::SampledImage(ImageType)?

It's a design miss made years ago I think. Yes, the img_ty field should be exposed as public. You can PR if you are good with that; otherwise I can take care of it off work.

But in my personal view, we still need SampledImageType as a separate type. In SPIR-V the 'sampled image' (image used for sampling) is not necessarily combined-image-samplers like in OpenGL; or textures to be sampled by a separate sampler resource as in D3D. There is something called a ConstantSampler in OpenCL (which share the same SPIR-V specification as Vulkan & OpenGL). It allows you to defined shader sampler parameters (addressing mode, normalized coords, etc.) within shader code so a sampled image might have sampler parameters attached to it. To keep the door open so someday when OpenCL support is demanded, or Khronos releases a extension to support such feature in Vulkan, we can smoothly adapt to it. Though, I'm not sure if it's too early to consider that.