Skip to content

Instantly share code, notes, and snippets.

View hasenbanck's full-sized avatar

Nils Hasenbanck hasenbanck

  • Hamburg, Germany
View GitHub Profile
layout(push_constant) uniform VertexConstants {
mat4 mvp;
} pc;
@hasenbanck
hasenbanck / upsert_for_hecs.rs
Created July 6, 2020 16:39
Simple `upsert` implementation for the rust ECS hecs
/// Trait to extend hecs to support upsert operations.
/// ```rust
/// use Upsert;
/// let mut world = hecs::World::new();
/// struct s(u32);
///
/// world.upsert(player_entity, |mut c| c.0 = 42, s(42))?;
/// ```
pub trait Upsert {
fn upsert<F, T: 'static>(&mut self, entity: Entity, update: F, insert: T) -> Result<()>
@hasenbanck
hasenbanck / gist:dbf203ed74de8f840e6cff5f2cd2b907
Created June 17, 2020 15:18
4096x4096 cubemaps (6 sides)
Jun 17 17:16:20.907 WARN gfx_memory::heaps: Unable to allocate 67108864 with Linear: TooManyObjects
Jun 17 17:16:20.926 WARN gfx_memory::heaps: Unable to allocate 67108864 with Linear: TooManyObjects
Jun 17 17:16:20.946 WARN gfx_memory::heaps: Unable to allocate 67108864 with Linear: TooManyObjects
Jun 17 17:16:20.964 WARN gfx_memory::heaps: Unable to allocate 67108864 with Linear: TooManyObjects
Jun 17 17:16:20.986 WARN gfx_memory::heaps: Unable to allocate 67108864 with Linear: TooManyObjects
Jun 17 17:16:21.005 WARN gfx_memory::heaps: Unable to allocate 67108864 with Linear: TooManyObjects
Jun 17 17:16:21.098 ERROR gfx_backend_vulkan:
VALIDATION [VUID-vkDestroyFramebuffer-framebuffer-00892 (-617577710)] : Validation Error: [ VUID-vkDestroyFramebuffer-framebuffer-00892 ] Object 0: handle = 0x29000ff2d40, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xdb308312 | Cannot call vkDestroyFramebuffer on VkFramebuffer 0xaf4278000000005d[] that is currently in use by a command buffer. T
@hasenbanck
hasenbanck / shader.vert
Created June 13, 2020 15:11
GLSL: shader.vert:3: error: '' : syntax error, unexpected IDENTIFIER
layout(set=0, binding=1)
buffer Instances {
InstanceData i_data[];
};
struct InstanceData {
mat4 mvp; // MVP matrice
mat4 model; // Model matrice
};
@hasenbanck
hasenbanck / bash output
Last active June 11, 2020 11:27
Instanced rendering with vertex arrays
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Stage { flag: VERTEX, error: Input { location: 4, error: WrongType } }', C:\Users\Username\.cargo\git\checkouts\wgpu-rs-40ea39809c03c5d8\7b866b1\src\backend\direct.rs:460:9
@hasenbanck
hasenbanck / gist:1e40681b7d74e942a0dd21de8d97bc5e
Created August 8, 2018 06:53
How to use the Backup SRAM of a STM32F7 / STM32
This might also work for other STM32 chips. I use the HAL, so it also might be supported by your chip.
To use the Backup SRAM (most of the time 4 Kb), you need to add a backup power source (like a battery or a supercap)
to the VBAT pin of your STM32. I use a simple CR2032 battery.
Use following code to get access to the Backup SRAM:
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_BKPSRAM_CLK_ENABLE();
@hasenbanck
hasenbanck / gist:31f74926b92c3abf01944911adeb99fd
Created May 23, 2017 05:38 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt