pub struct HdrGpuContext {
pub device: Device,
pub queue: Queue,
pub color_texture: Texture,
pub color_view: TextureView,
pub width: u32,
pub height: u32,
}Expand description
A headless GPU context backed by an Rgba16Float offscreen texture.
Unlike crate::GpuContext (which uses Rgba8Unorm for byte-exact
readback), HdrGpuContext uses Rgba16Float so fragment shaders can
output linear-light values in [0, +∞). Readback returns raw f16
bytes; use a half-to-float conversion to get the actual float values.
HDR capability requires the adapter to support Rgba16Float as a render
attachment. The from_device constructor validates this and returns
UiError::Unsupported if the format is not supported.
Fields§
§device: DeviceThe logical GPU device.
queue: QueueThe command queue.
color_texture: TextureThe Rgba16Float offscreen texture.
color_view: TextureViewView over color_texture.
width: u32Target width in physical pixels.
height: u32Target height in physical pixels.
Implementations§
Source§impl HdrGpuContext
impl HdrGpuContext
Sourcepub fn headless(width: u32, height: u32) -> Result<Self, UiError>
pub fn headless(width: u32, height: u32) -> Result<Self, UiError>
Create a headless HDR context.
§Errors
UiError::Unsupportedif no GPU adapter is available, if the dimensions are zero, or if the adapter does not supportRgba16Floatas a render attachment.UiError::Backendif device creation fails.
Sourcepub fn readback_f16(&self) -> Result<Vec<u8>, UiError>
pub fn readback_f16(&self) -> Result<Vec<u8>, UiError>
Read back the HDR texture as raw bytes.
The returned buffer contains width * height * 8 bytes (4 channels ×
2 bytes per channel, f16 little-endian), tightly packed (row padding
stripped).
§Errors
Returns UiError::Render if the GPU poll or buffer mapping fails.
Auto Trait Implementations§
impl !RefUnwindSafe for HdrGpuContext
impl !UnwindSafe for HdrGpuContext
impl Freeze for HdrGpuContext
impl Send for HdrGpuContext
impl Sync for HdrGpuContext
impl Unpin for HdrGpuContext
impl UnsafeUnpin for HdrGpuContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more