Skip to content

Static Samplers #284

@austinEng

Description

@austinEng

Chrome is interested in adding static samplers to Dawn. Filing this issue because I think there's a possibility it could eventually be a core webgpu concept. Great to add it to the header if that's the case.

Proposal:

+ // Can be chained in WGPUSamplerBindingLayout
+ typedef struct WGPUSamplerBindingLayoutStatic {
+   WGPUChainedStruct chain;
+   WGPUSampler sampler;
+ } WGPUSamplerBindingLayoutStatic WGPU_STRUCTURE_ATTRIBUTE;

typedef enum WGPUFeatureName {
 ...
+  WGPUFeatureName_StaticSamplers,
 ...
}

OR

typedef struct WGPUSamplerBindingLayout {
  WGPUChainedStruct const * nextInChain;
  WGPUSamplerBindingType type;
+ WGPUSampler staticSampler;
 } WGPUSamplerBindingLayout WGPU_STRUCTURE_ATTRIBUTE;

typedef enum WGPUFeatureName {
 ...
+  WGPUFeatureName_StaticSamplers,
 ...
}
  • This doesn't exist in the Web API right now, but it's useful in native, especially for YCbCr sampling (more stuff needed for full YCbCr). We could have an experimental WGPUFeatureName_StaticSamplers, and if it makes it to the Web and all implementations add it, remove the feature? It can be emulated by the implementation when the backend doesn't actually support it.
  • Vulkan, it would map to pImmutableSamplers on VkDescriptorSetLayoutBinding
  • D3D12, it would map to D3D12_STATIC_SAMPLER_DESC in the root signature
  • Metal, it would map to constexpr sampler injected into the MSL shader.
  • In the first option, it's invalid to have non-null staticSampler if WGPUFeatureName_StaticSamplers is not enabled.
    This is how Vulkan does it (no chained struct)
  • In the second option, it's invalid to chain WGPUSamplerBindingLayoutStatic if WGPUFeatureName_StaticSamplers is not enabled.

The first option is attractive because I expect this could become core, so it would be nifty to put it in the base sampler binding layout struct before we cut the webgpu.h 1.0 header. On the other hand, if it never becomes core, it's awkward that it's in the base struct, but you still need to explicitly enable the feature to use it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    non-breakingDoes not require a breaking change (that would block V1.0)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions