mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Reduce code duplication between backends
This commit is contained in:
committed by
Dzmitry Malyshau
parent
548cde4701
commit
3a4d6fa295
@@ -44,6 +44,7 @@
|
||||
pub use features::Features;
|
||||
|
||||
use crate::{
|
||||
back::{COMPONENTS, INDENT},
|
||||
proc::{EntryPointIndex, NameKey, Namer, TypeResolution},
|
||||
valid::{FunctionInfo, ModuleInfo},
|
||||
Arena, ArraySize, BinaryOperator, Binding, BuiltIn, Bytes, ConservativeDepth, Constant,
|
||||
@@ -69,9 +70,6 @@ mod keywords;
|
||||
pub const SUPPORTED_CORE_VERSIONS: &[u16] = &[330, 400, 410, 420, 430, 440, 450];
|
||||
/// List of supported es glsl versions
|
||||
pub const SUPPORTED_ES_VERSIONS: &[u16] = &[300, 310, 320];
|
||||
const INDENT: &str = " ";
|
||||
|
||||
const COMPONENTS: &[char] = &['x', 'y', 'z', 'w'];
|
||||
|
||||
/// glsl version
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#![allow(dead_code)]
|
||||
use super::{Error, Options, ShaderModel};
|
||||
use crate::{
|
||||
back::{hlsl::keywords::RESERVED, vector_size_str},
|
||||
back::{hlsl::keywords::RESERVED, vector_size_str, BAKE_PREFIX, COMPONENTS, INDENT},
|
||||
proc::{EntryPointIndex, NameKey, Namer, TypeResolution},
|
||||
valid::{FunctionInfo, ModuleInfo},
|
||||
Arena, ArraySize, BuiltIn, Bytes, Constant, ConstantInner, Expression, FastHashMap, Function,
|
||||
@@ -11,10 +11,7 @@ use crate::{
|
||||
};
|
||||
use std::fmt::Write;
|
||||
|
||||
const INDENT: &str = " ";
|
||||
const COMPONENTS: &[char] = &['x', 'y', 'z', 'w'];
|
||||
const LOCATION_SEMANTIC: &str = "LOC";
|
||||
const BAKE_PREFIX: &str = "_e";
|
||||
|
||||
/// Shorthand result used internally by the backend
|
||||
type BackendResult = Result<(), Error>;
|
||||
|
||||
@@ -13,6 +13,13 @@ pub mod spv;
|
||||
#[cfg(feature = "wgsl-out")]
|
||||
pub mod wgsl;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const COMPONENTS: &[char] = &['x', 'y', 'z', 'w'];
|
||||
#[allow(dead_code)]
|
||||
const INDENT: &str = " ";
|
||||
#[allow(dead_code)]
|
||||
const BAKE_PREFIX: &str = "_e";
|
||||
|
||||
/// How should code generated by Naga do indexing bounds checks?
|
||||
///
|
||||
/// When a vector, matrix, or array index is out of bounds—either negative, or
|
||||
|
||||
@@ -4,7 +4,7 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
arena::{Arena, Handle},
|
||||
back::vector_size_str,
|
||||
back::{vector_size_str, BAKE_PREFIX, COMPONENTS, INDENT},
|
||||
proc::{EntryPointIndex, NameKey, Namer, TypeResolution},
|
||||
valid::{Capabilities, FunctionInfo, GlobalUse, ModuleInfo},
|
||||
FastHashMap,
|
||||
@@ -15,8 +15,6 @@ use std::{
|
||||
};
|
||||
|
||||
const NAMESPACE: &str = "metal";
|
||||
const INDENT: &str = " ";
|
||||
const BAKE_PREFIX: &str = "_e";
|
||||
const WRAPPED_ARRAY_FIELD: &str = "inner";
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -305,8 +303,6 @@ fn scalar_kind_string(kind: crate::ScalarKind) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
const COMPONENTS: &[char] = &['x', 'y', 'z', 'w'];
|
||||
|
||||
fn separate(need_separator: bool) -> &'static str {
|
||||
if need_separator {
|
||||
","
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use super::Error;
|
||||
use crate::{
|
||||
back::{binary_operation_str, vector_size_str, wgsl::keywords::RESERVED},
|
||||
back::{
|
||||
binary_operation_str, vector_size_str, wgsl::keywords::RESERVED, BAKE_PREFIX, COMPONENTS,
|
||||
INDENT,
|
||||
},
|
||||
proc::{EntryPointIndex, NameKey, Namer, TypeResolution},
|
||||
valid::{FunctionInfo, ModuleInfo},
|
||||
Arena, ArraySize, Binding, Constant, ConstantInner, Expression, FastHashMap, Function,
|
||||
@@ -10,10 +13,6 @@ use crate::{
|
||||
};
|
||||
use std::fmt::Write;
|
||||
|
||||
const INDENT: &str = " ";
|
||||
const COMPONENTS: &[char] = &['x', 'y', 'z', 'w'];
|
||||
const BAKE_PREFIX: &str = "_e";
|
||||
|
||||
/// Shorthand result used internally by the backend
|
||||
type BackendResult = Result<(), Error>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user