Skip to content

Instantly share code, notes, and snippets.

@scott-wilson
scott-wilson / heat.wgsl
Last active October 3, 2023 04:27
I am trying to build a Python library that uses Rust and WGPU to do some computation in the GPU, but the code is panicking when I create the bind group with the error `Buffer (0, 1, Vulkan) is still mapped` after the texture to buffer queue submit.
@group(0) @binding(0) var input_meta_texture: texture_3d<u32>;
@group(0) @binding(1) var input_heat_texture: texture_3d<f32>;
@group(0) @binding(2) var output_heat_texture: texture_storage_3d<r32float, write>;
@compute
@workgroup_size(4, 4, 4)
fn heat_main(
@builtin(global_invocation_id) global_id: vec3<u32>
) {
let dimensions = textureDimensions(input_meta_texture);
#include <Imath/half.h>
namespace cppmm_bind
{
namespace IMATH_NAMESPACE
{
class __attribute__((annotate("cppmm:opaquebytes"))) half {
half() __attribute__((annotate("cppmm:rename:create_default")));
half(float f) __attribute__((annotate("cppmm:rename:create_from_float")));
~half() __attribute__((annotate("cppmm:rename:delete")));
import random
from maya import cmds
def get_new_name(prefix, suffixes):
names = []
rand_value = random.randrange(10000, 20000)
for suffix in suffixes:
names.append("{}_{}_{}".format(prefix, rand_value, suffix))

Hey, I have a question. I want to build something like the following. I have a trait that defines a bundle. The bundle is a bundle of chunks that can either come from a file, or a cache of chunks (more files). I could store the chunks in a vector in the bundle, but if I have really large files, then the amount of RAM used gets pretty huge, so I want to implement an iterator that can either read from the file and return the chunk, or read from the chunk cache and return the chunk. Right now I'm trying to define something like the following:

trait Bundle {
    fn id(&self) -> &ID;
    fn size(&self) -> u64;
    fn chunks<I: Iterator>(&self) -> Result<I, Error>;
}

pub struct FileBundle<P: AsRef<Path>> {

Keybase proof

I hereby claim:

  • I am scott-wilson on github.
  • I am propersquid (https://keybase.io/propersquid) on keybase.
  • I have a public key whose fingerprint is 9E0E 2DD9 E358 B735 B04C 0E32 EE31 90E1 D4FE 7818

To claim this, I am signing this object:

@scott-wilson
scott-wilson / robot.gd
Created December 11, 2016 19:27
Movement controller for a character
extends KinematicBody2D
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
var velocity = Vector2()
const WALK_SPEED = 200.0
func _ready():
# Called every time the node is added to the scene.
@scott-wilson
scott-wilson / abstraction_example.py
Created February 14, 2016 18:31
Example for abstracting away code
import random
# An ugly way to get which 3d package you're in.
try:
from maya import cmds
_IN_MAYA = True
except ImportError:
_IN_MAYA = False
try:
class Foo(object):
def __init__(self, value):
self._value = value
class Bar(Foo):
def __init__(self, value):
value = do_something_to_value(value)
# Calls the parent class's version of __init__.
import numpy as np
import matplotlib.pyplot as plt
w = 400
h = 300
def normalize(x):
x /= np.linalg.norm(x)
return x
# blender_version_save.py (c) 2013 Scott Wilson (ProperSquid)
#
# ***** BEGIN GPL LICENSE BLOCK *****
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#