Use more headers in AsBindGroup docs (#17586)
# Objective - Linking to a specific AsBindGroup attribute is hard because it doesn't use any headers and all the docs is in a giant block ## Solution - Make each attribute it's own sub-header so they can be easily linked --- ## Showcase Here's what the rustdoc output looks like with this change  ## Notes I kept the bullet point so the text is still indented like before. Not sure if we should keep that or not
This commit is contained in:
parent
416100a253
commit
9c5ce33e1d
@ -142,12 +142,14 @@ impl Deref for BindGroup {
|
||||
///
|
||||
/// The following field-level attributes are supported:
|
||||
///
|
||||
/// * `uniform(BINDING_INDEX)`
|
||||
/// ## `uniform(BINDING_INDEX)`
|
||||
///
|
||||
/// * The field will be converted to a shader-compatible type using the [`ShaderType`] trait, written to a [`Buffer`], and bound as a uniform.
|
||||
/// [`ShaderType`] is implemented for most math types already, such as [`f32`], [`Vec4`](bevy_math::Vec4), and
|
||||
/// [`LinearRgba`](bevy_color::LinearRgba). It can also be derived for custom structs.
|
||||
///
|
||||
/// * `texture(BINDING_INDEX, arguments)`
|
||||
/// ## `texture(BINDING_INDEX, arguments)`
|
||||
///
|
||||
/// * This field's [`Handle<Image>`](bevy_asset::Handle) will be used to look up the matching [`Texture`](crate::render_resource::Texture)
|
||||
/// GPU resource, which will be bound as a texture in shaders. The field will be assumed to implement [`Into<Option<Handle<Image>>>`]. In practice,
|
||||
/// most fields should be a [`Handle<Image>`](bevy_asset::Handle) or [`Option<Handle<Image>>`]. If the value of an [`Option<Handle<Image>>`] is
|
||||
@ -162,7 +164,8 @@ impl Deref for BindGroup {
|
||||
/// | `multisampled` = ... | `true`, `false` | `false` |
|
||||
/// | `visibility(...)` | `all`, `none`, or a list-combination of `vertex`, `fragment`, `compute` | `vertex`, `fragment` |
|
||||
///
|
||||
/// * `storage_texture(BINDING_INDEX, arguments)`
|
||||
/// ## `storage_texture(BINDING_INDEX, arguments)`
|
||||
///
|
||||
/// * This field's [`Handle<Image>`](bevy_asset::Handle) will be used to look up the matching [`Texture`](crate::render_resource::Texture)
|
||||
/// GPU resource, which will be bound as a storage texture in shaders. The field will be assumed to implement [`Into<Option<Handle<Image>>>`]. In practice,
|
||||
/// most fields should be a [`Handle<Image>`](bevy_asset::Handle) or [`Option<Handle<Image>>`]. If the value of an [`Option<Handle<Image>>`] is
|
||||
@ -175,7 +178,8 @@ impl Deref for BindGroup {
|
||||
/// | `access` = ... | any member of [`StorageTextureAccess`](crate::render_resource::StorageTextureAccess) | `ReadWrite` |
|
||||
/// | `visibility(...)` | `all`, `none`, or a list-combination of `vertex`, `fragment`, `compute` | `compute` |
|
||||
///
|
||||
/// * `sampler(BINDING_INDEX, arguments)`
|
||||
/// ## `sampler(BINDING_INDEX, arguments)`
|
||||
///
|
||||
/// * This field's [`Handle<Image>`](bevy_asset::Handle) will be used to look up the matching [`Sampler`] GPU
|
||||
/// resource, which will be bound as a sampler in shaders. The field will be assumed to implement [`Into<Option<Handle<Image>>>`]. In practice,
|
||||
/// most fields should be a [`Handle<Image>`](bevy_asset::Handle) or [`Option<Handle<Image>>`]. If the value of an [`Option<Handle<Image>>`] is
|
||||
@ -186,11 +190,12 @@ impl Deref for BindGroup {
|
||||
/// |------------------------|-------------------------------------------------------------------------|------------------------|
|
||||
/// | `sampler_type` = "..." | `"filtering"`, `"non_filtering"`, `"comparison"`. | `"filtering"` |
|
||||
/// | `visibility(...)` | `all`, `none`, or a list-combination of `vertex`, `fragment`, `compute` | `vertex`, `fragment` |
|
||||
/// * `storage(BINDING_INDEX, arguments)`
|
||||
///
|
||||
/// ## `storage(BINDING_INDEX, arguments)`
|
||||
///
|
||||
/// * The field's [`Handle<Storage>`](bevy_asset::Handle) will be used to look up the matching [`Buffer`] GPU resource, which
|
||||
/// will be bound as a storage buffer in shaders. If the `storage` attribute is used, the field is expected a raw
|
||||
/// buffer, and the buffer will be bound as a storage buffer in shaders.
|
||||
/// * It supports an optional `read_only` parameter. Defaults to false if not present.
|
||||
///
|
||||
/// | Arguments | Values | Default |
|
||||
/// |------------------------|-------------------------------------------------------------------------|----------------------|
|
||||
@ -253,19 +258,24 @@ impl Deref for BindGroup {
|
||||
/// ```
|
||||
///
|
||||
/// Some less common scenarios will require "struct-level" attributes. These are the currently supported struct-level attributes:
|
||||
/// * `uniform(BINDING_INDEX, ConvertedShaderType)`
|
||||
/// ## `uniform(BINDING_INDEX, ConvertedShaderType)`
|
||||
///
|
||||
/// * This also creates a [`Buffer`] using [`ShaderType`] and binds it as a uniform, much
|
||||
/// like the field-level `uniform` attribute. The difference is that the entire [`AsBindGroup`] value is converted to `ConvertedShaderType`,
|
||||
/// which must implement [`ShaderType`], instead of a specific field implementing [`ShaderType`]. This is useful if more complicated conversion
|
||||
/// logic is required. The conversion is done using the [`AsBindGroupShaderType<ConvertedShaderType>`] trait, which is automatically implemented
|
||||
/// if `&Self` implements [`Into<ConvertedShaderType>`]. Only use [`AsBindGroupShaderType`] if access to resources like [`RenderAssets<GpuImage>`] is
|
||||
/// required.
|
||||
/// * `bind_group_data(DataType)`
|
||||
///
|
||||
/// ## `bind_group_data(DataType)`
|
||||
///
|
||||
/// * The [`AsBindGroup`] type will be converted to some `DataType` using [`Into<DataType>`] and stored
|
||||
/// as [`AsBindGroup::Data`] as part of the [`AsBindGroup::as_bind_group`] call. This is useful if data needs to be stored alongside
|
||||
/// the generated bind group, such as a unique identifier for a material's bind group. The most common use case for this attribute
|
||||
/// is "shader pipeline specialization". See [`SpecializedRenderPipeline`](crate::render_resource::SpecializedRenderPipeline).
|
||||
/// * `bindless(COUNT)`
|
||||
///
|
||||
/// ## `bindless(COUNT)`
|
||||
///
|
||||
/// * This switch enables *bindless resources*, which changes the way Bevy
|
||||
/// supplies resources (uniforms, textures, and samplers) to the shader.
|
||||
/// When bindless resources are enabled, and the current platform supports
|
||||
|
||||
Loading…
Reference in New Issue
Block a user