はじめに

特に次の不明点が明確になる様にします。

  • リフレクション情報はどの様に付加されるのか?
  • LLVM-ILとリフレクション情報の対応付けはどうされるのか?
    もっともSPIR-VはLLVM-ILは全く関係ないと思うが。

参考

用語

  • Word: 32bit
  • <id>: 数字
    常に1word消費します。
  • Result<id>: 命令の結果の定義?
  • Literal String: null終端の文字列

デバグ命令

These debug instructions, which must be in the following order:
a. all OpString, OpSourceExtension, OpSource, and OpSourceContinued, without forward references.
b. all OpName and all OpMemberName

必須命令

  • OpEntryPoint
    OpEntryPoint Fragment %4 "main" %31 %33 %42 %57
    %4 = OpFunction %2 None %3                  ; main()
    %31 = OpVariable %30 Output
    %33 = OpVariable %32 Input
    %42 = OpVariable %32 Input
    %57 = OpVariable %32 Input

    Fragment: Execution Model
    %4: OpFunction の Result
    “main”: エントリーポイントの名前
    %31, %33,… : OpVariable の結果です。in, out を定義します。

基本命令

  • OpTypeInt
    %13 = OpTypeInt 32 0                         ; 32-bit int, sign-less
    
  • OpTypeFloat
    %6 = OpTypeFloat 32                         ; 32-bit float
    %7 = OpTypeVector %6 4                      ; vec4
    

    Result<id> LiteralNumber-width
    Result<id>: Op の戻り値(フロート型のオブジェクト?)
    width: ビット幅

  • OpTypeVector
    vector 型の宣言をします。

    %6 = OpTypeFloat 32                         ; 32-bit float
    %7 = OpTypeVector %6 4                      ; vec4
    

    Result<id> <id> LiteralNumber-ComponentCount
    Result<id>: Op の戻り値( vector 型のオブジェクト?)
    <id>: Component Type
    LiteralNumber-ComponentCount: コンポーネント数

メモリ操作命令

  • OpVariable
    オブジェクトをメモリに確保します。
    in, out, uniform 変数を new します。
    Result Type は OpTypePointer です。
    c.f. Result Type は結果の型情報を教える引数です。
    c.f. Result<id> は戻り値です。

    %6 = OpTypeFloat 32                         ; 32-bit float オブジェクトが %6 に代入されます。
    %7 = OpTypeVector %6 4                      ; vec4
    %32 = OpTypePointer Input %7                ; %7 へのポインタ型
    %33 = OpVariable %32 Input                  ; メモリにオブジェクトをアロケートします。%32 にアロケートします。
                                                ; OpVariableType に対して OpLoad/Store ができます。
    %34 = OpLoad %7 %33                         ;
  • OpTypePointer
    ポインタ型の宣言です。
    Input: ポンタ変数から出力される(他の変数への input 用途: Load される)
    Output: ポインタ変数へ出力される(他の変数から output される:Store される)

    %32 = OpTypePointer Input %7                ; %7 型のポインタ型の宣言
  • OpLoad
    %33 からロードします。
    %34 はオブジェクト(=実態)になります。

    %34 = OpLoad %7 %33                         ; %7 は戻り値の型、%33 は OpVariable オブジェクトへのポインタです。

     

リフレクション情報の付加

  • OpDecorate
    binding や location を指定できます。

別ページで詳細に調べます。