https://github.com/shader-slang/slang
Tip revision: 5902acdabc4445a65741a7a6a3a95f223e301059 authored by Yong He on 23 January 2024, 07:19:40 UTC
[LSP] Fetch configs directly from didConfigurationChanged message. (#3478)
[LSP] Fetch configs directly from didConfigurationChanged message. (#3478)
Tip revision: 5902acd
slang-ir-specialize-buffer-load-arg.h
// slang-ir-specialize-buffer-load-arg.h
#pragma once
namespace Slang
{
struct CodeGenContext;
struct IRModule;
/// Specialize functions in `module` that are called with direct loads from buffers.
///
/// For example:
///
/// struct Params { /* many fields */ }
/// int helper(Params p, int x) { return p.justOneField + x; }
/// ...
/// ConstantBuffer<Params> gParams;
/// ...
/// int z = helper(gParams, y);
///
/// In this case, the function `helper` declares a very large structure type as
/// a by-value argument. Depending on the final code-generation target, this could
/// result in output code that loads the entire contents of `gParams` before passing
/// it to `helper`, which then uses only a single field (rendering the rest of the load
/// operations wasted).
///
/// This pass is designed to specialize a callee function like `helper` based on call
/// sites in this form, so that the output code is:
///
/// struct Params { /* as before */ }
/// ConstantBuffer<Params> gParams;
/// int helper_1(int x) { return gParams.justOneField + x; }
/// ...
/// int z = helper_1(y);
///
/// Note how in the transformed code, there is no longer any attempt to load the rest
/// of the contents of `gParams`.
///
void specializeFuncsForBufferLoadArgs(
CodeGenContext* codeGenContext,
IRModule* module);
}