mirror of
https://github.com/guilhermewerner/wgpu-renderer
synced 2025-06-15 13:24:20 +00:00
Initial pipeline abstraction
This commit is contained in:
@ -22,6 +22,7 @@ path = "Examples/Triangle.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
bitflags = "1.3.2"
|
||||
bytemuck = { version = "1.4", features = [ "derive" ] }
|
||||
cgmath = "0.18"
|
||||
env_logger = "0.9"
|
||||
|
@ -54,8 +54,8 @@ const INDICES: &[u16] = &[
|
||||
|
||||
struct Triangle {
|
||||
render_pipeline: wgpu::RenderPipeline,
|
||||
vertex_buffer: wgpu::Buffer,
|
||||
index_buffer: wgpu::Buffer,
|
||||
vertex_buffer: VertexBuffer,
|
||||
index_buffer: IndexBuffer,
|
||||
num_indices: u32,
|
||||
}
|
||||
|
||||
@ -64,7 +64,8 @@ impl State for Triangle {
|
||||
// Shader
|
||||
|
||||
let shader = Shader::FromWgsl(include_str!("../Shaders/Triangle.wgsl"));
|
||||
let shader_module = renderer.SubmitShader(&shader);
|
||||
|
||||
renderer.CreateShader(&shader);
|
||||
|
||||
// Pipeline
|
||||
|
||||
@ -100,23 +101,7 @@ impl State for Triangle {
|
||||
vertex: wgpu::VertexState {
|
||||
module: &shader_module,
|
||||
entry_point: "main",
|
||||
buffers: &[wgpu::VertexBufferLayout {
|
||||
array_stride: std::mem::size_of::<TriangleVertex>()
|
||||
as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &[
|
||||
wgpu::VertexAttribute {
|
||||
offset: 0,
|
||||
shader_location: 0,
|
||||
format: wgpu::VertexFormat::Float32x3,
|
||||
},
|
||||
wgpu::VertexAttribute {
|
||||
offset: std::mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
|
||||
shader_location: 1,
|
||||
format: wgpu::VertexFormat::Float32x3,
|
||||
},
|
||||
],
|
||||
}],
|
||||
buffers: &[wgpu_layout],
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader_module,
|
||||
@ -145,15 +130,19 @@ impl State for Triangle {
|
||||
})
|
||||
};
|
||||
|
||||
let vertex_buffer = renderer.SubmitVertexBuffer(&VertexBuffer {
|
||||
let vertex_buffer = VertexBuffer {
|
||||
label: "Vertex Buffer".into(),
|
||||
content: bytemuck::cast_slice(VERTICES).to_vec(),
|
||||
});
|
||||
};
|
||||
|
||||
let index_buffer = renderer.SubmitIndexBuffer(&IndexBuffer {
|
||||
renderer.CreateVertexBuffer(&vertex_buffer);
|
||||
|
||||
let index_buffer = IndexBuffer {
|
||||
label: "Index Buffer".into(),
|
||||
content: bytemuck::cast_slice(INDICES).to_vec(),
|
||||
});
|
||||
};
|
||||
|
||||
renderer.CreateIndexBuffer(&index_buffer);
|
||||
|
||||
let num_indices = INDICES.len() as u32;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct IndexBuffer {
|
||||
pub label: Cow<'static, str>,
|
||||
pub content: Vec<u8>,
|
||||
|
40
Source/Render/Pipeline/CompareFunction.rs
Normal file
40
Source/Render/Pipeline/CompareFunction.rs
Normal file
@ -0,0 +1,40 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Comparison function used for depth and stencil operations.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum CompareFunction {
|
||||
/// Function never passes
|
||||
Never = 1,
|
||||
|
||||
/// Function passes if new value less than existing value
|
||||
Less = 2,
|
||||
|
||||
/// Function passes if new value is equal to existing value
|
||||
Equal = 3,
|
||||
|
||||
/// Function passes if new value is less than or equal to existing value
|
||||
LessEqual = 4,
|
||||
|
||||
/// Function passes if new value is greater than existing value
|
||||
Greater = 5,
|
||||
|
||||
/// Function passes if new value is not equal to existing value
|
||||
NotEqual = 6,
|
||||
|
||||
/// Function passes if new value is greater than or equal to existing value
|
||||
GreaterEqual = 7,
|
||||
|
||||
/// Function always passes
|
||||
Always = 8,
|
||||
}
|
||||
|
||||
impl CompareFunction {
|
||||
/// Returns true if the comparison depends on the reference value.
|
||||
pub fn NeedsReferenceValue(self) -> bool {
|
||||
match self {
|
||||
Self::Never | Self::Always => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
}
|
20
Source/Render/Pipeline/DepthBiasState.rs
Normal file
20
Source/Render/Pipeline/DepthBiasState.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct DepthBiasState {
|
||||
/// Constant depth biasing factor, in basic units of the depth format.
|
||||
pub constant: i32,
|
||||
|
||||
/// Slope depth biasing factor.
|
||||
pub slope_scale: f32,
|
||||
|
||||
/// Depth bias clamp value (absolute).
|
||||
pub clamp: f32,
|
||||
}
|
||||
|
||||
impl DepthBiasState {
|
||||
/// Returns true if the depth biasing is enabled.
|
||||
pub fn IsEnabled(&self) -> bool {
|
||||
self.constant != 0 || self.slope_scale != 0.0
|
||||
}
|
||||
}
|
21
Source/Render/Pipeline/DepthStencilState.rs
Normal file
21
Source/Render/Pipeline/DepthStencilState.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use super::{CompareFunction, DepthBiasState, StencilState, TextureFormat};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct DepthStencilState {
|
||||
/// Format of the depth/stencil buffer, must be special depth format. Must match the the format
|
||||
/// of the depth/stencil attachment in [`CommandEncoder::begin_render_pass`].
|
||||
pub format: TextureFormat,
|
||||
|
||||
/// If disabled, depth will not be written to.
|
||||
pub depth_write_enabled: bool,
|
||||
|
||||
/// Comparison function used to compare depth values in the depth test.
|
||||
pub depth_compare: CompareFunction,
|
||||
|
||||
/// Stencil state.
|
||||
pub stencil: StencilState,
|
||||
|
||||
/// Depth bias state.
|
||||
pub bias: DepthBiasState,
|
||||
}
|
12
Source/Render/Pipeline/Face.rs
Normal file
12
Source/Render/Pipeline/Face.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Face of a vertex.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Face {
|
||||
/// Front face
|
||||
Front = 0,
|
||||
|
||||
/// Back face
|
||||
Back = 1,
|
||||
}
|
17
Source/Render/Pipeline/FragmentState.rs
Normal file
17
Source/Render/Pipeline/FragmentState.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use crate::Shader::Shader;
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FragmentState {
|
||||
/// The compiled shader module for this stage.
|
||||
pub shader: Cow<'static, Shader>,
|
||||
|
||||
/// The name of the entry point in the compiled shader. There must be a function that returns
|
||||
/// void with this name in the shader.
|
||||
pub entry_point: Cow<'static, str>,
|
||||
|
||||
/*
|
||||
/// The color state of the render targets.
|
||||
pub targets: &'a [ColorTargetState],
|
||||
*/
|
||||
}
|
22
Source/Render/Pipeline/FrontFace.rs
Normal file
22
Source/Render/Pipeline/FrontFace.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Winding order which classifies the "front" face.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum FrontFace {
|
||||
/// Triangles with vertices in counter clockwise order are considered the front face.
|
||||
///
|
||||
/// This is the default with right handed coordinate spaces.
|
||||
Ccw = 0,
|
||||
|
||||
/// Triangles with vertices in clockwise order are considered the front face.
|
||||
///
|
||||
/// This is the default with left handed coordinate spaces.
|
||||
Cw = 1,
|
||||
}
|
||||
|
||||
impl Default for FrontFace {
|
||||
fn default() -> Self {
|
||||
FrontFace::Ccw
|
||||
}
|
||||
}
|
9
Source/Render/Pipeline/PipelineDescriptor.rs
Normal file
9
Source/Render/Pipeline/PipelineDescriptor.rs
Normal file
@ -0,0 +1,9 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PipelineDescriptor {
|
||||
pub label: Cow<'static, str>,
|
||||
pub layout: Option<String>,
|
||||
pub shader_stages: String,
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Type of drawing mode for polygons
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum PolygonMode {
|
37
Source/Render/Pipeline/PrimitiveState.rs
Normal file
37
Source/Render/Pipeline/PrimitiveState.rs
Normal file
@ -0,0 +1,37 @@
|
||||
use super::{Face, FrontFace, PolygonMode, PrimitiveTopology};
|
||||
use crate::Render::IndexFormat;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PrimitiveState {
|
||||
/// The primitive topology used to interpret vertices.
|
||||
pub topology: PrimitiveTopology,
|
||||
|
||||
/// When drawing strip topologies with indices, this is the required format for the index buffer.
|
||||
/// This has no effect on non-indexed or non-strip draws.
|
||||
pub strip_index_format: Option<IndexFormat>,
|
||||
|
||||
/// The face to consider the front for the purpose of culling and stencil operations.
|
||||
pub front_face: FrontFace,
|
||||
|
||||
/// The face culling mode.
|
||||
pub cull_mode: Option<Face>,
|
||||
|
||||
/// Controls the way each polygon is rasterized. Can be either `Fill` (default), `Line` or `Point`
|
||||
///
|
||||
/// Setting this to `Line` requires `Features::POLYGON_MODE_LINE` to be enabled.
|
||||
///
|
||||
/// Setting this to `Point` requires `Features::POLYGON_MODE_POINT` to be enabled.
|
||||
pub polygon_mode: PolygonMode,
|
||||
|
||||
/// If set to true, the polygon depth is clamped to 0-1 range instead of being clipped.
|
||||
///
|
||||
/// Enabling this requires `Features::DEPTH_CLAMPING` to be enabled.
|
||||
pub clamp_depth: bool,
|
||||
|
||||
/// If set to true, the primitives are rendered with conservative overestimation. I.e. any rastered pixel touched by it is filled.
|
||||
/// Only valid for PolygonMode::Fill!
|
||||
///
|
||||
/// Enabling this requires `Features::CONSERVATIVE_RASTERIZATION` to be enabled.
|
||||
pub conservative: bool,
|
||||
}
|
35
Source/Render/Pipeline/PrimitiveTopology.rs
Normal file
35
Source/Render/Pipeline/PrimitiveTopology.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Primitive type the input mesh is composed of.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum PrimitiveTopology {
|
||||
/// Vertex data is a list of points. Each vertex is a new point.
|
||||
PointList = 0,
|
||||
|
||||
/// Vertex data is a list of lines. Each pair of vertices composes a new line.
|
||||
///
|
||||
/// Vertices `0 1 2 3` create two lines `0 1` and `2 3`
|
||||
LineList = 1,
|
||||
|
||||
/// Vertex data is a strip of lines. Each set of two adjacent vertices form a line.
|
||||
///
|
||||
/// Vertices `0 1 2 3` create three lines `0 1`, `1 2`, and `2 3`.
|
||||
LineStrip = 2,
|
||||
|
||||
/// Vertex data is a list of triangles. Each set of 3 vertices composes a new triangle.
|
||||
///
|
||||
/// Vertices `0 1 2 3 4 5` create two triangles `0 1 2` and `3 4 5`
|
||||
TriangleList = 3,
|
||||
|
||||
/// Vertex data is a triangle strip. Each set of three adjacent vertices form a triangle.
|
||||
///
|
||||
/// Vertices `0 1 2 3 4 5` creates four triangles `0 1 2`, `2 1 3`, `2 3 4`, and `4 3 5`
|
||||
TriangleStrip = 4,
|
||||
}
|
||||
|
||||
impl Default for PrimitiveTopology {
|
||||
fn default() -> Self {
|
||||
PrimitiveTopology::TriangleList
|
||||
}
|
||||
}
|
43
Source/Render/Pipeline/StencilFaceState.rs
Normal file
43
Source/Render/Pipeline/StencilFaceState.rs
Normal file
@ -0,0 +1,43 @@
|
||||
use super::{CompareFunction, StencilOperation};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// State of the stencil operation (fixed-pipeline stage).
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct StencilFaceState {
|
||||
/// Comparison function that determines if the fail_op or pass_op is used on the stencil buffer.
|
||||
pub compare: CompareFunction,
|
||||
|
||||
/// Operation that is preformed when stencil test fails.
|
||||
pub fail_op: StencilOperation,
|
||||
|
||||
/// Operation that is performed when depth test fails but stencil test succeeds.
|
||||
pub depth_fail_op: StencilOperation,
|
||||
|
||||
/// Operation that is performed when stencil test success.
|
||||
pub pass_op: StencilOperation,
|
||||
}
|
||||
|
||||
impl StencilFaceState {
|
||||
/// Ignore the stencil state for the face.
|
||||
pub const IGNORE: Self = StencilFaceState {
|
||||
compare: CompareFunction::Always,
|
||||
fail_op: StencilOperation::Keep,
|
||||
depth_fail_op: StencilOperation::Keep,
|
||||
pass_op: StencilOperation::Keep,
|
||||
};
|
||||
|
||||
/// Returns true if the face state uses the reference value for testing or operation.
|
||||
pub fn NeedsReferenceValue(&self) -> bool {
|
||||
self.compare.NeedsReferenceValue()
|
||||
|| self.fail_op == StencilOperation::Replace
|
||||
|| self.depth_fail_op == StencilOperation::Replace
|
||||
|| self.pass_op == StencilOperation::Replace
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for StencilFaceState {
|
||||
fn default() -> Self {
|
||||
Self::IGNORE
|
||||
}
|
||||
}
|
36
Source/Render/Pipeline/StencilOperation.rs
Normal file
36
Source/Render/Pipeline/StencilOperation.rs
Normal file
@ -0,0 +1,36 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Operation to perform on the stencil value.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum StencilOperation {
|
||||
/// Keep stencil value unchanged.
|
||||
Keep = 0,
|
||||
|
||||
/// Set stencil value to zero.
|
||||
Zero = 1,
|
||||
|
||||
/// Replace stencil value with value provided in most recent call to [`RenderPass::set_stencil_reference`].
|
||||
Replace = 2,
|
||||
|
||||
/// Bitwise inverts stencil value.
|
||||
Invert = 3,
|
||||
|
||||
/// Increments stencil value by one, clamping on overflow.
|
||||
IncrementClamp = 4,
|
||||
|
||||
/// Decrements stencil value by one, clamping on underflow.
|
||||
DecrementClamp = 5,
|
||||
|
||||
/// Increments stencil value by one, wrapping on overflow.
|
||||
IncrementWrap = 6,
|
||||
|
||||
/// Decrements stencil value by one, wrapping on underflow.
|
||||
DecrementWrap = 7,
|
||||
}
|
||||
|
||||
impl Default for StencilOperation {
|
||||
fn default() -> Self {
|
||||
Self::Keep
|
||||
}
|
||||
}
|
37
Source/Render/Pipeline/StencilState.rs
Normal file
37
Source/Render/Pipeline/StencilState.rs
Normal file
@ -0,0 +1,37 @@
|
||||
use super::StencilFaceState;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// State of the stencil operation (fixed-pipeline stage).
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct StencilState {
|
||||
/// Front face mode.
|
||||
pub front: StencilFaceState,
|
||||
|
||||
/// Back face mode.
|
||||
pub back: StencilFaceState,
|
||||
|
||||
/// Stencil values are AND'd with this mask when reading and writing from the stencil buffer. Only low 8 bits are used.
|
||||
pub read_mask: u32,
|
||||
|
||||
/// Stencil values are AND'd with this mask when writing to the stencil buffer. Only low 8 bits are used.
|
||||
pub write_mask: u32,
|
||||
}
|
||||
|
||||
impl StencilState {
|
||||
/// Returns true if the stencil test is enabled.
|
||||
pub fn IsEnabled(&self) -> bool {
|
||||
(self.front != StencilFaceState::IGNORE || self.back != StencilFaceState::IGNORE)
|
||||
&& (self.read_mask != 0 || self.write_mask != 0)
|
||||
}
|
||||
|
||||
/// Returns true if the state doesn't mutate the target values.
|
||||
pub fn IsReadOnly(&self) -> bool {
|
||||
self.write_mask == 0
|
||||
}
|
||||
|
||||
/// Returns true if the stencil state uses the reference value for testing.
|
||||
pub fn NeedsReferenceValue(&self) -> bool {
|
||||
self.front.NeedsReferenceValue() || self.back.NeedsReferenceValue()
|
||||
}
|
||||
}
|
469
Source/Render/Pipeline/TextureFormat.rs
Normal file
469
Source/Render/Pipeline/TextureFormat.rs
Normal file
@ -0,0 +1,469 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum TextureFormat {
|
||||
// Normal 8 bit formats
|
||||
/// Red channel only. 8 bit integer per channel. [0, 255] converted to/from float [0, 1] in shader.
|
||||
R8UNorm,
|
||||
|
||||
/// Red channel only. 8 bit integer per channel. [-127, 127] converted to/from float [-1, 1] in shader.
|
||||
R8Norm,
|
||||
|
||||
/// Red channel only. 8 bit integer per channel. Unsigned in shader.
|
||||
R8UInt,
|
||||
|
||||
/// Red channel only. 8 bit integer per channel. Signed in shader.
|
||||
R8Int,
|
||||
|
||||
// Normal 16 bit formats
|
||||
/// Red channel only. 16 bit integer per channel. Unsigned in shader.
|
||||
R16UInt,
|
||||
|
||||
/// Red channel only. 16 bit integer per channel. Signed in shader.
|
||||
R16Int,
|
||||
|
||||
/// Red channel only. 16 bit float per channel. Float in shader.
|
||||
R16Float,
|
||||
|
||||
/// Red and green channels. 8 bit integer per channel. [0, 255] converted to/from float [0, 1] in shader.
|
||||
Rg8UNorm,
|
||||
|
||||
/// Red and green channels. 8 bit integer per channel. [-127, 127] converted to/from float [-1, 1] in shader.
|
||||
Rg8Norm,
|
||||
|
||||
/// Red and green channels. 8 bit integer per channel. Unsigned in shader.
|
||||
Rg8UInt,
|
||||
|
||||
/// Red and green channels. 8 bit integer per channel. Signed in shader.
|
||||
Rg8Int,
|
||||
|
||||
// Normal 32 bit formats
|
||||
/// Red channel only. 32 bit integer per channel. Unsigned in shader.
|
||||
R32UInt,
|
||||
|
||||
/// Red channel only. 32 bit integer per channel. Signed in shader.
|
||||
R32Int,
|
||||
|
||||
/// Red channel only. 32 bit float per channel. Float in shader.
|
||||
R32Float,
|
||||
|
||||
/// Red and green channels. 16 bit integer per channel. Unsigned in shader.
|
||||
Rg16UInt,
|
||||
|
||||
/// Red and green channels. 16 bit integer per channel. Signed in shader.
|
||||
Rg16Int,
|
||||
|
||||
/// Red and green channels. 16 bit float per channel. Float in shader.
|
||||
Rg16Float,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 8 bit integer per channel. [0, 255] converted to/from float [0, 1] in shader.
|
||||
Rgba8UNorm,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 8 bit integer per channel. Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
Rgba8UNormSrgb,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 8 bit integer per channel. [-127, 127] converted to/from float [-1, 1] in shader.
|
||||
Rgba8Norm,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 8 bit integer per channel. Unsigned in shader.
|
||||
Rgba8UInt,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 8 bit integer per channel. Signed in shader.
|
||||
Rgba8Int,
|
||||
|
||||
/// Blue, green, red, and alpha channels. 8 bit integer per channel. [0, 255] converted to/from float [0, 1] in shader.
|
||||
Bgra8UNorm,
|
||||
|
||||
/// Blue, green, red, and alpha channels. 8 bit integer per channel. Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
Bgra8UNormSrgb,
|
||||
|
||||
// Packed 32 bit formats
|
||||
/// Red, green, blue, and alpha channels. 10 bit integer for RGB channels, 2 bit integer for alpha channel. [0, 1023] ([0, 3] for alpha) converted to/from float [0, 1] in shader.
|
||||
Rgb10a2UNorm,
|
||||
|
||||
/// Red, green, and blue channels. 11 bit float with no sign bit for RG channels. 10 bit float with no sign bit for blue channel. Float in shader.
|
||||
Rg11b10Float,
|
||||
|
||||
// Normal 64 bit formats
|
||||
/// Red and green channels. 32 bit integer per channel. Unsigned in shader.
|
||||
Rg32UInt,
|
||||
|
||||
/// Red and green channels. 32 bit integer per channel. Signed in shader.
|
||||
Rg32Int,
|
||||
|
||||
/// Red and green channels. 32 bit float per channel. Float in shader.
|
||||
Rg32Float,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 16 bit integer per channel. Unsigned in shader.
|
||||
Rgba16UInt,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 16 bit integer per channel. Signed in shader.
|
||||
Rgba16Int,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 16 bit float per channel. Float in shader.
|
||||
Rgba16Float,
|
||||
|
||||
// Normal 128 bit formats
|
||||
/// Red, green, blue, and alpha channels. 32 bit integer per channel. Unsigned in shader.
|
||||
Rgba32UInt,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 32 bit integer per channel. Signed in shader.
|
||||
Rgba32Int,
|
||||
|
||||
/// Red, green, blue, and alpha channels. 32 bit float per channel. Float in shader.
|
||||
Rgba32Float,
|
||||
|
||||
// Depth and stencil formats
|
||||
/// Special depth format with 32 bit floating point depth.
|
||||
Depth32Float,
|
||||
|
||||
/// Special depth format with at least 24 bit integer depth.
|
||||
Depth24Plus,
|
||||
|
||||
/// Special depth/stencil format with at least 24 bit integer depth and 8 bits integer stencil.
|
||||
Depth24PlusStencil8,
|
||||
|
||||
// Packed uncompressed texture formats
|
||||
/// Packed unsigned float with 9 bits mantisa for each RGB component, then a common 5 bits exponent
|
||||
Rgb9e5Ufloat,
|
||||
|
||||
// Compressed textures usable with `TEXTURE_COMPRESSION_BC` feature.
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 4 color + alpha pallet. 5 bit R + 6 bit G + 5 bit B + 1 bit alpha.
|
||||
/// [0, 63] ([0, 1] for alpha) converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as DXT1.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc1RgbaUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 4 color + alpha pallet. 5 bit R + 6 bit G + 5 bit B + 1 bit alpha.
|
||||
/// Srgb-color [0, 63] ([0, 1] for alpha) converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as DXT1.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc1RgbaUNormSrgb,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 4 color pallet. 5 bit R + 6 bit G + 5 bit B + 4 bit alpha.
|
||||
/// [0, 63] ([0, 15] for alpha) converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as DXT3.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc2RgbaUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 4 color pallet. 5 bit R + 6 bit G + 5 bit B + 4 bit alpha.
|
||||
/// Srgb-color [0, 63] ([0, 255] for alpha) converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as DXT3.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc2RgbaUNormSrgb,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 4 color pallet + 8 alpha pallet. 5 bit R + 6 bit G + 5 bit B + 8 bit alpha.
|
||||
/// [0, 63] ([0, 255] for alpha) converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as DXT5.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc3RgbaUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 4 color pallet + 8 alpha pallet. 5 bit R + 6 bit G + 5 bit B + 8 bit alpha.
|
||||
/// Srgb-color [0, 63] ([0, 255] for alpha) converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as DXT5.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc3RgbaUNormSrgb,
|
||||
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 8 color pallet. 8 bit R.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as RGTC1.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc4RUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 8 color pallet. 8 bit R.
|
||||
/// [-127, 127] converted to/from float [-1, 1] in shader.
|
||||
///
|
||||
/// Also known as RGTC1.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc4RNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 8 color red pallet + 8 color green pallet. 8 bit RG.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as RGTC2.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc5RgUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 8 color red pallet + 8 color green pallet. 8 bit RG.
|
||||
/// [-127, 127] converted to/from float [-1, 1] in shader.
|
||||
///
|
||||
/// Also known as RGTC2.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc5RgNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Variable sized pallet. 16 bit unsigned float RGB. Float in shader.
|
||||
///
|
||||
/// Also known as BPTC (float).
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc6hRgbUfloat,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Variable sized pallet. 16 bit signed float RGB. Float in shader.
|
||||
///
|
||||
/// Also known as BPTC (float).
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc6hRgbSfloat,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Variable sized pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as BPTC (unorm).
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc7RgbaUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Variable sized pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// Also known as BPTC (unorm).
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
|
||||
Bc7RgbaUNormSrgb,
|
||||
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer RGB.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
Etc2RgbUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer RGB.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
Etc2RgbUNormSrgb,
|
||||
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer RGB + 1 bit alpha.
|
||||
/// [0, 255] ([0, 1] for alpha) converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
Etc2RgbA1UNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer RGB + 1 bit alpha.
|
||||
/// Srgb-color [0, 255] ([0, 1] for alpha) converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
Etc2RgbA1UNormSrgb,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer RGB + 8 bit alpha.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
//Etc2RgbA8UNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer RGB + 8 bit alpha.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
//Etc2RgbA8UNormSrgb,
|
||||
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer R.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
EacRUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer R.
|
||||
/// [-127, 127] converted to/from float [-1, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
EacRNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer R + 8 bit integer G.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
EacRgUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer R + 8 bit integer G.
|
||||
/// [-127, 127] converted to/from float [-1, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
|
||||
EacRgNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc4x4RgbaUNorm,
|
||||
|
||||
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc4x4RgbaUNormSrgb,
|
||||
|
||||
/// 5x4 block compressed texture. 16 bytes per block (6.4 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc5x4RgbaUNorm,
|
||||
|
||||
/// 5x4 block compressed texture. 16 bytes per block (6.4 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc5x4RgbaUNormSrgb,
|
||||
|
||||
/// 5x5 block compressed texture. 16 bytes per block (5.12 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc5x5RgbaUNorm,
|
||||
|
||||
/// 5x5 block compressed texture. 16 bytes per block (5.12 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc5x5RgbaUNormSrgb,
|
||||
|
||||
/// 6x5 block compressed texture. 16 bytes per block (4.27 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc6x5RgbaUNorm,
|
||||
|
||||
/// 6x5 block compressed texture. 16 bytes per block (4.27 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc6x5RgbaUNormSrgb,
|
||||
|
||||
/// 6x6 block compressed texture. 16 bytes per block (3.56 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc6x6RgbaUNorm,
|
||||
|
||||
/// 6x6 block compressed texture. 16 bytes per block (3.56 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc6x6RgbaUNormSrgb,
|
||||
|
||||
/// 8x5 block compressed texture. 16 bytes per block (3.2 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc8x5RgbaUNorm,
|
||||
|
||||
/// 8x5 block compressed texture. 16 bytes per block (3.2 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc8x5RgbaUNormSrgb,
|
||||
|
||||
/// 8x6 block compressed texture. 16 bytes per block (2.67 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc8x6RgbaUNorm,
|
||||
|
||||
/// 8x6 block compressed texture. 16 bytes per block (2.67 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc8x6RgbaUNormSrgb,
|
||||
|
||||
/// 10x5 block compressed texture. 16 bytes per block (2.56 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc10x5RgbaUNorm,
|
||||
|
||||
/// 10x5 block compressed texture. 16 bytes per block (2.56 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc10x5RgbaUNormSrgb,
|
||||
|
||||
/// 10x6 block compressed texture. 16 bytes per block (2.13 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc10x6RgbaUNorm,
|
||||
|
||||
/// 10x6 block compressed texture. 16 bytes per block (2.13 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc10x6RgbaUNormSrgb,
|
||||
|
||||
/// 8x8 block compressed texture. 16 bytes per block (2 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc8x8RgbaUNorm,
|
||||
|
||||
/// 8x8 block compressed texture. 16 bytes per block (2 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc8x8RgbaUNormSrgb,
|
||||
|
||||
/// 10x8 block compressed texture. 16 bytes per block (1.6 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc10x8RgbaUNorm,
|
||||
|
||||
/// 10x8 block compressed texture. 16 bytes per block (1.6 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc10x8RgbaUNormSrgb,
|
||||
|
||||
/// 10x10 block compressed texture. 16 bytes per block (1.28 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc10x10RgbaUNorm,
|
||||
|
||||
/// 10x10 block compressed texture. 16 bytes per block (1.28 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc10x10RgbaUNormSrgb,
|
||||
|
||||
/// 12x10 block compressed texture. 16 bytes per block (1.07 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc12x10RgbaUNorm,
|
||||
|
||||
/// 12x10 block compressed texture. 16 bytes per block (1.07 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc12x10RgbaUNormSrgb,
|
||||
|
||||
/// 12x12 block compressed texture. 16 bytes per block (0.89 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// [0, 255] converted to/from float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc12x12RgbaUNorm,
|
||||
|
||||
/// 12x12 block compressed texture. 16 bytes per block (0.89 bit/px). Complex pallet. 8 bit integer RGBA.
|
||||
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
|
||||
///
|
||||
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
|
||||
Astc12x12RgbaUNormSrgb,
|
||||
}
|
16
Source/Render/Pipeline/VertexState.rs
Normal file
16
Source/Render/Pipeline/VertexState.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use crate::Render::VertexBufferLayout;
|
||||
use crate::Shader::Shader;
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VertexState {
|
||||
/// The compiled shader module for this stage.
|
||||
pub shader: Cow<'static, Shader>,
|
||||
|
||||
/// The name of the entry point in the compiled shader. There must be a function that returns
|
||||
/// void with this name in the shader.
|
||||
pub entry_point: &'static str,
|
||||
|
||||
/// The format of any vertex buffers used with this pipeline.
|
||||
pub buffers: Cow<'static, [VertexBufferLayout]>,
|
||||
}
|
59
Source/Render/Pipeline/mod.rs
Normal file
59
Source/Render/Pipeline/mod.rs
Normal file
@ -0,0 +1,59 @@
|
||||
#[path = "CompareFunction.rs"]
|
||||
mod _CompareFunction;
|
||||
pub use self::_CompareFunction::*;
|
||||
|
||||
#[path = "DepthStencilState.rs"]
|
||||
mod _DepthStencilState;
|
||||
pub use self::_DepthStencilState::*;
|
||||
|
||||
#[path = "DepthBiasState.rs"]
|
||||
mod _DepthBiasState;
|
||||
pub use self::_DepthBiasState::*;
|
||||
|
||||
#[path = "Face.rs"]
|
||||
mod _Face;
|
||||
pub use self::_Face::*;
|
||||
|
||||
#[path = "FragmentState.rs"]
|
||||
mod _FragmentState;
|
||||
pub use self::_FragmentState::*;
|
||||
|
||||
#[path = "FrontFace.rs"]
|
||||
mod _FrontFace;
|
||||
pub use self::_FrontFace::*;
|
||||
|
||||
#[path = "PipelineDescriptor.rs"]
|
||||
mod _PipelineDescriptor;
|
||||
pub use self::_PipelineDescriptor::*;
|
||||
|
||||
#[path = "PolygonMode.rs"]
|
||||
mod _PolygonMode;
|
||||
pub use self::_PolygonMode::*;
|
||||
|
||||
#[path = "PrimitiveState.rs"]
|
||||
mod _PrimitiveState;
|
||||
pub use self::_PrimitiveState::*;
|
||||
|
||||
#[path = "PrimitiveTopology.rs"]
|
||||
mod _PrimitiveTopology;
|
||||
pub use self::_PrimitiveTopology::*;
|
||||
|
||||
#[path = "StencilFaceState.rs"]
|
||||
mod _StencilFaceState;
|
||||
pub use self::_StencilFaceState::*;
|
||||
|
||||
#[path = "StencilOperation.rs"]
|
||||
mod _StencilOperation;
|
||||
pub use self::_StencilOperation::*;
|
||||
|
||||
#[path = "StencilState.rs"]
|
||||
mod _StencilState;
|
||||
pub use self::_StencilState::*;
|
||||
|
||||
#[path = "TextureFormat.rs"]
|
||||
mod _TextureFormat;
|
||||
pub use self::_TextureFormat::*;
|
||||
|
||||
#[path = "VertexState.rs"]
|
||||
mod _VertexState;
|
||||
pub use self::_VertexState::*;
|
@ -1,6 +1,7 @@
|
||||
use super::{IndexBuffer, UniformBuffer, VertexBuffer};
|
||||
use crate::Shader::Shader;
|
||||
use anyhow::Result;
|
||||
use std::collections::HashMap;
|
||||
use wgpu::util::DeviceExt;
|
||||
use winit::window::Window;
|
||||
|
||||
@ -10,6 +11,11 @@ pub struct Renderer {
|
||||
pub config: wgpu::SurfaceConfiguration,
|
||||
pub device: wgpu::Device,
|
||||
pub queue: wgpu::Queue,
|
||||
pub pipelines: HashMap<String, wgpu::RenderPipeline>,
|
||||
pub shaders: HashMap<String, wgpu::ShaderModule>,
|
||||
pub vertex_buffers: HashMap<String, wgpu::Buffer>,
|
||||
pub index_buffers: HashMap<String, wgpu::Buffer>,
|
||||
pub uniform_buffers: HashMap<String, wgpu::Buffer>,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
@ -56,44 +62,61 @@ impl Renderer {
|
||||
config,
|
||||
device,
|
||||
queue,
|
||||
pipelines: HashMap::new(),
|
||||
shaders: HashMap::new(),
|
||||
vertex_buffers: HashMap::new(),
|
||||
index_buffers: HashMap::new(),
|
||||
uniform_buffers: HashMap::new(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn SubmitShader(&self, shader: &Shader) -> wgpu::ShaderModule {
|
||||
pub fn CreateShader(&mut self, shader: &Shader) {
|
||||
let src = shader.source.WgslToString().unwrap();
|
||||
|
||||
self.device
|
||||
.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
label: Some(&shader.label),
|
||||
source: wgpu::ShaderSource::Wgsl(src.as_str().into()),
|
||||
})
|
||||
self.shaders.insert(
|
||||
shader.label.to_string(),
|
||||
self.device
|
||||
.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
label: Some(&shader.label),
|
||||
source: wgpu::ShaderSource::Wgsl(src.as_str().into()),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn SubmitVertexBuffer(&self, vertex_buffer: &VertexBuffer) -> wgpu::Buffer {
|
||||
self.device
|
||||
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some(&vertex_buffer.label),
|
||||
contents: vertex_buffer.content.as_ref(),
|
||||
usage: wgpu::BufferUsages::VERTEX,
|
||||
})
|
||||
pub fn CreateVertexBuffer(&mut self, vertex_buffer: &VertexBuffer) {
|
||||
self.vertex_buffers.insert(
|
||||
vertex_buffer.label.to_string(),
|
||||
self.device
|
||||
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some(&vertex_buffer.label),
|
||||
contents: vertex_buffer.content.as_ref(),
|
||||
usage: wgpu::BufferUsages::VERTEX,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn SubmitIndexBuffer(&self, index_buffer: &IndexBuffer) -> wgpu::Buffer {
|
||||
self.device
|
||||
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some(&index_buffer.label),
|
||||
contents: index_buffer.content.as_ref(),
|
||||
usage: wgpu::BufferUsages::INDEX,
|
||||
})
|
||||
pub fn CreateIndexBuffer(&mut self, index_buffer: &IndexBuffer) {
|
||||
self.index_buffers.insert(
|
||||
index_buffer.label.to_string(),
|
||||
self.device
|
||||
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some(&index_buffer.label),
|
||||
contents: index_buffer.content.as_ref(),
|
||||
usage: wgpu::BufferUsages::INDEX,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn SubmitUniformBuffer(&self, uniform_buffer: &UniformBuffer) -> wgpu::Buffer {
|
||||
self.device
|
||||
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some(&uniform_buffer.label),
|
||||
contents: uniform_buffer.content.as_ref(),
|
||||
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
|
||||
})
|
||||
pub fn CreateUniformBuffer(&mut self, uniform_buffer: &UniformBuffer) {
|
||||
self.uniform_buffers.insert(
|
||||
uniform_buffer.label.to_string(),
|
||||
self.device
|
||||
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some(&uniform_buffer.label),
|
||||
contents: uniform_buffer.content.as_ref(),
|
||||
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn Draw(
|
||||
|
@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UniformBuffer {
|
||||
pub label: Cow<'static, str>,
|
||||
pub content: Vec<u8>,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct VertexBuffer {
|
||||
pub label: Cow<'static, str>,
|
||||
pub content: Vec<u8>,
|
||||
|
@ -1,3 +1,5 @@
|
||||
pub mod Pipeline;
|
||||
|
||||
//#[path = "DrawModel.rs"]
|
||||
//mod _DrawModel;
|
||||
//pub use self::_DrawModel::*;
|
||||
@ -18,10 +20,6 @@ pub use self::_IndexFormat::*;
|
||||
//mod _Model;
|
||||
//pub use self::_Model::*;
|
||||
|
||||
#[path = "PolygonMode.rs"]
|
||||
mod _PolygonMode;
|
||||
pub use self::_PolygonMode::*;
|
||||
|
||||
#[path = "Renderer.rs"]
|
||||
mod _Renderer;
|
||||
pub use self::_Renderer::*;
|
||||
|
Reference in New Issue
Block a user