mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
Create shader modules
This commit is contained in:
parent
569c5fbeb7
commit
76af247a51
7
examples/data/hello_triangle.frag
Normal file
7
examples/data/hello_triangle.frag
Normal file
@ -0,0 +1,7 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
outColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
BIN
examples/data/hello_triangle.frag.spv
Normal file
BIN
examples/data/hello_triangle.frag.spv
Normal file
Binary file not shown.
15
examples/data/hello_triangle.vert
Normal file
15
examples/data/hello_triangle.vert
Normal file
@ -0,0 +1,15 @@
|
||||
#version 450
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
const vec2 positions[3] = vec2[3](
|
||||
vec2(0.0, -0.5),
|
||||
vec2(0.5, 0.5),
|
||||
vec2(-0.5, 0.5)
|
||||
);
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
|
||||
}
|
BIN
examples/data/hello_triangle.vert.spv
Normal file
BIN
examples/data/hello_triangle.vert.spv
Normal file
Binary file not shown.
@ -10,4 +10,10 @@ fn main() {
|
||||
anisotropic_filtering: false,
|
||||
},
|
||||
});
|
||||
let _vs = gn::device_create_shader_module(device, gn::ShaderModuleDescriptor {
|
||||
code: include_bytes!("./data/hello_triangle.vert.spv"),
|
||||
});
|
||||
let _fs = gn::device_create_shader_module(device, gn::ShaderModuleDescriptor {
|
||||
code: include_bytes!("./data/hello_triangle.frag.spv"),
|
||||
});
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
use hal::{self, Device as _Device, QueueGroup};
|
||||
use memory;
|
||||
|
||||
use {BufferHandle, CommandBufferHandle, DeviceHandle};
|
||||
use {BufferHandle, CommandBufferHandle, DeviceHandle, ShaderModuleHandle};
|
||||
|
||||
|
||||
pub type BufferUsage = hal::buffer::Usage;
|
||||
@ -12,6 +12,11 @@ pub struct BufferDescriptor {
|
||||
pub usage: BufferUsage,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ShaderModuleDescriptor<'a> {
|
||||
pub code: &'a [u8],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct CommandBufferDescriptor {
|
||||
}
|
||||
@ -50,6 +55,20 @@ fn device_create_buffer(
|
||||
})
|
||||
}
|
||||
|
||||
pub struct ShaderModule<B: hal::Backend> {
|
||||
pub raw: B::ShaderModule,
|
||||
}
|
||||
|
||||
pub extern "C"
|
||||
fn device_create_shader_module(
|
||||
device: DeviceHandle, desc: ShaderModuleDescriptor
|
||||
) -> ShaderModuleHandle {
|
||||
let shader = device.device.create_shader_module(desc.code).unwrap();
|
||||
ShaderModuleHandle::new(ShaderModule {
|
||||
raw: shader,
|
||||
})
|
||||
}
|
||||
|
||||
pub extern "C"
|
||||
fn device_create_command_buffer(
|
||||
device: DeviceHandle, desc: CommandBufferDescriptor
|
||||
|
@ -26,6 +26,7 @@ pub type InstanceHandle = Handle<back::Instance>;
|
||||
pub type AdapterHandle = Handle<hal::Adapter<B>>;
|
||||
pub type DeviceHandle = Handle<Device<B>>;
|
||||
pub type BufferHandle = Handle<Buffer<B>>;
|
||||
pub type ShaderModuleHandle = Handle<ShaderModule<B>>;
|
||||
pub type CommandBufferHandle = Handle<CommandBuffer<B>>;
|
||||
pub type RenderPassHandle = Handle<RenderPass<B>>;
|
||||
pub type ComputePassHandle = Handle<ComputePass<B>>;
|
||||
|
Loading…
Reference in New Issue
Block a user