Skip to content

Instantly share code, notes, and snippets.

View cwfitzgerald's full-sized avatar
:octocat:
We should count LOC as "lines spent" not "lines produced" - Dijkstra

Connor Fitzgerald cwfitzgerald

:octocat:
We should count LOC as "lines spent" not "lines produced" - Dijkstra
View GitHub Profile
unsafe trait VulkanInstanceInitializationCallbacks {
/// Given the list of available instance extensions, you can extend the list of extensions
/// that are requested.
///
/// # SAFETY
///
/// - All extensions in `requested_extensions` must be in `available_extensions`.
fn extend_instance_extensions<'a>(
&'a mut self,
fn low(a: u32) -> u32 {
a & 0xFFFF
}
fn high(a: u32) -> u32 {
a >> 16
}
fn splice(w1: u32, w0: u32) -> u32 {
Requirement "maxPerStageDescriptorSamplers >= 1024" loses 51 (and partially loses 5) further deviceNames:
In ALL reports (51 deviceNames):
x AMD Radeon Pro 560: 1 (34781)
x AMD Radeon Pro 560X: 1 (33962)
x AMD Radeon R9 M290X: 1 (33801)
x Apple A15 GPU: 3 (33774 34008 34289)
x Apple A16 GPU: 3 (33762 33830 34432)
x Apple A17 Pro GPU: 1 (34786)
x Apple A18 Pro GPU: 1 (34726)
x Apple M1: 7 (33858 34007 34214 34496 34528 34753 34852)
use std::{collections::VecDeque, ffi::c_void, mem};
use anyhow::Context;
use arrayvec::ArrayVec;
use glam::UVec2;
use windows::{
core::Interface,
Win32::{
Foundation::*,
Graphics::{
@cwfitzgerald
cwfitzgerald / main.rs
Created May 20, 2024 13:37
D3D12/SDL2 Init
use glam::UVec2;
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use sdl2::{
event::{Event, WindowEvent},
keyboard::Keycode,
};
use windows::Win32::Foundation::HWND;
#[no_mangle]
pub static D3D12SDKVersion: u32 = 614;
@cwfitzgerald
cwfitzgerald / convert.py
Created April 20, 2022 16:57
BC7-ifier
import argparse
import json
import os
import subprocess
from pathlib import Path
parser = argparse.ArgumentParser(
description="Process gltf into rust-compatible format")
parser.add_argument('file', type=Path)
parser.add_argument('--force', type=bool)
let iad = pollster::block_on(rend3::create_iad(
None,
None,
Some(RendererMode::CPUPowered),
))
.unwrap();
let vert = iad.device.create_shader_module(&ShaderModuleDescriptor {
label: Some("vert"),
source: ShaderSource::Wgsl(
@cwfitzgerald
cwfitzgerald / compress.py
Created November 24, 2021 14:47
Turns a normal gltf into a compressonatored gltf
import argparse
import json
import os
import subprocess
from pathlib import Path
parser = argparse.ArgumentParser(
description="Process gltf into rust-compatible format")
parser.add_argument('file', type=Path)
parser.add_argument('--force', type=bool)
@cwfitzgerald
cwfitzgerald / gist:d538f8f488b5a4da6b479c2c3709d892
Created October 17, 2021 00:24
graphite's list of nv shader recompily
# Things that trigger shader recompiles on NVIDIA GL
* Respecifying input assembly via `glVertexAttrib*` for any vertex array
* Clearing an individual color attachment with `glClearBuffer*`
* Clearing an FBO with `glClear` without specifying all attachments in
the clear, e.g if the FBO has color + depth but you only pass `GL_COLOR_BUFFER_BIT`
* Attaching shaders to a program
* Changing sampler uniforms (all textures are bindless on NV, changing sampler index is bad)
* Respecifying `glClearColor` more than once per frame per FBO
* Changing depth function more than once per bound program
@cwfitzgerald
cwfitzgerald / libconv.rs
Created September 24, 2021 17:41
Mint Workaround
use nalgebra as na;
macro_rules! conversions {
($trait1:ident, $conv1:ident, $trait2:ident, $conv2:ident, $(($src:ty, $mint:ty, $dst:ty)),* $(,)?) => {
$(
impl $trait1 for $src {
type Target = $dst;
fn $conv1(self) -> Self::Target {
let m: $mint = self.into();
m.into()