File: GenericShaderState.hpp

package info (click to toggle)
intel-graphics-compiler2 2.16.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 106,644 kB
  • sloc: cpp: 805,640; lisp: 287,672; ansic: 16,414; python: 3,952; yacc: 2,588; lex: 1,666; pascal: 313; sh: 186; makefile: 35
file content (116 lines) | stat: -rw-r--r-- 4,192 bytes parent folder | download
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*========================== begin_copyright_notice ============================

Copyright (C) 2024 Intel Corporation

SPDX-License-Identifier: MIT

============================= end_copyright_notice ===========================*/

#pragma once

#include "common/LLVMWarningsPush.hpp"
#include <llvm/IR/Function.h>
#include <llvm/IR/Module.h>
#include "common/LLVMWarningsPop.hpp"
#include "Compiler/CodeGenPublic.h"
#include "common/Types.hpp"

namespace IGC {
class GenericShaderState {
public:
  GenericShaderState(const llvm::Function &Entry, CodeGenContext &Ctx);

  uint m_constantBufferLoaded = 0;
  uint m_numBlocks = 0;
  uint64_t m_uavLoaded = 0;
  uint m_shaderResourceLoaded[4]{};
  uint m_renderTargetLoaded = 0;
  bool m_HasEval = false;
  uint m_NOSBufferSize = 0;
  bool isMessageTargetDataCacheDataPort = false;
  uint m_constantBufferMask = 0;
  std::vector<USC::SConstantGatherEntry> gatherMap;
  uint m_ConstantBufferLength = 0;
  int m_cbSlot = -1;
  uint m_statelessCBPushedSize = 0;
  // Holds max used binding table entry index.
  uint32_t m_BindingTableEntryCount = 0;
  // Holds binding table entries bitmap.
  uint32_t m_BindingTableUsedEntriesBitmap = 0;
  /// Dispatch size is the number of logical threads running in one hardware thread
  SIMDMode m_dispatchSize = SIMDMode::UNKNOWN;

  bool GetHasBarrier() const { return m_BarrierNumber > 0; }
  void SetHasBarrier() {
    if (m_BarrierNumber == 0)
      m_BarrierNumber = 1;
  }
  void SetBarrierNumber(int BarrierNumber) { m_BarrierNumber = BarrierNumber; }
  int GetBarrierNumber() const { return m_BarrierNumber; }

  bool GetHasSampleGather4Load() const { return (m_HasSampleInst || m_HasGather4Inst || m_HasLoadInst); }
  bool GetHasSampleGather4() const { return (m_HasSampleInst || m_HasGather4Inst); }
  void SetHasSampleInst() { m_HasSampleInst = true; }
  void SetHasGather4Inst() { m_HasGather4Inst = true; }
  void SetHasLoadInst() { m_HasLoadInst = true; }

  bool GetHasDPAS() const { return m_HasDPAS; }
  void SetHasDPAS() { m_HasDPAS = true; }

  uint32_t getGRFSize() const { return Ctx.platform.getGRFSize(); }

  // Shader has LSC store messages with cache controls specified in `ops`
  void HasLscStoreCacheControls(const LSC_CACHE_OPTS &opts) {
    if (opts.l1 != LSC_CACHING_DEFAULT) {
      m_HasLscStoresWithNonDefaultL1CacheControls = true;
    }
  };
  bool GetHasLscStoresWithNonDefaultL1CacheControls() const { return m_HasLscStoresWithNonDefaultL1CacheControls; };

  /// Evaluate the Sampler Count field value.
  unsigned int GetSamplerCount(unsigned int samplerCount) const;

  // in DWORDs
  uint32_t getMinPushConstantBufferAlignmentInBytes() const {
    return Ctx.platform.getMinPushConstantBufferAlignment() * sizeof(DWORD);
  }

  uint32_t GetMaxUsedBindingTableEntryCount(void) const {
    if (m_BindingTableUsedEntriesBitmap != 0) {
      // m_BindingTableEntryCount is index; '+ 1' due to calculate total used count.
      return (m_BindingTableEntryCount + 1);
    }
    return 0;
  }

  uint32_t GetBindingTableEntryBitmap(void) const { return m_BindingTableUsedEntriesBitmap; }

  bool GetHasEval() const { return m_HasEval; }
  void SetHasEval() { m_HasEval = true; }
  void CreateGatherMap();
  void CreateConstantBufferOutput(SKernelProgram *pKernelProgram);
  static void setScratchUsage(CodeGenContext &Ctx, SProgramOutput &Prog);
  void setScratchUsage(SProgramOutput &Prog);
  uint32_t GetShaderThreadUsageRate();

  const llvm::Function &Entry;
  CodeGenContext &Ctx;

  CodeGenContext &GetContext() const { return Ctx; }

  bool shouldDisablePreemption(unsigned NumInst) const {
    return (Ctx.platform.supportDisableMidThreadPreemptionSwitch() &&
            IGC_IS_FLAG_ENABLED(EnableDisableMidThreadPreemptionOpt) && (Ctx.m_instrTypes.numLoopInsts == 0) &&
            (NumInst < IGC_GET_FLAG_VALUE(MidThreadPreemptionDisableThreshold)));
  }

private:
  bool m_HasSampleInst = false;
  bool m_HasGather4Inst = false;
  bool m_HasLoadInst = false;
  int m_BarrierNumber = 0;
  bool m_HasDPAS = false;
  // Shader has LSC store messages with non-default L1 cache control
  bool m_HasLscStoresWithNonDefaultL1CacheControls = false;
};
} // namespace IGC