From 14211ec3c4e56e59f479dbac23123ea61eab7d91 Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Wed, 22 Jan 2025 11:57:53 -0500 Subject: Remove unnecessary parameters from Metal entry point signature (#6131) * fix metal entry point global params * address review comments, cleanup and test * remove dead code * undo accidental change * address review comments and cleanup * minor fix and cleanup --------- Co-authored-by: Yong He --- source/slang/slang-ir-entry-point-uniforms.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'source/slang/slang-ir-entry-point-uniforms.cpp') diff --git a/source/slang/slang-ir-entry-point-uniforms.cpp b/source/slang/slang-ir-entry-point-uniforms.cpp index b3073a97d..12dcd187a 100644 --- a/source/slang/slang-ir-entry-point-uniforms.cpp +++ b/source/slang/slang-ir-entry-point-uniforms.cpp @@ -494,19 +494,27 @@ struct MoveEntryPointUniformParametersToGlobalScope : PerEntryPointPass // for CPU/CUDA) that might want to treat entry-point parameters // different from other cases. // - // TODO: Once we have support for multiple entry points to be emitted - // at once, we need a way to associate these per-entry-point parameters - // more closely with the original entry point. The two easiest options - // are: + // We need a way to associate these per-entry-point parameters + // more closely with the original entry point. The two current + // methods are: // // 1. Don't move the new aggregate parameter to the global scope // on those targets, and instead keep it as a parameter of the - // entry point. + // entry point. This is used for CPU/CUDA targets. // - // 2. Use a decoration on the entry point itself to point at the - // global parameter for its per-entry-point parameter data. + // 2. Use a decoration on the global param itself to point at the + // entry point for its per-entry-point parameter data, without moving + // the parameter to the global scope. This is used for Metal targets, as + // Metal does not have global parameters at the global scope. // - builder->addDecoration(globalParam, kIROp_EntryPointParamDecoration); + // Method (1) is not used because Metal contains shading language concepts + // such as binding offets, similar to other shading language targets. + // We want to reuse code from other shading language targets for Metal, hence + // we move parameters to the global scope, and then move the parameters back to + // the entry points that they originate from. The originating entry points are + // tracked through this decoration. + // + builder->addEntryPointParamDecoration(globalParam, entryPointFunc); param->replaceUsesWith(globalParam); param->removeAndDeallocate(); -- cgit v1.2.3