From f13781a8784af6d210a700b615e7c4fd73824e1e Mon Sep 17 00:00:00 2001 From: Ben Hansen Date: Wed, 29 Dec 2021 11:20:29 -0700 Subject: [PATCH] more work on alignment page --- docs/.vuepress/styles/index.styl | 2 +- docs/showcase/alignment/README.md | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/.vuepress/styles/index.styl b/docs/.vuepress/styles/index.styl index 96066c19..c394e284 100644 --- a/docs/.vuepress/styles/index.styl +++ b/docs/.vuepress/styles/index.styl @@ -11,7 +11,7 @@ excerpt(radius) { margin-bottom 1rem } -.warning { +.warning, .warn { background-color $warningColor color $warningTextColor excerpt(6px) diff --git a/docs/showcase/alignment/README.md b/docs/showcase/alignment/README.md index 2d5efa3f..b6aa73b7 100644 --- a/docs/showcase/alignment/README.md +++ b/docs/showcase/alignment/README.md @@ -1,5 +1,12 @@ # Memory Layout in WGSL +
+ +This page is currently being reworked. I want to understand the topics a bit better, but +as 0.12 is out I want to release what I have for now. + +
+ ## Alignment of vertex and index buffers Vertex buffers require defining a `VertexBufferLayout`, so the memory alignment is whatever @@ -85,9 +92,20 @@ struct LightUniform { But this won't compile. The [bytemuck crate](https://docs.rs/bytemuck/) doesn't work with structs with implicit padding bytes. Rust can't guarantee that the memory between the fields -has been initialized properly. The are potential security +has been initialized properly. This gave be an error when I tried it: + +``` +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> code/intermediate/tutorial10-lighting/src/main.rs:246:8 + | +246 | struct LightUniform { + | ^^^^^^^^^^^^ + | + = note: source type: `LightUniform` (256 bits) + = note: target type: `_::{closure#0}::TypeWithoutPadding` (192 bits) +``` -## In WGPU +