Skip to content

Instantly share code, notes, and snippets.

View lachlansneff's full-sized avatar

Lachlan Sneff lachlansneff

View GitHub Profile
#![feature(
allocator_api,
slice_ptr_get,
slice_ptr_len,
ptr_metadata,
maybe_uninit_uninit_array,
)]
use core::{
alloc::{Layout, AllocError},
use core::{
ops::{Shr, ShrAssign, Shl, ShlAssign, BitOr, BitOrAssign},
hash::Hash,
fmt,
};
macro_rules! impl_uint {
($int_ty:ty: [$($bits:literal),*]) => {
$(
impl Uint for u<$bits> {
use std::{
cell::UnsafeCell,
fmt::{self, Debug},
marker::PhantomData,
mem::self,
ops::{Deref, DerefMut},
ptr::NonNull,
};
use std::ops::{Add, Sub, SubAssign, Mul, Div, Neg, BitOr, BitOrAssign, BitAnd, BitAndAssign};
use std::mem;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub enum Op {
Const(f32),
X,
Y,
Z,
#version 450
layout(location = 0) in vec4 Vertex_Position;
layout(location = 1) in uvec4 Vertex_Normal;
layout(location = 2) in uvec4 I_TestInstancing_Property;
layout(location = 0) out vec4 v_Position;
layout(set = 0, binding = 0) uniform Camera {
mat4 ViewProj;
};
layout(set = 1, binding = 0) uniform texture2D Texture;
use crossbeam_queue::SegQueue;
use futures::{
future::FutureExt,
stream::{FuturesUnordered, StreamExt},
};
use std::{future::Future, pin::Pin, sync::Arc};
type Fut = Pin<Box<dyn Future<Output = Result<wgpu::Buffer, wgpu::BufferAsyncError>>>>;
pub struct StagedBuffer {
// use ...
pub unsafe trait AllocOwner {
fn owns(&self, ptr: NonNull<u8>, layout: Layout) -> bool;
}
#[derive(Default)]
pub struct Local<A> {
allocator: UnsafeCell<A>,
}
pub trait Module {
fn id(&self) -> usize;
}
macro_rules! register {
($( $vis:vis static $name:ident: $t:ty = $e:expr; )*) => {
$(
#[used]
$vis static $name: $t = {
#![feature(const_type_id, gen_future, const_fn)]
use std::any::TypeId;
use std::future::get_task_context;
// ...
// /// Information about the currently-running task.
// ///
// /// Contexts are always tied to the stack, since they are set up specifically
pub struct Function<'a> {
signature: &'a FuncSig,
module: &'a ModuleInner,
instance_inner: &'a mut InstanceInner,
func_index: FuncIndex,
}