Skip to content

Instantly share code, notes, and snippets.

@raphlinus
raphlinus / nonuniform.wgsl
Created November 4, 2022 14:52
Trivial example of a shader which should fail uniformity analysis
@compute @workgroup_size(256)
fn main(@builtin(local_invocation_id) local_id: vec3<u32>) {
if local_id.x < 5u {
workgroupBarrier();
}
}
@raphlinus
raphlinus / coarse.wgsl
Created October 7, 2022 01:41
Partially translated coarse.comp to wgsl
struct Alloc {
offset : u32,
}
struct BinInstanceRef {
offset : u32,
}
struct BinInstance {
@raphlinus
raphlinus / v-post-truth.md
Created July 4, 2022 14:14
Discussion draft of possible blog post

V: A post-truth language project

This is ordinarily something I'd write on my blog, and I might still, but I'm feeling cautious for reasons that will become clear.

It's often said that we live in a "post-truth" society. This is usually said in the context of politics, fake reviews, etc., and is adjacent to discussions of disinformation, also often connected to the threat of deepfakes and the potential of large language models to produce persuasive text. Even in science there is a replication crisis, and a disturbing amount of straight-up fraud, as documented by Dr. Elisabeth Bik and friends. But it's far more unusual for a programming language to be so characterized. Meet V.

The programming language space is known for passionate discussions which often come down to values, because the space is one of tradeoffs. Want safety (which I believe is related to religious-like concepts of purity and contamination)? Sure, but you have to decide whether you're willing to give up performance

@raphlinus
raphlinus / not_too_clever.md
Created June 23, 2022 00:50
Translation of grugbrain.dev into English

The not-too-clever programmer

This is a translation of grugbrain.dev into clear English. All props to the original author.

Introduction

This is a collection of thoughts on software development, originally written by an pseudonymous author styling themselves the "grug brain developer," but then translated into clear English by Raph Levien.

I am not an extremely smart developer, but I have many years of experience and have learned some things, although still don't know everything.

@raphlinus
raphlinus / iterhash.swift
Last active May 28, 2022 05:03
SwiftUI code for comparing virtual scrolling performance
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Scrolling test case by Raph Levien
import SwiftUI
import CryptoKit
struct ContentView: View {
var body: some View {
@raphlinus
raphlinus / inconsistent_corr.test
Created January 17, 2022 17:57
An inconsistent execution exists for this litmus test
NEWWG
NEWSG
NEWTHREAD
st.atom.scopedev.sc0 x = 2
NEWWG
NEWSG
NEWTHREAD
st.atom.scopedev.sc0 x = 1
NEWWG
NEWSG
@raphlinus
raphlinus / nonatomic_corr.test
Created January 15, 2022 18:18
Non-atomic CoRR litmus test for Vulkan memory model
NEWWG
NEWSG
NEWTHREAD
st.atom.scopedev.sc0 x = 1
NEWWG
NEWSG
NEWTHREAD
ld.atom.scopedev.sc0 x = 1
ld.scopedev.sc0 x
NOSOLUTION consistent[X] && #X.dr=0
@raphlinus
raphlinus / pathseg.md
Created November 26, 2021 19:10
Draft of path segment encoding description, will go into next PR

Path segment encoding

The new (November 2021) element processing pipeline has a particularly clever approach to path segment encoding, and this document explains that.

By way of motivation, in the old scene encoding, all elements take a fixed amount of space, currently 36 bytes, but that's at risk of expanding if a new element type requires even more space. The new design is based on stream compaction. The input is separated into multiple streams, so in particular path segment data gets its own stream. Further, that stream can be packed.

As explained in [#119], the path stream is separated into one stream for tag bytes, and another stream for the path segment data.

Prefix sum for unpacking

@raphlinus
raphlinus / k4_clip
Created April 28, 2021 15:41
Adreno 640 piet-gpu kernel4 disassembly listings, see https://github.com/linebender/piet-gpu/issues/83
:1:0257:0257[20554002x_00000001x] mov.s32s32 r0.z, 1
:0:0258:0258[00000500x_00000000x] (rpt5)nop
:6:0259:0264[c0260202x_02618001x] ldib.untyped.1d.u32.1.imm r0.z, r0.z, 1
:2:0260:0265[52b400f8x_20000002x] (sy)cmps.s.eq p0.x, r0.z, 0
:1:0261:0266[20044906x_000000cfx] (rpt1)mov.f32f32 r1.z, (r)r51.w
:0:0262:0268[00000300x_00000000x] (rpt3)nop
:0:0263:0272[00900000x_0000057cx] br !p0.x, #1404
:1:0264:0273[20554002x_00000002x] mov.s32s32 r0.z, 2
:1:0265:0274[20554003x_00000000x] mov.s32s32 r0.w, 0
:0:0266:0275[00000200x_00000000x] (rpt2)nop
@raphlinus
raphlinus / lasagna.md
Last active May 31, 2022 13:30
Sketch of ideas for lasagna architecture

Pure lasagna:

trait AppLogic {
    fn run(&mut self, actions: Vec<(Id, Box<dyn Any>)>) -> Mutation;
}

A callback based approach to the actions: