nak: Plumb clip/cull enables through nak

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand 2023-10-02 18:00:07 -05:00 committed by Marge Bot
parent d4d7f26151
commit 93db2c1254
3 changed files with 24 additions and 5 deletions

View file

@ -84,6 +84,9 @@ struct nak_shader_info {
uint32_t dummy;
};
uint8_t clip_enable;
uint8_t cull_enable;
struct nvk_xfb_info xfb;
/** Shader header for 3D stages */

View file

@ -311,6 +311,25 @@ pub extern "C" fn nak_compile_shader(
}
_ => nak_shader_info__bindgen_ty_1 { dummy: 0 },
},
clip_enable: match &s.info.stage {
ShaderStageInfo::Geometry(_)
| ShaderStageInfo::Tessellation
| ShaderStageInfo::Vertex => {
let num_clip = nir.info.clip_distance_array_size();
((1_u32 << num_clip) - 1).try_into().unwrap()
}
_ => 0,
},
cull_enable: match &s.info.stage {
ShaderStageInfo::Geometry(_)
| ShaderStageInfo::Tessellation
| ShaderStageInfo::Vertex => {
let num_clip = nir.info.clip_distance_array_size();
let num_cull = nir.info.cull_distance_array_size();
(((1_u32 << num_cull) - 1) << num_clip).try_into().unwrap()
}
_ => 0,
},
xfb: unsafe { nak_xfb_from_nir(nir.xfb_info) },
hdr: nak_sph::encode_header(&s.info, fs_key),
};

View file

@ -1264,11 +1264,8 @@ nvk_compile_nir_with_nak(struct nvk_physical_device *pdev,
case MESA_SHADER_VERTEX:
case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY: {
shader->vs.clip_enable =
BITFIELD_RANGE(0, nir->info.clip_distance_array_size);
shader->vs.cull_enable =
BITFIELD_RANGE(nir->info.clip_distance_array_size,
nir->info.cull_distance_array_size);
shader->vs.clip_enable = bin->info.clip_enable;
shader->vs.cull_enable = bin->info.cull_enable;
bool has_xfb = false;
for (unsigned b = 0; b < 4; b++) {