From 93db2c12547de300314093d9d07ea9becaf18f15 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 2 Oct 2023 18:00:07 -0500 Subject: [PATCH] nak: Plumb clip/cull enables through nak Part-of: --- src/nouveau/compiler/nak.h | 3 +++ src/nouveau/compiler/nak.rs | 19 +++++++++++++++++++ src/nouveau/vulkan/nvk_shader.c | 7 ++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/nouveau/compiler/nak.h b/src/nouveau/compiler/nak.h index 0bf07953cfd..5459babe203 100644 --- a/src/nouveau/compiler/nak.h +++ b/src/nouveau/compiler/nak.h @@ -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 */ diff --git a/src/nouveau/compiler/nak.rs b/src/nouveau/compiler/nak.rs index 65ac9e1d24b..8b0353b7006 100644 --- a/src/nouveau/compiler/nak.rs +++ b/src/nouveau/compiler/nak.rs @@ -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), }; diff --git a/src/nouveau/vulkan/nvk_shader.c b/src/nouveau/vulkan/nvk_shader.c index 5c7269c30b0..af8edc42c07 100644 --- a/src/nouveau/vulkan/nvk_shader.c +++ b/src/nouveau/vulkan/nvk_shader.c @@ -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++) {