/* * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/command_stream/stream_properties.h" #include "shared/source/helpers/flat_batch_buffer_helper.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/preamble_base.inl" #include "shared/source/kernel/kernel_execution_type.h" namespace NEO { template void PreambleHelper::programL3(LinearStream *pCommandStream, uint32_t l3Config) { LriHelper::program(pCommandStream, L3CNTLRegisterOffset::registerOffset, l3Config, false); } template uint32_t PreambleHelper::getUrbEntryAllocationSize() { return 0x782; } template void *PreambleHelper::getSpaceForVfeState(LinearStream *pCommandStream, const HardwareInfo &hwInfo, EngineGroupType engineGroupType) { using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE; addPipeControlBeforeVfeCmd(pCommandStream, &hwInfo, engineGroupType); return pCommandStream->getSpaceForCmd(); } template void PreambleHelper::programVfeState(void *pVfeState, const HardwareInfo &hwInfo, uint32_t scratchSize, uint64_t scratchAddress, uint32_t maxFrontEndThreads, const StreamProperties &streamProperties) { using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE; auto pMediaVfeState = reinterpret_cast(pVfeState); MEDIA_VFE_STATE cmd = GfxFamily::cmdInitMediaVfeState; cmd.setMaximumNumberOfThreads(maxFrontEndThreads); cmd.setNumberOfUrbEntries(1); cmd.setUrbEntryAllocationSize(PreambleHelper::getUrbEntryAllocationSize()); cmd.setPerThreadScratchSpace(PreambleHelper::getScratchSizeValueToProgramMediaVfeState(scratchSize)); cmd.setStackSize(PreambleHelper::getScratchSizeValueToProgramMediaVfeState(scratchSize)); uint32_t lowAddress = static_cast(0xFFFFFFFF & scratchAddress); uint32_t highAddress = static_cast(0xFFFFFFFF & (scratchAddress >> 32)); cmd.setScratchSpaceBasePointer(lowAddress); cmd.setScratchSpaceBasePointerHigh(highAddress); programAdditionalFieldsInVfeState(&cmd, hwInfo); appendProgramVFEState(hwInfo, streamProperties, &cmd); *pMediaVfeState = cmd; } template uint64_t PreambleHelper::getScratchSpaceAddressOffsetForVfeState(LinearStream *pCommandStream, void *pVfeState) { using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE; return static_cast(reinterpret_cast(pVfeState) - reinterpret_cast(pCommandStream->getCpuBase()) + MEDIA_VFE_STATE::PATCH_CONSTANTS::SCRATCHSPACEBASEPOINTER_BYTEOFFSET); } template size_t PreambleHelper::getVFECommandsSize() { using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE; return sizeof(MEDIA_VFE_STATE) + sizeof(PIPE_CONTROL); } } // namespace NEO