Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
grovesNL committed Apr 8, 2020
1 parent 7320582 commit ae3ee34
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
Binary file added examples/shadow/bake.frag.spv
Binary file not shown.
Binary file added examples/shadow/bake.vert.spv
Binary file not shown.
Binary file added examples/shadow/forward.frag.spv
Binary file not shown.
Binary file added examples/shadow/forward.vert.spv
Binary file not shown.
30 changes: 12 additions & 18 deletions examples/shadow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,10 @@ impl framework::Example for Example {
});

// Create the render pipeline
let vs_bytes =
framework::load_glsl(include_str!("bake.vert"), framework::ShaderStage::Vertex);
let fs_bytes =
framework::load_glsl(include_str!("bake.frag"), framework::ShaderStage::Fragment);
let vs_module = device.create_shader_module(&vs_bytes);
let fs_module = device.create_shader_module(&fs_bytes);
let vs_bytes = include_bytes!("bake.vert.spv");
let fs_bytes = include_bytes!("bake.frag.spv");
let vs_module = device.create_shader_module(&wgpu::read_spirv(std::io::Cursor::new(&vs_bytes[..])).unwrap());
let fs_module = device.create_shader_module(&wgpu::read_spirv(std::io::Cursor::new(&fs_bytes[..])).unwrap());

let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
layout: &pipeline_layout,
Expand Down Expand Up @@ -571,14 +569,10 @@ impl framework::Example for Example {
});

// Create the render pipeline
let vs_bytes =
framework::load_glsl(include_str!("forward.vert"), framework::ShaderStage::Vertex);
let fs_bytes = framework::load_glsl(
include_str!("forward.frag"),
framework::ShaderStage::Fragment,
);
let vs_module = device.create_shader_module(&vs_bytes);
let fs_module = device.create_shader_module(&fs_bytes);
let vs_bytes = include_bytes!("forward.vert.spv");
let fs_bytes = include_bytes!("forward.frag.spv");
let vs_module = device.create_shader_module(&wgpu::read_spirv(std::io::Cursor::new(&vs_bytes[..])).unwrap());
let fs_module = device.create_shader_module(&wgpu::read_spirv(std::io::Cursor::new(&fs_bytes[..])).unwrap());

let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
layout: &pipeline_layout,
Expand Down Expand Up @@ -706,7 +700,7 @@ impl framework::Example for Example {

{
let size = mem::size_of::<EntityUniforms>();
let temp_buf_data = device.create_buffer_mapped(&wgpu::BufferDescriptor {
let mut temp_buf_data = device.create_buffer_mapped(&wgpu::BufferDescriptor {
size: (self.entities.len() * size) as u64,
usage: wgpu::BufferUsage::COPY_SRC,
label: None,
Expand All @@ -716,7 +710,7 @@ impl framework::Example for Example {
for (entity, slot) in self
.entities
.iter_mut()
.zip(temp_buf_data.data.chunks_exact_mut(size))
.zip(temp_buf_data.data().chunks_exact_mut(size))
{
if entity.rotation_speed != 0.0 {
let rotation =
Expand Down Expand Up @@ -754,7 +748,7 @@ impl framework::Example for Example {
self.lights_are_dirty = false;
let size = mem::size_of::<LightRaw>();
let total_size = size * self.lights.len();
let temp_buf_data = device.create_buffer_mapped(&wgpu::BufferDescriptor {
let mut temp_buf_data = device.create_buffer_mapped(&wgpu::BufferDescriptor {
size: total_size as u64,
usage: wgpu::BufferUsage::COPY_SRC,
label: None
Expand All @@ -763,7 +757,7 @@ impl framework::Example for Example {
for (light, slot) in self
.lights
.iter()
.zip(temp_buf_data.data.chunks_exact_mut(size))
.zip(temp_buf_data.data().chunks_exact_mut(size))
{
slot.copy_from_slice(light.to_raw().as_bytes());
}
Expand Down

0 comments on commit ae3ee34

Please sign in to comment.