Skip to main content

Module sampling

Module sampling 

Source
Expand description

Texture bindings for the image paint.

§Why every draw binds a texture

The shader is one program serving every material kind, so it declares the texture and sampler whether a given draw samples them or not. Vulkan wants every descriptor a pipeline statically uses to be bound, and “statically uses” does not care that the branch reading it is unreachable for a solid fill. The alternatives are a pipeline variant per material kind, which multiplies the cache by four to avoid one binding, or leaving the descriptor unbound, which is invalid. So a draw that samples nothing binds a one-pixel placeholder instead.

§Why one sampler rather than one per tile mode

Address modes are a property of the paint, and baking them into samplers would mean a sampler per combination and a descriptor set per draw that used a different one. The shader does the wrapping arithmetic itself and the sampler stays fixed at clamp-to-edge, which also keeps repeat and decal from depending on filtering behavior at the seam.

Structs§

Bindings
Descriptor sets and image views for one submission.

Functions§

build
Build the bindings a batch needs from the table it was given.
create_descriptor_layout
The descriptor set layout every pipeline is built against.
create_placeholder_binding
The pool, view and set for the placeholder texture.
create_sampler
The one sampler every image draw uses.
image_binding
Which binding number the indexth texture a program declares occupies.
transition_for_sampling
Move every texture a batch samples into the layout a shader reads from.