summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-specialize-function-call.h
blob: 868f9def24cd85094d9fa6932d3496ff1f9cd5a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// slang-ir-specialize-function-call.h
#pragma once

namespace Slang
{
    class BackEndCompileRequest;
    class TargetRequest;
    struct IRInst;
    struct IRModule;
    struct IRParam;

    class FunctionCallSpecializeCondition
    {
    public:
        virtual bool doesParamWantSpecialization(IRParam* param, IRInst* arg) = 0;

        virtual bool isParamSuitableForSpecialization(IRParam* param, IRInst* arg);
    };


    /// Specialize calls to functions with certain type of parameters.
    ///
    /// For any function that has a specific type of input parameters
    /// this pass will rewrite its call sites that pass suitable arguments
    /// (e.g., direct references to global shader parameters) to instead call
    /// a specialized variant of the function that does not have
    /// those resource parameters (and instead, e.g, refers to the
    /// global shader parameters directly).
    ///
    void specializeFunctionCalls(
        BackEndCompileRequest* compileRequest,
        TargetRequest* targetRequest,
        IRModule* module,
        FunctionCallSpecializeCondition* condition);
}