From 9be0faba6fd45afe8b830a96c37f035aac233d00 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 27 Sep 2020 18:57:53 +0200 Subject: [PATCH] piet-gpu-types: remove unused scene elements Delete image compute shader as well; it is unused. Signed-off-by: Elias Naur --- piet-gpu-types/src/scene.rs | 50 -------- piet-gpu/shader/build.ninja | 2 - piet-gpu/shader/image.comp | 54 --------- piet-gpu/shader/image.spv | Bin 8116 -> 0 bytes piet-gpu/shader/scene.h | 236 ------------------------------------ 5 files changed, 342 deletions(-) delete mode 100644 piet-gpu/shader/image.comp delete mode 100644 piet-gpu/shader/image.spv diff --git a/piet-gpu-types/src/scene.rs b/piet-gpu-types/src/scene.rs index 5e4899f..0d72650 100644 --- a/piet-gpu-types/src/scene.rs +++ b/piet-gpu-types/src/scene.rs @@ -1,60 +1,10 @@ use piet_gpu_derive::piet_gpu; -pub use self::scene::{ - Bbox, PietCircle, PietFill, PietItem, PietStrokeLine, PietStrokePolyLine, Point, SimpleGroup, -}; - pub use self::scene::{CubicSeg, Element, Fill, LineSeg, QuadSeg, SetLineWidth, Stroke, Transform}; piet_gpu! { #[rust_encode] mod scene { - struct Bbox { - bbox: [i16; 4], - } - struct Point { - xy: [f32; 2], - } - struct SimpleGroup { - n_items: u32, - // Note: both of the following items are actually arrays - items: Ref, - bboxes: Ref, - offset: Point, - } - struct PietCircle { - rgba_color: u32, - center: Point, - radius: f32, - } - struct PietStrokeLine { - flags: u32, - rgba_color: u32, - width: f32, - start: Point, - end: Point, - } - struct PietFill { - flags: u32, - rgba_color: u32, - n_points: u32, - points: Ref, - } - struct PietStrokePolyLine { - rgba_color: u32, - width: f32, - n_points: u32, - points: Ref, - } - enum PietItem { - Group(SimpleGroup), - Circle(PietCircle), - Line(PietStrokeLine), - Fill(PietFill), - Poly(PietStrokePolyLine), - } - - // New approach follows (above to be deleted) struct LineSeg { p0: [f32; 2], p1: [f32; 2], diff --git a/piet-gpu/shader/build.ninja b/piet-gpu/shader/build.ninja index 13fb1b2..cce8615 100644 --- a/piet-gpu/shader/build.ninja +++ b/piet-gpu/shader/build.ninja @@ -7,8 +7,6 @@ glslang_validator = glslangValidator rule glsl command = $glslang_validator -V -o $out $in -build image.spv: glsl image.comp | scene.h - build elements.spv: glsl elements.comp | scene.h state.h annotated.h diff --git a/piet-gpu/shader/image.comp b/piet-gpu/shader/image.comp deleted file mode 100644 index 6d84eb5..0000000 --- a/piet-gpu/shader/image.comp +++ /dev/null @@ -1,54 +0,0 @@ -// A simple kernel to create an image. - -// Right now, this kernel stores the image in a buffer, but a better -// plan is to use a texture. This is because of limited support. - -#version 450 -#extension GL_GOOGLE_include_directive : enable - -layout(local_size_x = 16, local_size_y = 16) in; - -layout(set = 0, binding = 0) readonly buffer SceneBuf { - uint[] scene; -}; - -layout(set = 0, binding = 1) buffer ImageBuf { - uint[] image; -}; - -#include "scene.h" - -// TODO: make the image size dynamic. -#define IMAGE_WIDTH 2048 -#define IMAGE_HEIGHT 1535 - -void main() { - uvec2 xy_uint = gl_GlobalInvocationID.xy; - vec2 xy = vec2(xy_uint); - vec2 uv = xy * vec2(1.0 / IMAGE_WIDTH, 1.0 / IMAGE_HEIGHT); - vec3 rgb = uv.xyy; - - // Render the scene. Right now, every pixel traverses the scene graph, - // which is horribly wasteful, but the goal is to get *some* output and - // then optimize. - - SimpleGroup group = PietItem_Group_read(PietItemRef(0)); - for (uint i = 0; i < group.n_items; i++) { - PietItemRef item_ref = PietItem_index(group.items, i); - uint tag = PietItem_tag(item_ref); - tag = PietItem_Circle; - if (tag == PietItem_Circle) { - PietCircle circle = PietItem_Circle_read(item_ref); - float r = length(xy + vec2(0.5, 0.5) - circle.center.xy); - float alpha = clamp(0.5 + circle.radius - r, 0.0, 1.0); - vec4 fg_rgba = unpackUnorm4x8(circle.rgba_color); - // TODO: sRGB - rgb = mix(rgb, fg_rgba.rgb, alpha * fg_rgba.a); - } - } - - // TODO: sRGB - uvec4 s = uvec4(round(vec4(rgb, 1.0) * 255.0)); - uint rgba_packed = s.r | (s.g << 8) | (s.b << 16) | (s.a << 24); - image[xy_uint.y * IMAGE_WIDTH + xy_uint.x] = rgba_packed; -} diff --git a/piet-gpu/shader/image.spv b/piet-gpu/shader/image.spv deleted file mode 100644 index 097add185fc152cd7131529812585e68b2eebfd6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8116 zcmaKv32I@<-hzc$!F2xx|XIyZ`1x73`DDEh(xS_a#%BFz7-+lMw-NqR&IsN|s|2g0J&bQtB zXc)g_Vv>wYCh_0-iF!;~UsabhTM2mODy9&jzw5$-R(5G9_u-R&3k8y=~h$#m<3&;!t&OPr2Ar=_?nz zDudl8#Eb+FmX9UR2(lR;lLGzkBykxtb6) zo&V}_#Y$gSd1Tp8b#S<|x+>Ru)o@G8hT)bC#5Pj@RN6suI_@-Z+AZ}pvL58?uk=+N zl*iRk^Qn(pNM^&+I9gXq?lZF2F{UK*z^T7DST1#q)|6#V3rcI5OI)p%3CWS*9hKgJ zo^sn@|L{Osf#a+DzG+wgh(X54ed;ld$pUyTUmB<8(^sspvO}Yqds|a#b2iR> z-o+T@p}OYDsgE%|Sp?6GamZ|QI%U@9ypTRI=O(Z_wYf6b*;7uZoYti7Qy;4_Sq!ho zTGND7Gj6bZSE<<9-_t)>tJPTN)LHJUmUEhO8Z32HhMAM+=U8|>=ON|S<^9_zo7ZylHs!E~xnosneRTEmdkcE&!9m z(o)|gv@CUschbgKUEumyg``sBS-(Q!iwOV8G-=;q+FG7May@vUG+64*d^gZW-kZSr zyf@eQDKu%G+h`-t9pHMNLUQ*Qe$Nmj@$c^uBMOmjbRh_8@51Mf`lU2W`V5Aio7&%wDmY2OK4rc%$qWu=VI zg75AwdhPHxB#Ys-b!|*mg46prQ0lzA+=ag}*@)KOTk6iAB{iRlI<0wHGp&uaa2+RL z1#Aod#@X|IxP|E8OW;0j^jGs8Wq;45?*X6S%{7{GzjJ;Ij?VmNGIo8uTFr*%^ILP| zx7K`qc{A}eY5r{h^U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` zTZ8YXt@J-njCpU3w?;MNo?~~{V*VcT{qDQnX9{*YaehChX4rSYG|V$TgEs0s6>LoY zy>J>_J!(1~Y~PsgIpOzh z-)+`>CRWQ;ueHm=w>{PCc`t;kdDbHDMc~M*Kl<(f>oc!wAP?V*!H#t$ zYv}v)C74?HUkbKQ_+JKA>tH?n_PrdlkGkvVck&gOYwP?RQ*N9&-OpEI`rT`B?DYch zBFyJ#%)OpZyAX4)kD-md-U-g{b=MeP8N>T>yb2!9anIBB8IQA2f;(>hEbM}-$64qE ztHoK^308}>D}&YI-0udf<Nw^@Dd}k@wYLwE-;7*dRFa>W{udV14Fwt>xj{19lFvwpV~%|2Q9VVo9d|@;u4?{pp#112zv+cbto9--ubqKFmIH z$zt%an9mZ-d(uq16!V@OM;rI#2JpljziAA=Imd4W-- zIP&U`zV89+Gp}nR58r#ijumV0KCtWL8W=A(Cj9RQk6oh=psB~4KL}R49gFkxA+WkR z@1T{(`S~!|^P?W;=ObY2hG%AJ zjJ!<_jSS@O80)GWl Vw^nn?> 2; - uint raw0 = scene[ix + 0]; - uint raw1 = scene[ix + 1]; - Bbox s; - s.bbox = ivec4(int(raw0 << 16) >> 16, int(raw0) >> 16, int(raw1 << 16) >> 16, int(raw1) >> 16); - return s; -} - -Point Point_read(PointRef ref) { - uint ix = ref.offset >> 2; - uint raw0 = scene[ix + 0]; - uint raw1 = scene[ix + 1]; - Point s; - s.xy = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1)); - return s; -} - -SimpleGroup SimpleGroup_read(SimpleGroupRef ref) { - uint ix = ref.offset >> 2; - uint raw0 = scene[ix + 0]; - uint raw1 = scene[ix + 1]; - uint raw2 = scene[ix + 2]; - SimpleGroup s; - s.n_items = raw0; - s.items = PietItemRef(raw1); - s.bboxes = BboxRef(raw2); - s.offset = Point_read(PointRef(ref.offset + 12)); - return s; -} - -PietCircle PietCircle_read(PietCircleRef ref) { - uint ix = ref.offset >> 2; - uint raw0 = scene[ix + 0]; - uint raw3 = scene[ix + 3]; - PietCircle s; - s.rgba_color = raw0; - s.center = Point_read(PointRef(ref.offset + 4)); - s.radius = uintBitsToFloat(raw3); - return s; -} - -PietStrokeLine PietStrokeLine_read(PietStrokeLineRef ref) { - uint ix = ref.offset >> 2; - uint raw0 = scene[ix + 0]; - uint raw1 = scene[ix + 1]; - uint raw2 = scene[ix + 2]; - PietStrokeLine s; - s.flags = raw0; - s.rgba_color = raw1; - s.width = uintBitsToFloat(raw2); - s.start = Point_read(PointRef(ref.offset + 12)); - s.end = Point_read(PointRef(ref.offset + 20)); - return s; -} - -PietFill PietFill_read(PietFillRef ref) { - uint ix = ref.offset >> 2; - uint raw0 = scene[ix + 0]; - uint raw1 = scene[ix + 1]; - uint raw2 = scene[ix + 2]; - uint raw3 = scene[ix + 3]; - PietFill s; - s.flags = raw0; - s.rgba_color = raw1; - s.n_points = raw2; - s.points = PointRef(raw3); - return s; -} - -PietStrokePolyLine PietStrokePolyLine_read(PietStrokePolyLineRef ref) { - uint ix = ref.offset >> 2; - uint raw0 = scene[ix + 0]; - uint raw1 = scene[ix + 1]; - uint raw2 = scene[ix + 2]; - uint raw3 = scene[ix + 3]; - PietStrokePolyLine s; - s.rgba_color = raw0; - s.width = uintBitsToFloat(raw1); - s.n_points = raw2; - s.points = PointRef(raw3); - return s; -} - -uint PietItem_tag(PietItemRef ref) { - return scene[ref.offset >> 2]; -} - -SimpleGroup PietItem_Group_read(PietItemRef ref) { - return SimpleGroup_read(SimpleGroupRef(ref.offset + 4)); -} - -PietCircle PietItem_Circle_read(PietItemRef ref) { - return PietCircle_read(PietCircleRef(ref.offset + 4)); -} - -PietStrokeLine PietItem_Line_read(PietItemRef ref) { - return PietStrokeLine_read(PietStrokeLineRef(ref.offset + 4)); -} - -PietFill PietItem_Fill_read(PietItemRef ref) { - return PietFill_read(PietFillRef(ref.offset + 4)); -} - -PietStrokePolyLine PietItem_Poly_read(PietItemRef ref) { - return PietStrokePolyLine_read(PietStrokePolyLineRef(ref.offset + 4)); -} - LineSeg LineSeg_read(LineSegRef ref) { uint ix = ref.offset >> 2; uint raw0 = scene[ix + 0];