Skip to main content

ProgramType

Enum ProgramType 

Source
pub enum ProgramType {
    Pixel,
    Vertex,
    Geometry,
    Hull,
    Domain,
    Compute,
}
Expand description

The kind of program a version token names.

Variants§

§

Pixel

A pixel program (ps).

§

Vertex

A vertex program (vs).

§

Geometry

A geometry program (gs).

§

Hull

A hull program (hs).

§

Domain

A domain program (ds).

§

Compute

A compute program (cs).

Implementations§

Source§

impl ProgramType

Source

pub fn name(self) -> &'static str

The target’s stage prefix (ps, vs, …).

Examples found in repository?
examples/pairs_dxbc.rs (line 82)
33fn main() -> Result<(), Box<dyn std::error::Error>> {
34    let mut paths = Vec::new();
35    for argument in std::env::args().skip(1) {
36        files(Path::new(&argument), &mut paths)?;
37    }
38    let (mut programs, mut skipped) = (0_usize, 0_usize);
39    for path in &paths {
40        let bytes = std::fs::read(path)?;
41        let has_code = dxbc_reader::parts(&bytes)
42            .is_ok_and(|parts| parts.iter().any(|c| matches!(&c.kind, b"SHDR" | b"SHEX")));
43        if !has_code {
44            skipped += 1;
45            continue;
46        }
47        let program = match dxbc_reader::code(&bytes).and_then(|code| dxbc_reader::decode(&code)) {
48            Ok(program) => program,
49            Err(e) => {
50                eprintln!("{}: {e}", path.display());
51                continue;
52            }
53        };
54        programs += 1;
55        let hash = fnv1a64(&bytes);
56        let mut pairs = Pairs::new();
57        for read in dxbc_reader::texture_reads(&program) {
58            let texture = if read.texture_indexed {
59                format!("t[{}+]", read.texture)
60            } else {
61                format!("t{}", read.texture)
62            };
63            let sampler = match (read.sampler, read.sampler_indexed) {
64                (None, _) => "-".to_owned(),
65                (Some(slot), true) => format!("s[{slot}+]"),
66                (Some(slot), false) => format!("s{slot}"),
67            };
68            let mode = read
69                .sampler_mode
70                .map_or_else(|| "-".to_owned(), |m| m.to_string());
71            let entry = pairs
72                .entry((texture, sampler, read.comparison, mode))
73                .or_default();
74            entry.0 += 1;
75            *entry.1.entry(dxbc_reader::opcode_name(read.opcode)).or_default() += 1;
76        }
77        for ((texture, sampler, comparison, mode), (count, names)) in pairs {
78            let names: Vec<String> = names.iter().map(|(n, c)| format!("{n}x{c}")).collect();
79            println!(
80                "{hash:016x}\t{}\t{}\t{texture}\t{sampler}\t{}\t{mode}\t{count}\t{}",
81                path.display(),
82                program.kind.name(),
83                u8::from(comparison),
84                names.join(",")
85            );
86        }
87    }
88    eprintln!("{programs} programs, {skipped} files skipped");
89    Ok(())
90}

Trait Implementations§

Source§

impl Clone for ProgramType

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ProgramType

Source§

impl Debug for ProgramType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ProgramType

Source§

impl PartialEq for ProgramType

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ProgramType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.