Module: Mesa Branch: main Commit: a946071546819105fcf6a539e1e32d000968782c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a946071546819105fcf6a539e1e32d000968782c
Author: Faith Ekstrand <[email protected]> Date: Tue Nov 14 12:23:08 2023 -0600 nvk: Use nak_fs_key instead of rolling our own Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26197> --- src/nouveau/vulkan/nvk_codegen.c | 8 ++++---- src/nouveau/vulkan/nvk_graphics_pipeline.c | 7 +++---- src/nouveau/vulkan/nvk_shader.c | 14 ++------------ src/nouveau/vulkan/nvk_shader.h | 11 +++-------- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/nouveau/vulkan/nvk_codegen.c b/src/nouveau/vulkan/nvk_codegen.c index dc37f35e992..e888fe5412a 100644 --- a/src/nouveau/vulkan/nvk_codegen.c +++ b/src/nouveau/vulkan/nvk_codegen.c @@ -700,7 +700,7 @@ nvk_hdr_interp_mode(const struct nv50_ir_varying *var) static int -nvk_fs_gen_header(struct nvk_shader *fs, const struct nvk_fs_key *key, +nvk_fs_gen_header(struct nvk_shader *fs, const struct nak_fs_key *key, struct nv50_ir_prog_info_out *info) { unsigned i, c, a, m; @@ -843,7 +843,7 @@ nvk_fill_transform_feedback_state(struct nir_shader *nir, VkResult nvk_cg_compile_nir(struct nvk_physical_device *pdev, nir_shader *nir, - const struct nvk_fs_key *fs_key, + const struct nak_fs_key *fs_key, struct nvk_shader *shader) { struct nv50_ir_prog_info *info; @@ -880,9 +880,9 @@ nvk_cg_compile_nir(struct nvk_physical_device *pdev, nir_shader *nir, if (info_out.bin.fixupData) { nv50_ir_apply_fixups(info_out.bin.fixupData, info_out.bin.code, - fs_key && fs_key->force_per_sample, + fs_key && fs_key->force_sample_shading, false /* flatshade */, false /* alphatest */, - fs_key && fs_key->msaa); + fs_key && fs_key->force_sample_shading); } shader->stage = nir->info.stage; diff --git a/src/nouveau/vulkan/nvk_graphics_pipeline.c b/src/nouveau/vulkan/nvk_graphics_pipeline.c index 49d11c09216..4af8b6cd951 100644 --- a/src/nouveau/vulkan/nvk_graphics_pipeline.c +++ b/src/nouveau/vulkan/nvk_graphics_pipeline.c @@ -42,7 +42,7 @@ emit_pipeline_rs_state(struct nv_push *p, } static void -nvk_populate_fs_key(struct nvk_fs_key *key, +nvk_populate_fs_key(struct nak_fs_key *key, const struct vk_multisample_state *ms, const struct vk_graphics_pipeline_state *state) { @@ -55,10 +55,9 @@ nvk_populate_fs_key(struct nvk_fs_key *key, if (ms == NULL || ms->rasterization_samples <= 1) return; - key->msaa = ms->rasterization_samples; if (ms->sample_shading_enable && (ms->rasterization_samples * ms->min_sample_shading) > 1.0) - key->force_per_sample = true; + key->force_sample_shading = true; } static void @@ -356,7 +355,7 @@ nvk_graphics_pipeline_create(struct nvk_device *dev, if (nir[stage] == NULL) continue; - struct nvk_fs_key fs_key_tmp, *fs_key = NULL; + struct nak_fs_key fs_key_tmp, *fs_key = NULL; if (stage == MESA_SHADER_FRAGMENT) { nvk_populate_fs_key(&fs_key_tmp, state.ms, &state); fs_key = &fs_key_tmp; diff --git a/src/nouveau/vulkan/nvk_shader.c b/src/nouveau/vulkan/nvk_shader.c index 1ff8f4d3af4..42db934b2c1 100644 --- a/src/nouveau/vulkan/nvk_shader.c +++ b/src/nouveau/vulkan/nvk_shader.c @@ -395,19 +395,9 @@ nvk_shader_dump(struct nvk_shader *shader) static VkResult nvk_compile_nir_with_nak(struct nvk_physical_device *pdev, nir_shader *nir, - const struct nvk_fs_key *nvk_fs_key, + const struct nak_fs_key *fs_key, struct nvk_shader *shader) { - struct nak_fs_key fs_key_tmp; - const struct nak_fs_key *fs_key = NULL; - if (nir->info.stage == MESA_SHADER_FRAGMENT && nvk_fs_key != NULL) { - fs_key_tmp = (struct nak_fs_key) { - .zs_self_dep = nvk_fs_key->zs_self_dep, - .force_sample_shading = nvk_fs_key->force_per_sample, - }; - fs_key = &fs_key_tmp; - } - struct nak_shader_bin *bin = nak_compile_shader(nir, pdev->nak, fs_key); shader->stage = nir->info.stage; @@ -481,7 +471,7 @@ nvk_compile_nir_with_nak(struct nvk_physical_device *pdev, VkResult nvk_compile_nir(struct nvk_physical_device *pdev, nir_shader *nir, - const struct nvk_fs_key *fs_key, + const struct nak_fs_key *fs_key, struct nvk_shader *shader) { if (use_nak(pdev, nir->info.stage)) diff --git a/src/nouveau/vulkan/nvk_shader.h b/src/nouveau/vulkan/nvk_shader.h index d8a174a266d..793509ee4ab 100644 --- a/src/nouveau/vulkan/nvk_shader.h +++ b/src/nouveau/vulkan/nvk_shader.h @@ -8,6 +8,7 @@ #include "nvk_private.h" #include "nvk_device_memory.h" +#include "nak.h" #include "nir.h" #include "nouveau_bo.h" @@ -24,12 +25,6 @@ struct vk_shader_module; #define TU102_SHADER_HEADER_SIZE (32 * 4) #define NVC0_MAX_SHADER_HEADER_SIZE TU102_SHADER_HEADER_SIZE -struct nvk_fs_key { - bool msaa; - bool force_per_sample; - bool zs_self_dep; -}; - struct nvk_transform_feedback_state { uint32_t stride[4]; uint8_t stream[4]; @@ -145,7 +140,7 @@ nvk_lower_nir(struct nvk_device *dev, nir_shader *nir, VkResult nvk_compile_nir(struct nvk_physical_device *dev, nir_shader *nir, - const struct nvk_fs_key *fs_key, + const struct nak_fs_key *fs_key, struct nvk_shader *shader); VkResult @@ -169,7 +164,7 @@ void nvk_cg_preprocess_nir(nir_shader *nir); void nvk_cg_optimize_nir(nir_shader *nir); VkResult nvk_cg_compile_nir(struct nvk_physical_device *pdev, nir_shader *nir, - const struct nvk_fs_key *fs_key, + const struct nak_fs_key *fs_key, struct nvk_shader *shader); #endif
