JFLib

render2d crate root#

/// the most frames the CPU may record ahead of the GPU
FRAMES_MAX: usize = 3
/// records per page: the unit of the pool's regions and of a workgroup of culling (common.wgsl PAGE)
PAGE: u32 = 256
/// quads per instance of a draw (stroke.wgsl BATCH): the u16 indices of one instance reach 4 * BATCH corners
BATCH: u32 = 16384
/// the most visible layers (stroke.wgsl: first_instance = layer << 16 on Voll)
LAYERS_MAX: u32 = 65535
/// the WGSL sources as the device gets them (common.wgsl in front of each, block.wgsl behind it in those that place records;
/// stroke.wgsl with fs_full from full_body.wgsl, the same body as the function full_body, and fill.wgsl)
COMMON_WGSL: &str = include_str!("common.wgsl")
BLOCK_WGSL: &str = include_str!("block.wgsl")
CULL_WGSL: &str = concat!(include_str!("common.wgsl"), include_str!("block. ...
SCATTER_WGSL: &str = concat!(include_str!("common.wgsl"), include_str!("scatte ...
STROKE_WGSL: &str = concat!(include_str!("common.wgsl"), include_str!("block. ...
/// text (G6c): STROKE_WGSL with textc.wgsl and text.wgsl behind it (vs_text / fs_text for layers of text alone, vs_text_all
/// / fs_text_all for text among anything else)
TEXT_WGSL: &str = concat!(include_str!("common.wgsl"), include_str!("block. ...
TEXTC_WGSL: &str = include_str!("textc.wgsl")
/// (G6d) the highlight's look (behind the stroke and text shaders: hl_wgsl) and the write pass with highlights (behind
/// CULL_WGSL: write_hl_wgsl)
HL_WGSL: &str = include_str!("hl.wgsl")
HL_WRITE_WGSL: &str = include_str!("hl_write.wgsl")
  • fn hl_wgsl(base: &str) -> alloc::string::String (G6d) the vertex shaders that read the highlight: STROKE_WGSL or TEXT_WGSL with every visible list's word through hl_take, ink through hl_ink, half_width through hl_wider, and hl.wgsl behind them (the entries keep their names: vs, vs_full, vs_fill, vs_text, vs_text_all). The plain sources and their shaders stay as they are

  • fn write_hl_wgsl() -> alloc::string::String (G6d) CULL_WGSL with the write pass that puts the highlight into the visible list (entry write_hl)

COUNT_SPV: &[u32] = spv::COUNT
SCAN_SPV: &[u32] = spv::SCAN
WRITE_SPV: &[u32] = spv::WRITE
INSTANCES_SPV: &[u32] = spv::INSTANCES
SCATTER_SPV: &[u32] = spv::SCATTER
VS_SPV: &[u32] = spv::VS
VS_FULL_SPV: &[u32] = spv::VS_FULL
FS_SPV: &[u32] = spv::FS
FS_FULL_SPV: &[u32] = spv::FS_FULL
VS_FILL_SPV: &[u32] = spv::VS_FILL
FS_FILL_SPV: &[u32] = spv::FS_FILL
VS_TEXT_SPV: &[u32] = spv::VS_TEXT
FS_TEXT_SPV: &[u32] = spv::FS_TEXT
VS_TEXT_ALL_SPV: &[u32] = spv::VS_TEXT_ALL
FS_TEXT_ALL_SPV: &[u32] = spv::FS_TEXT_ALL
/// (G6d) the vertex shaders of hl_wgsl and write_hl
VS_HL_SPV: &[u32] = spv::VS_HL
VS_FULL_HL_SPV: &[u32] = spv::VS_FULL_HL
VS_FILL_HL_SPV: &[u32] = spv::VS_FILL_HL
VS_TEXT_HL_SPV: &[u32] = spv::VS_TEXT_HL
VS_TEXT_ALL_HL_SPV: &[u32] = spv::VS_TEXT_ALL_HL
WRITE_HL_SPV: &[u32] = spv::WRITE_HL
  • struct RendererDesc Renderer::new. Made with new and changed field by field (it may grow)
    • color: Format -- the format of the colour targets: one without sRGB (the codes are blended as they are)
    • frames_in_flight: usize -- frames the CPU may record ahead of the GPU (1 ..= FRAMES_MAX)
    • separate_scratch: Option<bool> -- (G6e3) a render pass of its own, after a barrier, for a run of layers whose fragment shader needs scratch memory (fs_full, fs_fill, fs_text_all, the overlay's fs_fill) when the last such run before it took another pipeline: None decides by the adapter (on for Intel under Vulkan: Mesa's driver gives such shaders of two draws the same scratch memory with their own strides, on Gen9 they overwrote each other's spilled registers; docs/RENDER2D.md "Die anderen Ziele (G6e3)"), Some forces it either way. No pixel changes; on GPUs that draw in tiles each pass costs a store and a load of the target

impl RendererDesc

  • const fn new(color: Format) -> RendererDesc

  • struct Renderer the pipelines of one colour format on one device

impl Renderer

  • fn new(dev: &Device, desc: &RendererDesc) -> Result<Renderer>
  • fn device(&self) -> &Device
  • fn desc(&self) -> &RendererDesc
  • fn multi_draw(&self) -> bool this device draws the visible layers with one multi-draw (level Voll)
  • fn max_records(&self) -> u32 the most records (segments, free places included) a scene's pool can hold on this device
  • fn record<'a>(&'a self, e: &mut CommandEncoder<'a>, s: &'a Scene, color: ColorAttachment<'a>) -> Result<()> one frame of a prepared scene into e: its uploads, its visibility, its render pass (the colour attachment's load and clear as it says, sRGB codes)

Source: docs/API.md in the JFLib repository.