summaryrefslogtreecommitdiffstats
path: root/src/libs/dxvk-native-1.9.2a/src/dxso/dxso_module.h
blob: 1f5cda85bdd8c648e4113cce82cb7bfb04e24e0e (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once

#include "dxso_reader.h"
#include "dxso_code.h"
#include "dxso_header.h"
#include "dxso_ctab.h"

#include "dxso_isgn.h"
#include "dxso_analysis.h"

#include "../d3d9/d3d9_constant_layout.h"
#include "../d3d9/d3d9_shader_permutations.h"

#include <vector>

namespace dxvk {

  class DxsoCompiler;
  class DxsoCode;
  struct DxsoModuleInfo;

  /**
   * \brief DXSO shader module, a d3d9 shader object.
   */
  class DxsoModule {

  public:

    DxsoModule(DxsoReader& reader);

    const DxsoProgramInfo& info() {
      return m_header.info();
    }

    DxsoAnalysisInfo analyze();

    /**
     * \brief Compiles DXSO shader to SPIR-V module
     * 
     * \param [in] moduleInfo DXSO module info
     * \param [in] fileName File name, will be added to
     *        the compiled SPIR-V for debugging purposes.
     * \returns The compiled shader object
     */
    DxsoPermutations compile(
      const DxsoModuleInfo&     moduleInfo,
      const std::string&        fileName,
      const DxsoAnalysisInfo&   analysis,
      const D3D9ConstantLayout& layout);

    const DxsoIsgn& isgn() {
      return m_isgn;
    }

    const DxsoShaderMetaInfo& meta() { return m_meta; }

    const DxsoDefinedConstants& constants() { return m_constants; }

    uint32_t usedSamplers() { return m_usedSamplers; }

    uint32_t usedRTs() { return m_usedRTs; }

  private:

    void runCompiler(
            DxsoCompiler&       compiler,
            DxsoCodeIter        iter) const;

    void runAnalyzer(
            DxsoAnalyzer&       analyzer,
            DxsoCodeIter        iter) const;

    DxsoHeader      m_header;
    DxsoCode        m_code;

    DxsoIsgn        m_isgn;
    uint32_t        m_usedSamplers;
    uint32_t        m_usedRTs;

    DxsoShaderMetaInfo   m_meta;
    DxsoDefinedConstants m_constants;

  };

}