1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
use crate::models::texture::{ImageFormat, ImageSize};
use crate::output::gfx::CompareFunction;

pub struct OutputTexture {
    pub game_address: usize,
    pub format: ImageFormat,
    pub size: ImageSize,
    pub width: u32,
    pub height: u32,
    pub data: Vec<u8>,

    // when a texture has been created in a gfx backend, this field will be Some
    pub device_id: Option<u32>,
}

impl OutputTexture {
    pub fn new(
        game_address: usize,
        format: ImageFormat,
        size: ImageSize,
        width: u32,
        height: u32,
        data: Vec<u8>,
    ) -> Self {
        Self {
            game_address,
            format,
            size,
            width,
            height,
            data,
            device_id: None,
        }
    }
}

#[derive(Debug, Clone, Copy)]
pub struct OutputSampler {
    pub tile: usize,
    pub linear_filter: bool,
    pub clamp_s: u32,
    pub clamp_t: u32,
}

#[derive(Debug, Clone, Copy)]
pub struct OutputStencil {
    pub depth_write_enabled: bool,
    pub depth_compare: CompareFunction,
    pub polygon_offset: bool,
}

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct OutputUniformsBlend {
    pub fog_color: glam::Vec4,
    pub blend_color: glam::Vec4,
}

impl OutputUniformsBlend {
    pub const EMPTY: Self = OutputUniformsBlend {
        fog_color: glam::Vec4::ZERO,
        blend_color: glam::Vec4::ZERO,
    };
}

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct OutputUniformsCombine {
    pub prim_color: glam::Vec4,
    pub env_color: glam::Vec4,
    pub key_center: glam::Vec3,
    pub key_scale: glam::Vec3,
    pub prim_lod: glam::Vec2,
    pub convert_k4: f32,
    pub convert_k5: f32,
}

impl OutputUniformsCombine {
    pub const EMPTY: Self = OutputUniformsCombine {
        prim_color: glam::Vec4::ZERO,
        env_color: glam::Vec4::ZERO,
        key_center: glam::Vec3::ZERO,
        key_scale: glam::Vec3::ZERO,
        prim_lod: glam::Vec2::ZERO,
        convert_k4: 0.0,
        convert_k5: 0.0,
    };
}

#[derive(Debug, Clone, Copy)]
pub struct OutputUniforms {
    pub blend: OutputUniformsBlend,
    pub combine: OutputUniformsCombine,
}

impl OutputUniforms {
    pub const EMPTY: Self = OutputUniforms {
        blend: OutputUniformsBlend::EMPTY,
        combine: OutputUniformsCombine::EMPTY,
    };
}

#[derive(Debug, Clone)]
pub struct OutputVBO {
    pub vbo: Vec<u8>,
    pub num_tris: usize,
}

impl OutputVBO {
    pub const EMPTY: Self = OutputVBO {
        vbo: Vec::new(),
        num_tris: 0,
    };
}

#[derive(Debug, Clone)]
pub struct OutputFogParams {
    pub multiplier: i16,
    pub offset: i16,
}

impl OutputFogParams {
    pub const EMPTY: Self = OutputFogParams {
        multiplier: 0,
        offset: 0,
    };
}