mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 15:30:14 +01:00
nak: Move NIR enum translation out of nak_sph.rs
Better to keep all the NIR stuff together. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
parent
145213fd2c
commit
40ec7efa07
2 changed files with 19 additions and 30 deletions
|
|
@ -43,13 +43,19 @@ fn init_info_from_nir(nir: &nir_shader, sm: u8) -> ShaderInfo {
|
||||||
MESA_SHADER_FRAGMENT => ShaderStageInfo::Fragment,
|
MESA_SHADER_FRAGMENT => ShaderStageInfo::Fragment,
|
||||||
MESA_SHADER_GEOMETRY => {
|
MESA_SHADER_GEOMETRY => {
|
||||||
let info_gs = unsafe { &nir.info.__bindgen_anon_1.gs };
|
let info_gs = unsafe { &nir.info.__bindgen_anon_1.gs };
|
||||||
|
let output_topology = match info_gs.input_primitive {
|
||||||
|
MESA_PRIM_POINTS => OutputTopology::PointList,
|
||||||
|
MESA_PRIM_TRIANGLES | MESA_PRIM_LINE_STRIP => {
|
||||||
|
OutputTopology::LineStrip
|
||||||
|
}
|
||||||
|
MESA_PRIM_TRIANGLE_STRIP => OutputTopology::TriangleStrip,
|
||||||
|
_ => panic!("Invalid GS input primitive"),
|
||||||
|
};
|
||||||
|
|
||||||
ShaderStageInfo::Geometry(GeometryShaderInfo {
|
ShaderStageInfo::Geometry(GeometryShaderInfo {
|
||||||
stream_out_mask: info_gs.active_stream_mask(),
|
stream_out_mask: info_gs.active_stream_mask(),
|
||||||
threads_per_input_primitive: info_gs.invocations,
|
threads_per_input_primitive: info_gs.invocations,
|
||||||
output_topology: OutputTopology::from(
|
output_topology: output_topology,
|
||||||
info_gs.input_primitive,
|
|
||||||
),
|
|
||||||
max_output_vertex_count: info_gs.vertices_out,
|
max_output_vertex_count: info_gs.vertices_out,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -1457,6 +1463,16 @@ impl<'a> ShaderFromNir<'a> {
|
||||||
nir_intrinsic_load_barycentric_sample => {
|
nir_intrinsic_load_barycentric_sample => {
|
||||||
(InterpFreq::Pass, InterpLoc::Centroid)
|
(InterpFreq::Pass, InterpLoc::Centroid)
|
||||||
}
|
}
|
||||||
|
_ => panic!("Unsupported barycentric"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let interp_mode = match bary.interp_mode() {
|
||||||
|
INTERP_MODE_NONE | INTERP_MODE_SMOOTH => {
|
||||||
|
PixelImap::Perspective
|
||||||
|
}
|
||||||
|
INTERP_MODE_FLAT => PixelImap::Constant,
|
||||||
|
INTERP_MODE_NOPERSPECTIVE => PixelImap::ScreenLinear,
|
||||||
|
INTERP_MODE_EXPLICIT => PixelImap::Unused,
|
||||||
_ => panic!("Unsupported interp mode"),
|
_ => panic!("Unsupported interp mode"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1472,8 +1488,6 @@ impl<'a> ShaderFromNir<'a> {
|
||||||
_ => panic!("Unsupported interp mode"),
|
_ => panic!("Unsupported interp mode"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let interp_mode = PixelImap::from(bary.interp_mode());
|
|
||||||
|
|
||||||
assert!(intrin.def.bit_size() == 32);
|
assert!(intrin.def.bit_size() == 32);
|
||||||
let dst =
|
let dst =
|
||||||
b.alloc_ssa(RegFile::GPR, intrin.def.num_components());
|
b.alloc_ssa(RegFile::GPR, intrin.def.num_components());
|
||||||
|
|
|
||||||
|
|
@ -50,19 +50,6 @@ pub enum OutputTopology {
|
||||||
TriangleStrip,
|
TriangleStrip,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<mesa_prim> for OutputTopology {
|
|
||||||
fn from(value: mesa_prim) -> Self {
|
|
||||||
match value {
|
|
||||||
MESA_PRIM_POINTS => OutputTopology::PointList,
|
|
||||||
MESA_PRIM_TRIANGLES | MESA_PRIM_LINE_STRIP => {
|
|
||||||
OutputTopology::LineStrip
|
|
||||||
}
|
|
||||||
MESA_PRIM_TRIANGLE_STRIP => OutputTopology::TriangleStrip,
|
|
||||||
_ => panic!("Invalid mesa_prim {}", value),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum PixelImap {
|
pub enum PixelImap {
|
||||||
Unused,
|
Unused,
|
||||||
|
|
@ -71,18 +58,6 @@ pub enum PixelImap {
|
||||||
ScreenLinear,
|
ScreenLinear,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<glsl_interp_mode> for PixelImap {
|
|
||||||
fn from(value: glsl_interp_mode) -> Self {
|
|
||||||
match value {
|
|
||||||
INTERP_MODE_NONE | INTERP_MODE_SMOOTH => PixelImap::Perspective,
|
|
||||||
INTERP_MODE_FLAT => PixelImap::Constant,
|
|
||||||
INTERP_MODE_NOPERSPECTIVE => PixelImap::ScreenLinear,
|
|
||||||
INTERP_MODE_EXPLICIT => PixelImap::Unused,
|
|
||||||
_ => panic!("Unsupported INTERP_MODE"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<PixelImap> for u8 {
|
impl From<PixelImap> for u8 {
|
||||||
fn from(value: PixelImap) -> u8 {
|
fn from(value: PixelImap) -> u8 {
|
||||||
match value {
|
match value {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue