Skip to content

Commit 7f9ab97

Browse files
bors[bot]unconed
andcommitted
Merge #86
86: Add vertex formats r=kvark a=unconed Add the vertex formats from: https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl Co-authored-by: Steven Wittens <[email protected]>
2 parents 22143f3 + cf3e1a5 commit 7f9ab97

File tree

5 files changed

+152
-20
lines changed

5 files changed

+152
-20
lines changed

gfx-examples/src/cube.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ impl framework::Example for Example {
308308
attributes: &[
309309
wgpu::VertexAttributeDescriptor {
310310
attribute_index: 0,
311-
format: wgpu::VertexFormat::FloatR32G32B32A32,
311+
format: wgpu::VertexFormat::Float4,
312312
offset: 0,
313313
},
314314
wgpu::VertexAttributeDescriptor {
315315
attribute_index: 1,
316-
format: wgpu::VertexFormat::FloatR32G32,
316+
format: wgpu::VertexFormat::Float2,
317317
offset: 4 * 4,
318318
},
319319
],

gfx-examples/src/shadow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,12 @@ impl framework::Example for Example {
389389
attributes: &[
390390
wgpu::VertexAttributeDescriptor {
391391
attribute_index: 0,
392-
format: wgpu::VertexFormat::IntR8G8B8A8,
392+
format: wgpu::VertexFormat::Char4,
393393
offset: 0,
394394
},
395395
wgpu::VertexAttributeDescriptor {
396396
attribute_index: 1,
397-
format: wgpu::VertexFormat::IntR8G8B8A8,
397+
format: wgpu::VertexFormat::Char4,
398398
offset: 4 * 1,
399399
},
400400
],

wgpu-bindings/wgpu.h

+49-5
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,55 @@ typedef enum {
187187
} WGPUTextureViewDimension;
188188

189189
typedef enum {
190-
WGPUVertexFormat_FloatR32G32B32A32 = 0,
191-
WGPUVertexFormat_FloatR32G32B32 = 1,
192-
WGPUVertexFormat_FloatR32G32 = 2,
193-
WGPUVertexFormat_FloatR32 = 3,
194-
WGPUVertexFormat_IntR8G8B8A8 = 4,
190+
WGPUVertexFormat_Uchar = 0,
191+
WGPUVertexFormat_Uchar2 = 1,
192+
WGPUVertexFormat_Uchar3 = 2,
193+
WGPUVertexFormat_Uchar4 = 3,
194+
WGPUVertexFormat_Char = 4,
195+
WGPUVertexFormat_Char2 = 5,
196+
WGPUVertexFormat_Char3 = 6,
197+
WGPUVertexFormat_Char4 = 7,
198+
WGPUVertexFormat_UcharNorm = 8,
199+
WGPUVertexFormat_Uchar2Norm = 9,
200+
WGPUVertexFormat_Uchar3Norm = 10,
201+
WGPUVertexFormat_Uchar4Norm = 11,
202+
WGPUVertexFormat_Uchar4NormBgra = 12,
203+
WGPUVertexFormat_CharNorm = 13,
204+
WGPUVertexFormat_Char2Norm = 14,
205+
WGPUVertexFormat_Char3Norm = 15,
206+
WGPUVertexFormat_Char4Norm = 16,
207+
WGPUVertexFormat_Ushort = 17,
208+
WGPUVertexFormat_Ushort2 = 18,
209+
WGPUVertexFormat_Ushort3 = 19,
210+
WGPUVertexFormat_Ushort4 = 20,
211+
WGPUVertexFormat_Short = 21,
212+
WGPUVertexFormat_Short2 = 22,
213+
WGPUVertexFormat_Short3 = 23,
214+
WGPUVertexFormat_Short4 = 24,
215+
WGPUVertexFormat_UshortNorm = 25,
216+
WGPUVertexFormat_Ushort2Norm = 26,
217+
WGPUVertexFormat_Ushort3Norm = 27,
218+
WGPUVertexFormat_Ushort4Norm = 28,
219+
WGPUVertexFormat_ShortNorm = 29,
220+
WGPUVertexFormat_Short2Norm = 30,
221+
WGPUVertexFormat_Short3Norm = 31,
222+
WGPUVertexFormat_Short4Norm = 32,
223+
WGPUVertexFormat_Half = 33,
224+
WGPUVertexFormat_Half2 = 34,
225+
WGPUVertexFormat_Half3 = 35,
226+
WGPUVertexFormat_Half4 = 36,
227+
WGPUVertexFormat_Float = 37,
228+
WGPUVertexFormat_Float2 = 38,
229+
WGPUVertexFormat_Float3 = 39,
230+
WGPUVertexFormat_Float4 = 40,
231+
WGPUVertexFormat_Uint = 41,
232+
WGPUVertexFormat_Uint2 = 42,
233+
WGPUVertexFormat_Uint3 = 43,
234+
WGPUVertexFormat_Uint4 = 44,
235+
WGPUVertexFormat_Int = 45,
236+
WGPUVertexFormat_Int2 = 46,
237+
WGPUVertexFormat_Int3 = 47,
238+
WGPUVertexFormat_Int4 = 48,
195239
} WGPUVertexFormat;
196240

197241
typedef struct WGPUBufferMapAsyncStatus WGPUBufferMapAsyncStatus;

wgpu-native/src/conv.rs

+49-5
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,55 @@ pub fn map_vertex_format(vertex_format: pipeline::VertexFormat) -> hal::format::
358358
use hal::format::Format as H;
359359
use crate::pipeline::VertexFormat::*;
360360
match vertex_format {
361-
FloatR32G32B32A32 => H::Rgba32Float,
362-
FloatR32G32B32 => H::Rgb32Float,
363-
FloatR32G32 => H::Rg32Float,
364-
FloatR32 => H::R32Float,
365-
IntR8G8B8A8 => H::Rgba8Int,
361+
Uchar => H::R8Uint,
362+
Uchar2 => H::Rg8Uint,
363+
Uchar3 => H::Rgb8Uint,
364+
Uchar4 => H::Rgba8Uint,
365+
Char => H::R8Int,
366+
Char2 => H::Rg8Int,
367+
Char3 => H::Rgb8Int,
368+
Char4 => H::Rgba8Int,
369+
UcharNorm => H::R8Srgb,
370+
Uchar2Norm => H::Rg8Srgb,
371+
Uchar3Norm => H::Rgb8Srgb,
372+
Uchar4Norm => H::Rgba8Srgb,
373+
Uchar4NormBgra => H::Bgra8Srgb,
374+
CharNorm => H::R8Inorm,
375+
Char2Norm => H::Rg8Inorm,
376+
Char3Norm => H::Rgb8Inorm,
377+
Char4Norm => H::Rgba8Inorm,
378+
Ushort => H::R16Uint,
379+
Ushort2 => H::Rg16Uint,
380+
Ushort3 => H::Rgb16Uint,
381+
Ushort4 => H::Rgba16Uint,
382+
Short => H::R16Int,
383+
Short2 => H::Rg16Int,
384+
Short3 => H::Rgb16Int,
385+
Short4 => H::Rgba16Int,
386+
UshortNorm => H::R16Unorm,
387+
Ushort2Norm => H::Rg16Unorm,
388+
Ushort3Norm => H::Rgb16Unorm,
389+
Ushort4Norm => H::Rgba16Unorm,
390+
ShortNorm => H::R16Inorm,
391+
Short2Norm => H::Rg16Inorm,
392+
Short3Norm => H::Rgb16Inorm,
393+
Short4Norm => H::Rgba16Inorm,
394+
Half => H::R16Float,
395+
Half2 => H::Rg16Float,
396+
Half3 => H::Rgb16Float,
397+
Half4 => H::Rgba16Float,
398+
Float => H::R32Float,
399+
Float2 => H::Rg32Float,
400+
Float3 => H::Rgb32Float,
401+
Float4 => H::Rgba32Float,
402+
Uint => H::R32Uint,
403+
Uint2 => H::Rg32Uint,
404+
Uint3 => H::Rgb32Uint,
405+
Uint4 => H::Rgba32Uint,
406+
Int => H::R32Int,
407+
Int2 => H::Rg32Int,
408+
Int3 => H::Rgb32Int,
409+
Int4 => H::Rgba32Int,
366410
}
367411
}
368412

wgpu-native/src/pipeline.rs

+50-6
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,56 @@ pub enum IndexFormat {
125125
#[repr(C)]
126126
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
127127
pub enum VertexFormat {
128-
FloatR32G32B32A32 = 0,
129-
FloatR32G32B32 = 1,
130-
FloatR32G32 = 2,
131-
FloatR32 = 3,
132-
IntR8G8B8A8 = 4,
133-
}
128+
Uchar = 0,
129+
Uchar2 = 1,
130+
Uchar3 = 2,
131+
Uchar4 = 3,
132+
Char = 4,
133+
Char2 = 5,
134+
Char3 = 6,
135+
Char4 = 7,
136+
UcharNorm = 8,
137+
Uchar2Norm = 9,
138+
Uchar3Norm = 10,
139+
Uchar4Norm = 11,
140+
Uchar4NormBgra = 12,
141+
CharNorm = 13,
142+
Char2Norm = 14,
143+
Char3Norm = 15,
144+
Char4Norm = 16,
145+
Ushort = 17,
146+
Ushort2 = 18,
147+
Ushort3 = 19,
148+
Ushort4 = 20,
149+
Short = 21,
150+
Short2 = 22,
151+
Short3 = 23,
152+
Short4 = 24,
153+
UshortNorm = 25,
154+
Ushort2Norm = 26,
155+
Ushort3Norm = 27,
156+
Ushort4Norm = 28,
157+
ShortNorm = 29,
158+
Short2Norm = 30,
159+
Short3Norm = 31,
160+
Short4Norm = 32,
161+
Half = 33,
162+
Half2 = 34,
163+
Half3 = 35,
164+
Half4 = 36,
165+
Float = 37,
166+
Float2 = 38,
167+
Float3 = 39,
168+
Float4 = 40,
169+
Uint = 41,
170+
Uint2 = 42,
171+
Uint3 = 43,
172+
Uint4 = 44,
173+
Int = 45,
174+
Int2 = 46,
175+
Int3 = 47,
176+
Int4 = 48,
177+
}
134178

135179
#[repr(C)]
136180
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]

0 commit comments

Comments
 (0)