Skip to content

armgit / gecko

Public Imported from GitHub
0

A GameCube/Wii emulator and debugger written in Rust.

texmaps!

Layle11f02bc5983c
diff --git a/crates/backend-wgpu/src/gx.wgsl b/crates/backend-wgpu/src/gx.wgsl
index c8780d8..04f3196 100644
--- a/crates/backend-wgpu/src/gx.wgsl
+++ b/crates/backend-wgpu/src/gx.wgsl
@@ -6,6 +6,7 @@ struct FrameUniforms {
tev_konst_colors: array<vec4<f32>, 16>,
tev_color_env: array<vec4<u32>, 4>,
tev_alpha_env: array<vec4<u32>, 4>,
+ tev_orders: array<vec4<u32>, 4>,
num_tev_stages: u32,
alpha_ref0: f32,
alpha_ref1: f32,
@@ -24,22 +25,50 @@ var<uniform> frame: FrameUniforms;
@group(0) @binding(1)
var<uniform> draw: DrawUniforms;
-@group(0) @binding(2)
-var tex: texture_2d<f32>;
-
-@group(0) @binding(3)
-var tex_sampler: sampler;
+// 8 texture maps (texmap 0-7)
+@group(0) @binding(2) var tex0: texture_2d<f32>;
+@group(0) @binding(3) var tex1: texture_2d<f32>;
+@group(0) @binding(4) var tex2: texture_2d<f32>;
+@group(0) @binding(5) var tex3: texture_2d<f32>;
+@group(0) @binding(6) var tex4: texture_2d<f32>;
+@group(0) @binding(7) var tex5: texture_2d<f32>;
+@group(0) @binding(8) var tex6: texture_2d<f32>;
+@group(0) @binding(9) var tex7: texture_2d<f32>;
+
+// 8 samplers (paired with texmaps)
+@group(0) @binding(10) var samp0: sampler;
+@group(0) @binding(11) var samp1: sampler;
+@group(0) @binding(12) var samp2: sampler;
+@group(0) @binding(13) var samp3: sampler;
+@group(0) @binding(14) var samp4: sampler;
+@group(0) @binding(15) var samp5: sampler;
+@group(0) @binding(16) var samp6: sampler;
+@group(0) @binding(17) var samp7: sampler;
struct VsIn {
@location(0) position: vec3<f32>,
@location(1) color: vec4<f32>,
@location(2) tex0: vec2<f32>,
+ @location(3) tex1: vec2<f32>,
+ @location(4) tex2: vec2<f32>,
+ @location(5) tex3: vec2<f32>,
+ @location(6) tex4: vec2<f32>,
+ @location(7) tex5: vec2<f32>,
+ @location(8) tex6: vec2<f32>,
+ @location(9) tex7: vec2<f32>,
};
struct VsOut {
@builtin(position) clip_pos: vec4<f32>,
@location(0) color: vec4<f32>,
- @location(1) tex0: vec2<f32>,
+ @location(1) uv0: vec2<f32>,
+ @location(2) uv1: vec2<f32>,
+ @location(3) uv2: vec2<f32>,
+ @location(4) uv3: vec2<f32>,
+ @location(5) uv4: vec2<f32>,
+ @location(6) uv5: vec2<f32>,
+ @location(7) uv6: vec2<f32>,
+ @location(8) uv7: vec2<f32>,
};
@vertex
@@ -49,7 +78,14 @@ fn vs_main(in: VsIn) -> VsOut {
// Remap depth: GameCube/OpenGL uses [-1,1], wgpu uses [0,1]
out.clip_pos.z = out.clip_pos.z * 0.5 + out.clip_pos.w * 0.5;
out.color = in.color;
- out.tex0 = in.tex0;
+ out.uv0 = in.tex0;
+ out.uv1 = in.tex1;
+ out.uv2 = in.tex2;
+ out.uv3 = in.tex3;
+ out.uv4 = in.tex4;
+ out.uv5 = in.tex5;
+ out.uv6 = in.tex6;
+ out.uv7 = in.tex7;
return out;
}
@@ -65,6 +101,36 @@ fn extract_bits(val: u32, lo: u32, width: u32) -> u32 {
return (val >> lo) & ((1u << width) - 1u);
}
+// Select texcoord by index (from TevOrder.texcoord)
+fn select_texcoord(in: VsOut, idx: u32) -> vec2<f32> {
+ switch idx {
+ case 0u: { return in.uv0; }
+ case 1u: { return in.uv1; }
+ case 2u: { return in.uv2; }
+ case 3u: { return in.uv3; }
+ case 4u: { return in.uv4; }
+ case 5u: { return in.uv5; }
+ case 6u: { return in.uv6; }
+ case 7u: { return in.uv7; }
+ default: { return in.uv0; }
+ }
+}
+
+// Sample from texmap by index (from TevOrder.texmap)
+fn sample_texmap(texmap: u32, uv: vec2<f32>) -> vec4<f32> {
+ switch texmap {
+ case 0u: { return textureSample(tex0, samp0, uv); }
+ case 1u: { return textureSample(tex1, samp1, uv); }
+ case 2u: { return textureSample(tex2, samp2, uv); }
+ case 3u: { return textureSample(tex3, samp3, uv); }
+ case 4u: { return textureSample(tex4, samp4, uv); }
+ case 5u: { return textureSample(tex5, samp5, uv); }
+ case 6u: { return textureSample(tex6, samp6, uv); }
+ case 7u: { return textureSample(tex7, samp7, uv); }
+ default: { return textureSample(tex0, samp0, uv); }
+ }
+}
+
// TEV color input selector (TevColorIn, 4-bit, 16 variants)
fn tev_color_in(sel: u32, tex_color: vec4<f32>, ras_color: vec4<f32>, regs: array<vec4<f32>, 4>, konst_color: vec4<f32>) -> vec3<f32> {
switch sel {
@@ -107,7 +173,7 @@ fn tev_alpha_in(sel: u32, tex_color: vec4<f32>, ras_color: vec4<f32>, regs: arra
fn tev_combine_color(a: vec3<f32>, b: vec3<f32>, c: vec3<f32>, d: vec3<f32>,
bias: u32, sub: bool, scale: u32, do_clamp: bool) -> vec3<f32> {
let lerp = a * (vec3(1.0) - c) + b * c;
-
+
var result: vec3<f32>;
if sub {
result = d - lerp;
@@ -121,7 +187,7 @@ fn tev_combine_color(a: vec3<f32>, b: vec3<f32>, c: vec3<f32>, d: vec3<f32>,
case 2u: { result -= vec3(0.5); } // SubHalf
default: {} // Zero
}
-
+
// Scale
switch scale {
case 1u: { result *= 2.0; } // Scale2
@@ -133,38 +199,38 @@ fn tev_combine_color(a: vec3<f32>, b: vec3<f32>, c: vec3<f32>, d: vec3<f32>,
if do_clamp {
result = clamp(result, vec3(0.0), vec3(1.0));
}
-
+
return result;
}
// TEV alpha combiner: same formula as color but per-channel
fn tev_combine_alpha(a: f32, b: f32, c: f32, d: f32, bias: u32, sub: bool, scale: u32, do_clamp: bool) -> f32 {
let lerp = a * (1.0 - c) + b * c;
-
+
var result: f32;
if sub {
result = d - lerp;
} else {
result = d + lerp;
}
-
+
switch bias {
case 1u: { result += 0.5; }
case 2u: { result -= 0.5; }
default: {}
}
-
+
switch scale {
case 1u: { result *= 2.0; }
case 2u: { result *= 4.0; }
case 3u: { result *= 0.5; }
default: {}
}
-
+
if do_clamp {
result = clamp(result, 0.0, 1.0);
}
-
+
return result;
}
@@ -201,10 +267,7 @@ fn fs_main(in: VsOut) -> @location(0) vec4<f32> {
regs[2] = frame.tev_color_reg2;
regs[3] = frame.tev_color_reg3;
- // Inputs available to TEV stages
let ras_color = in.color;
- let tex_color = textureSample(tex, tex_sampler, in.tex0);
-
let num_stages = frame.num_tev_stages;
for (var stage = 0u; stage < 16u; stage++) {
@@ -212,6 +275,21 @@ fn fs_main(in: VsOut) -> @location(0) vec4<f32> {
break;
}
+ // Resolve per-stage texture from TevOrder
+ // TevStageOrder bit layout: texmap(0-2), texcoord(3-5), tex_enable(6)
+ let order = read_packed(frame.tev_orders, stage);
+ let texmap_idx = order & 7u;
+ let texcoord_idx = (order >> 3u) & 7u;
+ let tex_enabled = ((order >> 6u) & 1u) != 0u;
+
+ var tex_color: vec4<f32>;
+ if tex_enabled {
+ let uv = select_texcoord(in, texcoord_idx);
+ tex_color = sample_texmap(texmap_idx, uv);
+ } else {
+ tex_color = vec4<f32>(1.0, 1.0, 1.0, 1.0);
+ }
+
// Combine colors
let cenv = read_packed(frame.tev_color_env, stage);
diff --git a/crates/backend-wgpu/src/lib.rs b/crates/backend-wgpu/src/lib.rs
index a8c9da2..7dbd2b7 100644
--- a/crates/backend-wgpu/src/lib.rs
+++ b/crates/backend-wgpu/src/lib.rs
@@ -11,14 +11,29 @@ struct GpuVertex {
position: [f32; 3],
color: [f32; 4],
tex0: [f32; 2],
+ tex1: [f32; 2],
+ tex2: [f32; 2],
+ tex3: [f32; 2],
+ tex4: [f32; 2],
+ tex5: [f32; 2],
+ tex6: [f32; 2],
+ tex7: [f32; 2],
}
impl From<&gecko::flipper::gx::draw::Vertex> for GpuVertex {
fn from(v: &gecko::flipper::gx::draw::Vertex) -> Self {
+ let tc = |i: usize| v.texcoords[i].unwrap_or([0.0, 0.0]);
Self {
position: v.position,
color: v.color0,
- tex0: v.texcoords[0].unwrap_or([0.0, 0.0]),
+ tex0: tc(0),
+ tex1: tc(1),
+ tex2: tc(2),
+ tex3: tc(3),
+ tex4: tc(4),
+ tex5: tc(5),
+ tex6: tc(6),
+ tex7: tc(7),
}
}
}
@@ -30,6 +45,7 @@ struct FrameUniforms {
tev_konst_colors: [[f32; 4]; 16],
tev_color_env: [u32; 16],
tev_alpha_env: [u32; 16],
+ tev_orders: [u32; 16],
num_tev_stages: u32,
alpha_ref0: f32,
alpha_ref1: f32,
@@ -124,46 +140,52 @@ impl GxRenderer {
source: wgpu::ShaderSource::Wgsl(SHADER.into()),
});
- let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
- label: None,
- entries: &[
- wgpu::BindGroupLayoutEntry {
- binding: 0,
- visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
- ty: wgpu::BindingType::Buffer {
- ty: wgpu::BufferBindingType::Uniform,
- has_dynamic_offset: false,
- min_binding_size: wgpu::BufferSize::new(frame_uniform_size),
- },
- count: None,
+ // Bindings: 0=FrameUniforms, 1=DrawUniforms, 2-9=textures 0-7, 10-17=samplers 0-7
+ let mut layout_entries = vec![
+ wgpu::BindGroupLayoutEntry {
+ binding: 0,
+ visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
+ ty: wgpu::BindingType::Buffer {
+ ty: wgpu::BufferBindingType::Uniform,
+ has_dynamic_offset: false,
+ min_binding_size: wgpu::BufferSize::new(frame_uniform_size),
},
- wgpu::BindGroupLayoutEntry {
- binding: 1,
- visibility: wgpu::ShaderStages::VERTEX,
- ty: wgpu::BindingType::Buffer {
- ty: wgpu::BufferBindingType::Uniform,
- has_dynamic_offset: true,
- min_binding_size: wgpu::BufferSize::new(draw_uniform_size),
- },
- count: None,
- },
- wgpu::BindGroupLayoutEntry {
- binding: 2,
- visibility: wgpu::ShaderStages::FRAGMENT,
- ty: wgpu::BindingType::Texture {
- sample_type: wgpu::TextureSampleType::Float { filterable: true },
- view_dimension: wgpu::TextureViewDimension::D2,
- multisampled: false,
- },
- count: None,
+ count: None,
+ },
+ wgpu::BindGroupLayoutEntry {
+ binding: 1,
+ visibility: wgpu::ShaderStages::VERTEX,
+ ty: wgpu::BindingType::Buffer {
+ ty: wgpu::BufferBindingType::Uniform,
+ has_dynamic_offset: true,
+ min_binding_size: wgpu::BufferSize::new(draw_uniform_size),
},
- wgpu::BindGroupLayoutEntry {
- binding: 3,
- visibility: wgpu::ShaderStages::FRAGMENT,
- ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
- count: None,
+ count: None,
+ },
+ ];
+ for i in 0..8u32 {
+ layout_entries.push(wgpu::BindGroupLayoutEntry {
+ binding: 2 + i,
+ visibility: wgpu::ShaderStages::FRAGMENT,
+ ty: wgpu::BindingType::Texture {
+ sample_type: wgpu::TextureSampleType::Float { filterable: true },
+ view_dimension: wgpu::TextureViewDimension::D2,
+ multisampled: false,
},
- ],
+ count: None,
+ });
+ }
+ for i in 0..8u32 {
+ layout_entries.push(wgpu::BindGroupLayoutEntry {
+ binding: 10 + i,
+ visibility: wgpu::ShaderStages::FRAGMENT,
+ ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
+ count: None,
+ });
+ }
+ let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
+ label: None,
+ entries: &layout_entries,
});
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
@@ -226,35 +248,40 @@ impl GxRenderer {
);
let fallback_view = fallback_texture.create_view(&Default::default());
+ let mut initial_entries = vec![
+ wgpu::BindGroupEntry {
+ binding: 0,
+ resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
+ buffer: &frame_uniform_buffer,
+ offset: 0,
+ size: wgpu::BufferSize::new(frame_uniform_size),
+ }),
+ },
+ wgpu::BindGroupEntry {
+ binding: 1,
+ resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
+ buffer: &draw_uniform_buffer,
+ offset: 0,
+ size: wgpu::BufferSize::new(draw_uniform_size),
+ }),
+ },
+ ];
+ for i in 0..8u32 {
+ initial_entries.push(wgpu::BindGroupEntry {
+ binding: 2 + i,
+ resource: wgpu::BindingResource::TextureView(&fallback_view),
+ });
+ }
+ for i in 0..8u32 {
+ initial_entries.push(wgpu::BindGroupEntry {
+ binding: 10 + i,
+ resource: wgpu::BindingResource::Sampler(&sampler),
+ });
+ }
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None,
layout: &bind_group_layout,
- entries: &[
- wgpu::BindGroupEntry {
- binding: 0,
- resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
- buffer: &frame_uniform_buffer,
- offset: 0,
- size: wgpu::BufferSize::new(frame_uniform_size),
- }),
- },
- wgpu::BindGroupEntry {
- binding: 1,
- resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
- buffer: &draw_uniform_buffer,
- offset: 0,
- size: wgpu::BufferSize::new(draw_uniform_size),
- }),
- },
- wgpu::BindGroupEntry {
- binding: 2,
- resource: wgpu::BindingResource::TextureView(&fallback_view),
- },
- wgpu::BindGroupEntry {
- binding: 3,
- resource: wgpu::BindingResource::Sampler(&sampler),
- },
- ],
+ entries: &initial_entries,
});
let initial_capacity = 1024;
@@ -320,21 +347,27 @@ impl GxRenderer {
array_stride: std::mem::size_of::<GpuVertex>() as u64,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: &[
+ // position: vec3<f32>
wgpu::VertexAttribute {
format: wgpu::VertexFormat::Float32x3,
offset: 0,
shader_location: 0,
},
+ // color: vec4<f32>
wgpu::VertexAttribute {
format: wgpu::VertexFormat::Float32x4,
offset: 12,
shader_location: 1,
},
- wgpu::VertexAttribute {
- format: wgpu::VertexFormat::Float32x2,
- offset: 28,
- shader_location: 2,
- },
+ // tex0-tex7: vec2<f32> each
+ wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x2, offset: 28, shader_location: 2 },
+ wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x2, offset: 36, shader_location: 3 },
+ wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x2, offset: 44, shader_location: 4 },
+ wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x2, offset: 52, shader_location: 5 },
+ wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x2, offset: 60, shader_location: 6 },
+ wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x2, offset: 68, shader_location: 7 },
+ wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x2, offset: 76, shader_location: 8 },
+ wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x2, offset: 84, shader_location: 9 },
],
};
@@ -498,6 +531,7 @@ impl GxRenderer {
tev_konst_colors: dc.tev_konst_colors,
tev_color_env: dc.tev_color_env.map(|e| e.raw()),
tev_alpha_env: dc.tev_alpha_env.map(|e| e.raw()),
+ tev_orders: dc.tev_orders.map(|o| o.raw()),
num_tev_stages: dc.num_tev_stages as u32,
alpha_ref0: alpha_cmp.ref0() as f32 / 255.0,
alpha_ref1: alpha_cmp.ref1() as f32 / 255.0,
@@ -578,46 +612,57 @@ impl GxRenderer {
let pipeline = &self.pipeline_cache[&pipeline_key];
rpass.set_pipeline(pipeline);
- let (tex_view, sampler) = if let Some(desc) = &dc.textures[0] {
- let tex_key = (desc.ram_addr, desc.width, desc.height, desc.format);
- let sampler_key = (desc.wrap_s, desc.wrap_t, desc.mag_filter, desc.min_filter);
- (&self.texture_cache[&tex_key].1, &self.sampler_cache[&sampler_key])
- } else {
- (&self.fallback_view, &self.sampler_cache[&fallback_sampler_key])
- };
+ // Resolve all 8 texture views + samplers for this draw call
+ let mut tex_views: [&wgpu::TextureView; 8] = [&self.fallback_view; 8];
+ let mut tex_samplers: [&wgpu::Sampler; 8] =
+ [&self.sampler_cache[&fallback_sampler_key]; 8];
+ for slot in 0..8 {
+ if let Some(desc) = &dc.textures[slot] {
+ let tex_key = (desc.ram_addr, desc.width, desc.height, desc.format);
+ let sampler_key =
+ (desc.wrap_s, desc.wrap_t, desc.mag_filter, desc.min_filter);
+ tex_views[slot] = &self.texture_cache[&tex_key].1;
+ tex_samplers[slot] = &self.sampler_cache[&sampler_key];
+ }
+ }
let frame_offset = (index as u64 * frame_stride as u64) as wgpu::BufferAddress;
let draw_offset = (index as u64 * self.draw_uniform_stride) as u32;
+ let mut entries = vec![
+ wgpu::BindGroupEntry {
+ binding: 0,
+ resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
+ buffer: &self.frame_uniform_buffer,
+ offset: frame_offset,
+ size: wgpu::BufferSize::new(std::mem::size_of::<FrameUniforms>() as u64),
+ }),
+ },
+ wgpu::BindGroupEntry {
+ binding: 1,
+ resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
+ buffer: &self.draw_uniform_buffer,
+ offset: 0,
+ size: wgpu::BufferSize::new(std::mem::size_of::<DrawUniforms>() as u64),
+ }),
+ },
+ ];
+ for i in 0..8u32 {
+ entries.push(wgpu::BindGroupEntry {
+ binding: 2 + i,
+ resource: wgpu::BindingResource::TextureView(tex_views[i as usize]),
+ });
+ }
+ for i in 0..8u32 {
+ entries.push(wgpu::BindGroupEntry {
+ binding: 10 + i,
+ resource: wgpu::BindingResource::Sampler(tex_samplers[i as usize]),
+ });
+ }
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None,
layout: &self.bind_group_layout,
- entries: &[
- wgpu::BindGroupEntry {
- binding: 0,
- resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
- buffer: &self.frame_uniform_buffer,
- offset: frame_offset,
- size: wgpu::BufferSize::new(std::mem::size_of::<FrameUniforms>() as u64),
- }),
- },
- wgpu::BindGroupEntry {
- binding: 1,
- resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
- buffer: &self.draw_uniform_buffer,
- offset: 0,
- size: wgpu::BufferSize::new(std::mem::size_of::<DrawUniforms>() as u64),
- }),
- },
- wgpu::BindGroupEntry {
- binding: 2,
- resource: wgpu::BindingResource::TextureView(tex_view),
- },
- wgpu::BindGroupEntry {
- binding: 3,
- resource: wgpu::BindingResource::Sampler(sampler),
- },
- ],
+ entries: &entries,
});
rpass.set_bind_group(0, &bind_group, &[draw_offset]);
diff --git a/crates/gecko/src/flipper/gx.rs b/crates/gecko/src/flipper/gx.rs
index d0e94f0..62434bc 100644
--- a/crates/gecko/src/flipper/gx.rs
+++ b/crates/gecko/src/flipper/gx.rs
@@ -428,6 +428,7 @@ impl GraphicsProcessor {
vertices,
modelview,
textures: self.cur_textures,
+ tev_orders: self.resolve_tev_orders(),
tev_color_env: self.cur_tev_color_env,
tev_alpha_env: self.cur_tev_alpha_env,
tev_color_regs,
@@ -900,6 +901,22 @@ impl GraphicsProcessor {
}
/// Resolve TEV color registers (lo+hi) into [r,g,b,a] float arrays
+ fn resolve_tev_orders(&self) -> [regs::TevStageOrder; 16] {
+ let mut orders = [regs::TevStageOrder::default(); 16];
+ for i in 0..8 {
+ let reg = self.cur_tev_orders[i];
+ orders[2 * i] = regs::TevStageOrder::default()
+ .with_texmap(reg.texmap0())
+ .with_texcoord(reg.texcoord0())
+ .with_tex_enable(reg.tex_enable0());
+ orders[2 * i + 1] = regs::TevStageOrder::default()
+ .with_texmap(reg.texmap1())
+ .with_texcoord(reg.texcoord1())
+ .with_tex_enable(reg.tex_enable1());
+ }
+ orders
+ }
+
fn resolve_tev_color_regs(&self) -> [[f32; 4]; 4] {
std::array::from_fn(|i| {
let lo = self.cur_tev_color_regs_lo[i];
diff --git a/crates/gecko/src/flipper/gx/draw.rs b/crates/gecko/src/flipper/gx/draw.rs
index f2b6a90..5a389ce 100644
--- a/crates/gecko/src/flipper/gx/draw.rs
+++ b/crates/gecko/src/flipper/gx/draw.rs
@@ -1,4 +1,4 @@
-use super::regs::{AlphaCompare, BlendMode, MagFilter, MinFilter, TevAlphaEnv, TevColorEnv, WrapMode, ZMode};
+use super::regs::{AlphaCompare, BlendMode, MagFilter, MinFilter, TevAlphaEnv, TevColorEnv, TevStageOrder, WrapMode, ZMode};
use chapa::BitEnum;
#[derive(Debug)]
@@ -74,6 +74,9 @@ pub struct DrawCall {
// Textures bound at draw time
pub textures: [Option<TextureDescriptor>; 8],
+ // Per-TEV-stage order (resolved from paired TevOrder registers)
+ pub tev_orders: [TevStageOrder; 16],
+
// TEV state snapshot
pub tev_color_env: [TevColorEnv; 16],
pub tev_alpha_env: [TevAlphaEnv; 16],
diff --git a/crates/gecko/src/flipper/gx/regs.rs b/crates/gecko/src/flipper/gx/regs.rs
index 4c8832a..0d2ce43 100644
--- a/crates/gecko/src/flipper/gx/regs.rs
+++ b/crates/gecko/src/flipper/gx/regs.rs
@@ -611,6 +611,19 @@ pub struct TevOrder {
pub channel1: RasterChannel,
}
+#[chapa::bitfield(u32, order = lsb0)]
+#[derive(Debug, Clone, Copy, Default)]
+pub struct TevStageOrder {
+ #[bits(0..=2)]
+ pub texmap: u8,
+
+ #[bits(3..=5)]
+ pub texcoord: u8,
+
+ #[bits(6)]
+ pub tex_enable: bool,
+}
+
#[chapa::bitfield(u32, order = lsb0)]
#[derive(Debug, Clone, Copy)]
pub struct TxSetMode0 {