Address review feedback.

* add comment for ClipInp::path_ix
* update comment for SceneBuilder drawtags
* remove copy of blend data through info buffer. Instead, update EndClip's DrawMonoid::scene_offset to point to the same scene data of the associated EndClip.
This commit is contained in:
Chad Brokaw 2022-11-29 14:52:03 -05:00
parent 28082af9ec
commit d13ec497e2
8 changed files with 22 additions and 35 deletions

View file

@ -277,12 +277,12 @@ fn encode_blend_mode(mode: BlendMode) -> u32 {
(mode.mix as u32) << 8 | mode.compose as u32
}
// Tags for draw objects. See shader/drawtag.h for the authoritative source.
// Tags for draw objects. See shader/shared/drawtag.wgsl for the authoritative source.
const DRAWTAG_FILLCOLOR: u32 = 0x44;
const DRAWTAG_FILLLINGRADIENT: u32 = 0x114;
const DRAWTAG_FILLRADGRADIENT: u32 = 0x2dc;
const DRAWTAG_BEGINCLIP: u32 = 0x89;
const DRAWTAG_ENDCLIP: u32 = 0xa1;
const DRAWTAG_BEGINCLIP: u32 = 0x9;
const DRAWTAG_ENDCLIP: u32 = 0x21;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod)]

View file

@ -26,9 +26,6 @@ var<storage, read_write> draw_monoids: array<DrawMonoid>;
@group(0) @binding(6)
var<storage, read_write> clip_bboxes: array<vec4<f32>>;
@group(0) @binding(7)
var<storage, read_write> info: array<u32>;
let WG_SIZE = 256u;
var<workgroup> sh_bic: array<Bic, 510 >;
var<workgroup> sh_stack: array<u32, WG_SIZE>;
@ -69,7 +66,7 @@ fn search_link(bic: ptr<function, Bic>, ix: u32) -> i32 {
}
}
fn load_clip_inp(ix: u32) -> i32 {
fn load_clip_path(ix: u32) -> i32 {
if ix < config.n_clip {
return clip_inp[ix].path_ix;
} else {
@ -131,7 +128,7 @@ fn main(
sh_stack_bbox[local_id.x] = bbox;
// Read input and compute Bic binary tree
let inp = load_clip_inp(global_id.x);
let inp = load_clip_path(global_id.x);
let is_push = inp >= 0;
var bic = Bic(1u - u32(is_push), u32(is_push));
sh_bic[local_id.x] = bic;
@ -193,12 +190,8 @@ fn main(
let parent_ix = parent_clip.ix;
let ix = ~inp;
draw_monoids[ix].path_ix = u32(path_ix);
// Copy blend mode and alpha from parent
let di = draw_monoids[ix].info_offset;
let parent_di = draw_monoids[parent_ix].info_offset;
info[di] = info[parent_di];
info[di + 1u] = info[parent_di + 1u];
// Make EndClip point to the same draw data as BeginClip
draw_monoids[ix].scene_offset = draw_monoids[parent_ix].scene_offset;
if grandparent >= 0 {
bbox = sh_bbox[grandparent];
} else if grandparent + i32(stack_size) >= 0 {

View file

@ -281,8 +281,9 @@ fn main(
var is_blend = false;
if is_clip {
let BLEND_CLIP = (128u << 8u) | 3u;
let di = draw_monoids[drawobj_ix].info_offset;
let blend = info[di];
let scene_offset = draw_monoids[drawobj_ix].scene_offset;
let dd = config.drawdata_base + scene_offset;
let blend = scene[dd];
is_blend = blend != BLEND_CLIP;
}
let include_tile = tile.segments != 0u || (tile.backdrop == 0) == is_clip || is_blend;
@ -347,7 +348,7 @@ fn main(
write_grad(CMD_RAD_GRAD, index, info_offset);
}
// DRAWTAG_BEGIN_CLIP
case 0x89u: {
case 0x9u: {
if tile.segments == 0u && tile.backdrop == 0 {
clip_zero_depth = clip_depth + 1u;
} else {
@ -358,11 +359,11 @@ fn main(
clip_depth += 1u;
}
// DRAWTAG_END_CLIP
case 0xa1u: {
case 0x21u: {
clip_depth -= 1u;
write_path(tile, -1.0);
let blend = info[di];
let alpha = bitcast<f32>(info[di + 1u]);
let blend = scene[dd];
let alpha = bitcast<f32>(scene[dd + 1u]);
write_end_clip(CmdEndClip(blend, alpha));
render_blend_depth -= 1u;
}
@ -372,11 +373,11 @@ fn main(
// In "clip zero" state, suppress all drawing
switch drawtag {
// DRAWTAG_BEGIN_CLIP
case 0x89u: {
case 0x9u: {
clip_depth += 1u;
}
// DRAWTAG_END_CLIP
case 0xa1u: {
case 0x21u: {
if clip_depth == clip_zero_depth {
clip_zero_depth = 0u;
}

View file

@ -170,15 +170,6 @@ fn main(
info[di + 9u] = bitcast<u32>(ra);
info[di + 10u] = bitcast<u32>(roff);
}
// DRAWTAG_BEGIN_CLIP
case 0x89u: {
// Store blend mode and alpha in info for two reasons: 1) we don't need
// to bind scene in clip_leaf which keeps us at 8 buffer bindings and 2)
// the logic in coarse to check clip state for tile inclusion is the
// same for BeginClip/EndClip.
info[di] = scene[dd];
info[di + 1u] = scene[dd + 1u];
}
default: {}
}
}

View file

@ -11,7 +11,11 @@ fn bic_combine(x: Bic, y: Bic) -> Bic {
}
struct ClipInp {
// Index of the draw object.
ix: u32,
// This is a packed encoding of an enum with the sign bit as the tag. If positive,
// this entry is a BeginClip and contains the associated path index. If negative,
// it is an EndClip and contains the bitwise-not of the EndClip draw object index.
path_ix: i32,
}

View file

@ -20,8 +20,8 @@ let DRAWTAG_FILL_COLOR = 0x44u;
let DRAWTAG_FILL_LIN_GRADIENT = 0x114u;
let DRAWTAG_FILL_RAD_GRADIENT = 0x2dcu;
let DRAWTAG_FILL_IMAGE = 0x48u;
let DRAWTAG_BEGIN_CLIP = 0x89u;
let DRAWTAG_END_CLIP = 0xa1u;
let DRAWTAG_BEGIN_CLIP = 0x9u;
let DRAWTAG_END_CLIP = 0x21u;
fn draw_monoid_identity() -> DrawMonoid {
return DrawMonoid();

View file

@ -324,7 +324,6 @@ pub fn render_full(
clip_el_buf,
draw_monoid_buf,
clip_bbox_buf,
info_buf,
],
);
}

View file

@ -212,7 +212,6 @@ pub fn full_shaders(device: &Device, engine: &mut Engine) -> Result<FullShaders,
BindType::BufReadOnly,
BindType::Buffer,
BindType::Buffer,
BindType::Buffer,
],
)?;
let binning = engine.add_shader(