Add rustfmt.toml and enable auto formatting (Fixes #7)

This commit is contained in:
Keavon Chambers
2020-07-12 16:20:28 -07:00
parent c49c00100e
commit 848228dd45
20 changed files with 541 additions and 439 deletions

View File

@@ -1,9 +1,9 @@
use crate::resource_cache::ResourceCache;
use crate::draw_command::DrawCommand;
use crate::color::Color;
use crate::texture::Texture;
use crate::pipeline::Pipeline;
use crate::draw_command::DrawCommand;
use crate::gui_attributes::*;
use crate::pipeline::Pipeline;
use crate::resource_cache::ResourceCache;
use crate::texture::Texture;
pub struct GuiNode {
pub form_factor: GuiNodeUniform,
@@ -18,7 +18,13 @@ impl GuiNode {
}
}
pub fn build_draw_commands_recursive(node: &rctree::Node<GuiNode>, device: &wgpu::Device, queue: &mut wgpu::Queue, pipeline_cache: &ResourceCache<Pipeline>, texture_cache: &mut ResourceCache<Texture>) -> Vec<DrawCommand> {
pub fn build_draw_commands_recursive(
node: &rctree::Node<GuiNode>,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
pipeline_cache: &ResourceCache<Pipeline>,
texture_cache: &mut ResourceCache<Texture>,
) -> Vec<DrawCommand> {
let mut draw_commands: Vec<DrawCommand> = Vec::new();
for mut subnode in node.descendants() {
@@ -32,19 +38,11 @@ impl GuiNode {
}
pub fn build_draw_command(&mut self, device: &wgpu::Device, queue: &mut wgpu::Queue, pipeline: &Pipeline, texture_cache: &mut ResourceCache<Texture>) -> DrawCommand {
const VERTICES: &[[f32; 2]] = &[
[-0.5, 0.5],
[0.5, 0.5],
[0.5, 1.0],
[-0.5, 1.0],
];
const INDICES: &[u16] = &[
0, 1, 2,
0, 2, 3,
];
const VERTICES: &[[f32; 2]] = &[[-0.5, 0.5], [0.5, 0.5], [0.5, 1.0], [-0.5, 1.0]];
const INDICES: &[u16] = &[0, 1, 2, 0, 2, 3];
let bind_groups = self.build_bind_groups(device, queue, pipeline, texture_cache);
// Create a draw command with the vertex data then push it to the GPU command queue
DrawCommand::new(device, self.pipeline_name.clone(), bind_groups, VERTICES, INDICES)
}
@@ -57,15 +55,17 @@ impl GuiNode {
let binding_staging_buffer = Pipeline::build_binding_staging_buffer(device, &self.form_factor);
// Construct the bind group for this GUI node
let bind_group = Pipeline::build_bind_group(device, &pipeline.bind_group_layout, vec![
Pipeline::build_binding_resource(&binding_staging_buffer),
wgpu::BindingResource::TextureView(&texture.texture_view),
wgpu::BindingResource::Sampler(&texture.sampler),
]);
vec![
bind_group,
]
let bind_group = Pipeline::build_bind_group(
device,
&pipeline.bind_group_layout,
vec![
Pipeline::build_binding_resource(&binding_staging_buffer),
wgpu::BindingResource::TextureView(&texture.texture_view),
wgpu::BindingResource::Sampler(&texture.sampler),
],
);
vec![bind_group]
}
}