Expand description
A wgpu render device for the Noesis GUI Native SDK.
Noesis does no drawing of its own: it hands a render device textures to
create, render targets to fill, and batches of triangles to draw.
WgpuRenderDevice does that work on a wgpu::Device and wgpu::Queue
you provide. It compiles a pipeline for each shader and render state Noesis
asks for, and submits its own command encoders: one when the offscreen
phase ends and one when the onscreen phase ends.
The device renders into Rgba8Unorm targets. Use it from the thread that
drives the Noesis view and renderer.
§Driving the device
With the default shim feature, the device implements
noesis_runtime’s RenderDevice trait. Register it with
noesis_runtime::render_device::register, bind it to a view’s renderer,
and Noesis calls it directly:
let mut device = noesis_wgpu::WgpuRenderDevice::new(wgpu_device, wgpu_queue);
device.set_onscreen_target(target_view, width, height);
let registered = noesis_runtime::render_device::register(device);
view.renderer().init(®istered);A host that receives Noesis’s device calls some other way, such as a C#
RenderDevice that forwards them over a C ABI, calls the same methods
itself. That host creates Noesis’s texture objects, so it knows which
TextureHandle each texture
pointer in a Batch stands
for. It passes them to WgpuRenderDevice::draw_batch_with as
BatchTextures.
§Beyond the protocol
- Custom shaders:
WgpuRenderDevice::create_pixel_shadercompiles WGSL for Noesis’sBrushShaderandShaderEffectobjects, andWgpuRenderDevice::draw_custom_batchdraws a batch with one, given as aBatchShader. WgpuRenderDevice::import_texturewraps awgpu::Texturethe host owns, such as a live render target, as a texture Noesis can sample.WgpuRenderDevice::set_pattern_lodbiases and caps the mip level of images, as aPatternLod.
§Features
shim(default): implementsnoesis_runtime’sRenderDevicetrait andBatchTextures::from_batch. Turns onnoesis_runtime’s ownshimfeature, so the build needs the Noesis Native SDK. Without it, this crate andnoesis_runtimebuild with no SDK and link no Noesis library.
Structs§
- Batch
Shader - The custom shader a batch draws with, and its inputs, as device handles.
- Batch
Textures - The textures a
Batchsamples, as device handles. - Device
Stats - What a
WgpuRenderDevicehas drawn, fromWgpuRenderDevice::stats. - Pattern
Lod - How pattern textures pick their mip level, set with
WgpuRenderDevice::set_pattern_lod. - Pixel
Shader Desc - Parameters for
WgpuRenderDevice::create_pixel_shader. - Pixel
Shader Error - Why
WgpuRenderDevice::create_pixel_shaderrejected a shader: the description is out of range, or wgpu’s validation message for the WGSL. - Pixel
Shader Handle - The device’s identifier for a custom pixel shader, returned by
WgpuRenderDevice::create_pixel_shader. - Wgpu
Render Device - A Noesis render device that draws with wgpu.
Enums§
- Pixel
Shader Kind - Which Noesis object a custom shader serves, which decides the function its source defines and the batches it draws.
Constants§
- MAX_
SHADER_ CONSTANTS - The largest
Constantsstruct a custom shader can declare, in bytes: the size of Noesis’scbuffer1_ps, 128 floats. - MAX_
SHADER_ TEXTURES - The most extra textures a custom shader can sample.