EmbarkStudios / rust-gpu

🐉 Making Rust a first-class language and ecosystem for GPU shaders 🚧

Home Page:https://shader.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Emulate Image/Sampler API operations on non-SPIRV platforms

Keavon opened this issue · comments

While the GPU provides hardware for texture sampling and interpolation, on other targets (i.e. CPU in general) it's necessary to emulate that. Currently, the Image and Sampler APIs don't provide texture sampling operations when compiling to non-SPIRV targets.

We need this for an issue on Graphite to support image transformation with graceful CPU fallback (even if the performance would be not ideal), since WebGPU is only available on Chromium browsers for now and thus CPU is still an important target. Having this feature be as performant as possible would be eventually nice, but a slower solution would be a reasonable starting point of greater priority to our use case (something is better than nothing, existing is better than fast).

This issue was discussed in the Embark Discord.

Also on Discord before filing this issue, @eddyb summarized some recollection of the potential main three main concerns involved:

how to feed data into the API, how the API stores the data internally, and how the sampling is implemented - with the middle one, with its potential need to add lifetimes, and/or remove Copy & use Arc, being the worst part, since at least unoptimized sampling is mostly "just" looking up 4 texels and interpolating them