text: /*
   * Copyright (C) 2019-2020 Intel Corporation
   *
   * SPDX-License-Identifier: MIT
   *
   */
  
  #include "shared/source/command_stream/command_stream_receiver_hw_base.inl"
  
  namespace NEO {
  
  template <typename GfxFamily>
  size_t CommandStreamReceiverHw<GfxFamily>::getSshHeapSize() {
      return defaultHeapSize;
  }
  
  template <typename GfxFamily>
  inline void CommandStreamReceiverHw<GfxFamily>::programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config) {
      typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL;
      if (csrSizeRequestFlags.l3ConfigChanged && this->isPreambleSent) {
          // Add a PIPE_CONTROL w/ CS_stall
          auto pCmd = (PIPE_CONTROL *)csr.getSpace(sizeof(PIPE_CONTROL));
          PIPE_CONTROL cmd = GfxFamily::cmdInitPipeControl;
          cmd.setCommandStreamerStallEnable(true);
          cmd.setDcFlushEnable(true);
          addClearSLMWorkAround(&cmd);
          *pCmd = cmd;
  
          PreambleHelper<GfxFamily>::programL3(&csr, newL3Config);
          this->lastSentL3Config = newL3Config;
      }
  }
  
  template <typename GfxFamily>
  size_t CommandStreamReceiverHw<GfxFamily>::getRequiredStateBaseAddressSize() const {
      using PIPELINE_SELECT = typename GfxFamily::PIPELINE_SELECT;
  
      size_t size = 0;
      auto &hwHelper = HwHelper::get(peekHwInfo().platform.eRenderCoreFamily);
      if (hwHelper.is3DPipelineSelectWARequired(peekHwInfo())) {
          size += (2 * PreambleHelper<GfxFamily>::getCmdSizeForPipelineSelect(peekHwInfo()));
      }
      size += sizeof(typename GfxFamily::STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL);
      return size;
  }
  
  template <typename GfxFamily>
  inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForL3Config() const {
      if (!this->isPreambleSent) {
          return sizeof(typename GfxFamily::MI_LOAD_REGISTER_IMM);
      } else if (csrSizeRequestFlags.l3ConfigChanged) {
          return sizeof(typename GfxFamily::MI_LOAD_REGISTER_IMM) + sizeof(typename GfxFamily::PIPE_CONTROL);
      }
      return 0;
  }
  
  template <typename GfxFamily>
  void CommandStreamReceiverHw<GfxFamily>::programPipelineSelect(LinearStream &commandStream, PipelineSelectArgs &pipelineSelectArgs) {
      if (csrSizeRequestFlags.mediaSamplerConfigChanged || !isPreambleSent) {
          if (!isPipelineSelectAlreadyProgrammed()) {
              PreambleHelper<GfxFamily>::programPipelineSelect(&commandStream, pipelineSelectArgs, peekHwInfo());
          }
          this->lastMediaSamplerConfig = pipelineSelectArgs.mediaSamplerRequired;
      }
  }
  
  template <typename GfxFamily>
  void CommandStreamReceiverHw<GfxFamily>::adjustThreadArbitionPolicy(void *const stateComputeMode) {}
  
  template <typename GfxFamily>
  void CommandStreamReceiverHw<GfxFamily>::createScratchSpaceController() {
      scratchSpaceController = std::make_unique<ScratchSpaceControllerBase>(rootDeviceIndex, executionEnvironment, *internalAllocationStorage.get());
  }
  
  template <typename GfxFamily>
  void CommandStreamReceiverHw<GfxFamily>::programEpliogueCommands(LinearStream &csr, const DispatchFlags &dispatchFlags) {
      this->programEngineModeEpliogue(csr, dispatchFlags);
  }
  
  template <typename GfxFamily>
  size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForEpilogueCommands(const DispatchFlags &dispatchFlags) const {
      return this->getCmdSizeForEngineMode(dispatchFlags);
  }
  
  template <typename GfxFamily>
  bool CommandStreamReceiverHw<GfxFamily>::isMultiOsContextCapable() const {
      return false;
  }
  
  template <typename GfxFamily>
  inline void CommandStreamReceiverHw<GfxFamily>::addPipeControlBeforeStateBaseAddress(LinearStream &commandStream) {
      PipeControlArgs args(true);
      args.textureCacheInvalidationEnable = true;
      addPipeControlCmd(commandStream, args);
  }
  
  template <typename GfxFamily>
  bool CommandStreamReceiverHw<GfxFamily>::checkPlatformSupportsNewResourceImplicitFlush() const {
      return false;
  }
  
  template <typename GfxFamily>
  bool CommandStreamReceiverHw<GfxFamily>::checkPlatformSupportsGpuIdleImplicitFlush() const {
      return false;
  }
  
  } // namespace NEO
  