Name Description Size
conv.rs 8700
help.rs ! Helpers for the hlsl backend Important note about `Expression::ImageQuery`/`Expression::ArrayLength` and hlsl backend: Due to implementation of `GetDimensions` function in hlsl (<https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-getdimensions>) backend can't work with it as an expression. Instead, it generates a unique wrapped function per `Expression::ImageQuery`, based on texture info and query function. See `WrappedImageQuery` struct that represents a unique function and will be generated before writing all statements and expressions. This allowed to works with `Expression::ImageQuery` as expression and write wrapped function. For example: ```wgsl let dim_1d = textureDimensions(image_1d); ``` ```hlsl int NagaDimensions1D(Texture1D<float4>) { uint4 ret; image_1d.GetDimensions(ret.x); return ret.x; } int dim_1d = NagaDimensions1D(image_1d); ``` 97404
keywords.rs 20819
mod.rs 28521
ray.rs 6102
storage.rs ! Generating accesses to [`ByteAddressBuffer`] contents. Naga IR globals in the [`Storage`] address space are rendered as [`ByteAddressBuffer`]s or [`RWByteAddressBuffer`]s in HLSL. These buffers don't have HLSL types (structs, arrays, etc.); instead, they are just raw blocks of bytes, with methods to load and store values of specific types at particular byte offsets. This means that Naga must translate chains of [`Access`] and [`AccessIndex`] expressions into HLSL expressions that compute byte offsets into the buffer. To generate code for a [`Storage`] access: - Call [`Writer::fill_access_chain`] on the expression referring to the value. This populates [`Writer::temp_access_chain`] with the appropriate byte offset calculations, as a vector of [`SubAccess`] values. - Call [`Writer::write_storage_address`] to emit an HLSL expression for a given slice of [`SubAccess`] values. Naga IR expressions can operate on composite values of any type, but [`ByteAddressBuffer`] and [`RWByteAddressBuffer`] have only a fixed set of `Load` and `Store` methods, to access one through four consecutive 32-bit values. To synthesize a Naga access, you can initialize [`temp_access_chain`] to refer to the composite, and then temporarily push and pop additional steps on [`Writer::temp_access_chain`] to generate accesses to the individual elements/members. The [`temp_access_chain`] field is a member of [`Writer`] solely to allow re-use of the `Vec`'s dynamic allocation. Its value is no longer needed once HLSL for the access has been generated. Note about DXC and Load/Store functions: DXC's HLSL has a generic [`Load` and `Store`] function for [`ByteAddressBuffer`] and [`RWByteAddressBuffer`]. This is not available in FXC's HLSL, so we use it only for types that are only available in DXC. Notably 64 and 16 bit types. FXC's HLSL has functions Load, Load2, Load3, and Load4 and Store, Store2, Store3, Store4. This loads/stores a vector of length 1, 2, 3, or 4. We use that for 32bit types, bitcasting to the correct type if necessary. [`Storage`]: crate::AddressSpace::Storage [`ByteAddressBuffer`]: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-byteaddressbuffer [`RWByteAddressBuffer`]: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-rwbyteaddressbuffer [`Access`]: crate::Expression::Access [`AccessIndex`]: crate::Expression::AccessIndex [`Writer::fill_access_chain`]: super::Writer::fill_access_chain [`Writer::write_storage_address`]: super::Writer::write_storage_address [`Writer::temp_access_chain`]: super::Writer::temp_access_chain [`temp_access_chain`]: super::Writer::temp_access_chain [`Writer`]: super::Writer [`Load` and `Store`]: https://github.com/microsoft/DirectXShaderCompiler/wiki/ByteAddressBuffer-Load-Store-Additions 27904
writer.rs 202926