mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-20 02:42:43 +00:00
[glsl-out] Use fmt::Writer instead of io::Writer
This commit is contained in:
parent
446f5dad6f
commit
c37ae5e2a0
@ -237,23 +237,12 @@ fn main() {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let file = fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.truncate(true)
|
||||
.create(true)
|
||||
.open(output_path)
|
||||
.unwrap();
|
||||
|
||||
let mut writer = glsl::Writer::new(file, &module, info.as_ref().unwrap(), ¶ms.glsl)
|
||||
.unwrap_pretty();
|
||||
|
||||
writer
|
||||
.write()
|
||||
.map_err(|e| {
|
||||
fs::remove_file(output_path).unwrap();
|
||||
e
|
||||
})
|
||||
.unwrap();
|
||||
let mut buffer = String::new();
|
||||
let mut writer =
|
||||
glsl::Writer::new(&mut buffer, &module, info.as_ref().unwrap(), ¶ms.glsl)
|
||||
.unwrap_pretty();
|
||||
writer.write().unwrap();
|
||||
fs::write(output_path, buffer).unwrap();
|
||||
}
|
||||
#[cfg(feature = "dot-out")]
|
||||
"dot" => {
|
||||
|
@ -3,7 +3,7 @@ use crate::{
|
||||
Binding, Bytes, Handle, ImageClass, ImageDimension, Interpolation, Sampling, ScalarKind,
|
||||
ShaderStage, StorageClass, StorageFormat, Type, TypeInner,
|
||||
};
|
||||
use std::io::Write;
|
||||
use std::fmt::Write;
|
||||
|
||||
bitflags::bitflags! {
|
||||
/// Structure used to encode a set of additions to glsl that aren't supported by all versions
|
||||
|
@ -57,7 +57,7 @@ use features::FeaturesManager;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
fmt,
|
||||
io::{Error as IoError, Write},
|
||||
fmt::{Error as FmtError, Write},
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
@ -271,8 +271,8 @@ type BackendResult = Result<(), Error>;
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
/// A error occurred while writing to the output
|
||||
#[error("I/O error")]
|
||||
IoError(#[from] IoError),
|
||||
#[error("Format error")]
|
||||
FmtError(#[from] FmtError),
|
||||
/// The specified [`Version`](Version) doesn't have all required [`Features`](super)
|
||||
///
|
||||
/// Contains the missing [`Features`](Features)
|
||||
|
@ -189,14 +189,12 @@ fn check_output_glsl(
|
||||
entry_point: ep_name.to_string(),
|
||||
};
|
||||
|
||||
let mut buffer = Vec::new();
|
||||
let mut buffer = String::new();
|
||||
let mut writer = glsl::Writer::new(&mut buffer, module, info, &options).unwrap();
|
||||
writer.write().unwrap();
|
||||
|
||||
let string = String::from_utf8(buffer).unwrap();
|
||||
|
||||
let ext = format!("{:?}.glsl", stage);
|
||||
fs::write(destination.with_extension(&ext), string).unwrap();
|
||||
fs::write(destination.with_extension(&ext), buffer).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(feature = "hlsl-out")]
|
||||
|
Loading…
Reference in New Issue
Block a user