nak: Move clip, cull, and XFB into a nak_shader_info.vtg

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26197>
This commit is contained in:
Faith Ekstrand 2023-11-14 16:38:37 -06:00 committed by Marge Bot
parent 440adf7970
commit a232050204
3 changed files with 19 additions and 21 deletions

View file

@ -109,10 +109,12 @@ struct nak_shader_info {
uint32_t dummy;
};
uint8_t clip_enable;
uint8_t cull_enable;
struct {
uint8_t clip_enable;
uint8_t cull_enable;
struct nak_xfb_info xfb;
struct nak_xfb_info xfb;
} vtg;
/** Shader header for 3D stages */
uint32_t hdr[32];

View file

@ -351,26 +351,22 @@ 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 {
vtg: 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()
let clip_enable = (1_u32 << num_clip) - 1;
let cull_enable = ((1_u32 << num_cull) - 1) << num_clip;
nak_shader_info__bindgen_ty_2 {
clip_enable: clip_enable.try_into().unwrap(),
cull_enable: cull_enable.try_into().unwrap(),
xfb: unsafe { nak_xfb_from_nir(nir.xfb_info) },
}
}
_ => 0,
_ => unsafe { std::mem::zeroed() },
},
xfb: unsafe { nak_xfb_from_nir(nir.xfb_info) },
hdr: nak_sph::encode_header(&s.info, fs_key),
};

View file

@ -428,8 +428,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 = bin->info.clip_enable;
shader->vs.cull_enable = bin->info.cull_enable;
shader->vs.clip_enable = bin->info.vtg.clip_enable;
shader->vs.cull_enable = bin->info.vtg.cull_enable;
if (nir->info.stage == MESA_SHADER_TESS_EVAL) {
shader->tp.domain_type = bin->info.ts.domain;
@ -441,7 +441,7 @@ nvk_compile_nir_with_nak(struct nvk_physical_device *pdev,
bool has_xfb = false;
for (unsigned b = 0; b < 4; b++) {
if (bin->info.xfb.attr_count[b] > 0) {
if (bin->info.vtg.xfb.attr_count[b] > 0) {
has_xfb = true;
break;
}
@ -449,8 +449,8 @@ nvk_compile_nir_with_nak(struct nvk_physical_device *pdev,
if (has_xfb) {
shader->xfb = malloc(sizeof(*shader->xfb));
STATIC_ASSERT(sizeof(*shader->xfb) == sizeof(bin->info.xfb));
memcpy(shader->xfb, &bin->info.xfb, sizeof(*shader->xfb));
STATIC_ASSERT(sizeof(*shader->xfb) == sizeof(bin->info.vtg.xfb));
memcpy(shader->xfb, &bin->info.vtg.xfb, sizeof(*shader->xfb));
}
break;
}