mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Refactor programming of surface states
Related-To: NEO-5069 Change-Id: Id7442fcdcc8c7df57f00e8dc383c11869bf1a677 Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
0de5e422fb
commit
394e626db9
@ -75,14 +75,14 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(z
|
||||
|
||||
if (device->getNEODevice()->getDebugger()) {
|
||||
auto *ssh = commandContainer.getIndirectHeap(NEO::HeapType::SURFACE_STATE);
|
||||
auto surfaceState = device->getNEODevice()->getDebugger()->getDebugSurfaceReservedSurfaceState(*ssh);
|
||||
NEO::Device *neoDevice = device->getNEODevice();
|
||||
auto surfaceState = neoDevice->getDebugger()->getDebugSurfaceReservedSurfaceState(*ssh);
|
||||
auto debugSurface = device->getDebugSurface();
|
||||
auto mocs = device->getMOCS(true, false);
|
||||
NEO::EncodeSurfaceState<GfxFamily>::encodeBuffer(surfaceState, debugSurface->getGpuAddress(),
|
||||
debugSurface->getUnderlyingBufferSize(),
|
||||
mocs, true);
|
||||
NEO::EncodeSurfaceState<GfxFamily>::encodeExtraBufferParams(debugSurface,
|
||||
device->getNEODevice()->getGmmHelper(), surfaceState, false, false);
|
||||
debugSurface->getUnderlyingBufferSize(), mocs,
|
||||
true, false, neoDevice->getNumAvailableDevices(),
|
||||
debugSurface, neoDevice->getGmmHelper());
|
||||
}
|
||||
|
||||
appendSignalEventPostWalker(hEvent);
|
||||
|
@ -51,10 +51,10 @@ struct KernelHw : public KernelImp {
|
||||
bufferSizeForSsh = alignUp(bufferSizeForSsh, alignment);
|
||||
|
||||
auto mocs = this->module->getDevice()->getMOCS(true, false);
|
||||
bool requiresCoherency;
|
||||
NEO::EncodeSurfaceState<GfxFamily>::encodeBuffer(surfaceStateAddress,
|
||||
bufferAddressForSsh, bufferSizeForSsh, mocs,
|
||||
requiresCoherency = false);
|
||||
NEO::Device *neoDevice = module->getDevice()->getNEODevice();
|
||||
NEO::EncodeSurfaceState<GfxFamily>::encodeBuffer(surfaceStateAddress, bufferAddressForSsh, bufferSizeForSsh, mocs,
|
||||
true, false, neoDevice->getNumAvailableDevices(),
|
||||
alloc, neoDevice->getGmmHelper());
|
||||
}
|
||||
|
||||
std::unique_ptr<Kernel> clone() const override {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "shared/source/gen11/hw_cmds.h"
|
||||
|
||||
#include "opencl/source/mem_obj/buffer_bdw_plus.inl"
|
||||
#include "opencl/source/mem_obj/buffer_base.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "shared/source/gen12lp/hw_cmds.h"
|
||||
|
||||
#include "opencl/source/mem_obj/buffer_bdw_plus.inl"
|
||||
#include "opencl/source/mem_obj/buffer_base.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "shared/source/gen8/hw_cmds.h"
|
||||
|
||||
#include "opencl/source/mem_obj/buffer_bdw_plus.inl"
|
||||
#include "opencl/source/mem_obj/buffer_base.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "shared/source/gen9/hw_cmds.h"
|
||||
|
||||
#include "opencl/source/mem_obj/buffer_bdw_plus.inl"
|
||||
#include "opencl/source/mem_obj/buffer_base.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
@ -9,7 +9,6 @@ set(RUNTIME_SRCS_MEM_OBJ
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/buffer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/buffer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/buffer_base.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/buffer_bdw_plus.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/buffer_factory_init.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image.h
|
||||
|
@ -206,7 +206,6 @@ class BufferHw : public Buffer {
|
||||
zeroCopy, isHostPtrSVM, isObjectRedescribed) {}
|
||||
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument, const Device &device) override;
|
||||
void appendBufferState(void *memory, const Device &device, bool isReadOnlyArgument);
|
||||
void appendSurfaceStateExt(void *memory);
|
||||
|
||||
static Buffer *create(Context *context,
|
||||
|
@ -38,11 +38,9 @@ void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, boo
|
||||
auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex);
|
||||
EncodeSurfaceState<GfxFamily>::encodeBuffer(memory, getBufferAddress(rootDeviceIndex),
|
||||
getSurfaceSize(alignSizeForAuxTranslation, rootDeviceIndex),
|
||||
getMocsValue(disableL3, isReadOnlyArgument, rootDeviceIndex), true);
|
||||
EncodeSurfaceState<GfxFamily>::encodeExtraBufferParams(graphicsAllocation,
|
||||
device.getGmmHelper(), memory, forceNonAuxMode, isReadOnlyArgument);
|
||||
|
||||
appendBufferState(memory, device, isReadOnlyArgument);
|
||||
getMocsValue(disableL3, isReadOnlyArgument, rootDeviceIndex),
|
||||
true, forceNonAuxMode, device.getNumAvailableDevices(),
|
||||
graphicsAllocation, device.getGmmHelper());
|
||||
appendSurfaceStateExt(memory);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/source/mem_obj/buffer_base.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BufferHw<GfxFamily>::appendBufferState(void *memory, const Device &device, bool isReadOnly) {
|
||||
}
|
||||
|
||||
} // namespace NEO
|
@ -194,8 +194,10 @@ struct EncodeSurfaceState {
|
||||
using AUXILIARY_SURFACE_MODE = typename R_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
|
||||
|
||||
static void encodeBuffer(void *dst, uint64_t address, size_t size, uint32_t mocs,
|
||||
bool cpuCoherent);
|
||||
static void encodeExtraBufferParams(GraphicsAllocation *allocation, GmmHelper *gmmHelper, void *memory, bool forceNonAuxMode, bool isReadOnlyArgument);
|
||||
bool cpuCoherent, bool forceNonAuxMode, uint32_t numAvailableDevices,
|
||||
GraphicsAllocation *allocation, GmmHelper *gmmHelper);
|
||||
static void encodeExtraBufferParams(R_SURFACE_STATE *surfaceState, GraphicsAllocation *allocation, GmmHelper *gmmHelper,
|
||||
uint32_t numAvailableDevices);
|
||||
|
||||
static constexpr uintptr_t getSurfaceBaseAddressAlignmentMask() {
|
||||
return ~(getSurfaceBaseAddressAlignment() - 1);
|
||||
|
@ -267,52 +267,48 @@ void EncodeStoreMMIO<Family>::encode(LinearStream &csr, uint32_t offset, uint64_
|
||||
|
||||
template <typename Family>
|
||||
void EncodeSurfaceState<Family>::encodeBuffer(void *dst, uint64_t address, size_t size, uint32_t mocs,
|
||||
bool cpuCoherent) {
|
||||
auto ss = reinterpret_cast<R_SURFACE_STATE *>(dst);
|
||||
bool cpuCoherent, bool forceNonAuxMode, uint32_t numAvailableDevices,
|
||||
GraphicsAllocation *allocation, GmmHelper *gmmHelper) {
|
||||
auto surfaceState = reinterpret_cast<R_SURFACE_STATE *>(dst);
|
||||
UNRECOVERABLE_IF(!isAligned<getSurfaceBaseAddressAlignment()>(size));
|
||||
|
||||
SURFACE_STATE_BUFFER_LENGTH Length = {0};
|
||||
Length.Length = static_cast<uint32_t>(size - 1);
|
||||
|
||||
ss->setWidth(Length.SurfaceState.Width + 1);
|
||||
ss->setHeight(Length.SurfaceState.Height + 1);
|
||||
ss->setDepth(Length.SurfaceState.Depth + 1);
|
||||
surfaceState->setWidth(Length.SurfaceState.Width + 1);
|
||||
surfaceState->setHeight(Length.SurfaceState.Height + 1);
|
||||
surfaceState->setDepth(Length.SurfaceState.Depth + 1);
|
||||
|
||||
ss->setSurfaceType((address != 0) ? R_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER
|
||||
surfaceState->setSurfaceType((address != 0) ? R_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER
|
||||
: R_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_NULL);
|
||||
ss->setSurfaceFormat(SURFACE_FORMAT::SURFACE_FORMAT_RAW);
|
||||
ss->setSurfaceVerticalAlignment(R_SURFACE_STATE::SURFACE_VERTICAL_ALIGNMENT_VALIGN_4);
|
||||
ss->setSurfaceHorizontalAlignment(R_SURFACE_STATE::SURFACE_HORIZONTAL_ALIGNMENT_HALIGN_4);
|
||||
surfaceState->setSurfaceFormat(SURFACE_FORMAT::SURFACE_FORMAT_RAW);
|
||||
surfaceState->setSurfaceVerticalAlignment(R_SURFACE_STATE::SURFACE_VERTICAL_ALIGNMENT_VALIGN_4);
|
||||
surfaceState->setSurfaceHorizontalAlignment(R_SURFACE_STATE::SURFACE_HORIZONTAL_ALIGNMENT_HALIGN_4);
|
||||
|
||||
ss->setTileMode(R_SURFACE_STATE::TILE_MODE_LINEAR);
|
||||
ss->setVerticalLineStride(0);
|
||||
ss->setVerticalLineStrideOffset(0);
|
||||
ss->setMemoryObjectControlState(mocs);
|
||||
ss->setSurfaceBaseAddress(address);
|
||||
surfaceState->setTileMode(R_SURFACE_STATE::TILE_MODE_LINEAR);
|
||||
surfaceState->setVerticalLineStride(0);
|
||||
surfaceState->setVerticalLineStrideOffset(0);
|
||||
surfaceState->setMemoryObjectControlState(mocs);
|
||||
surfaceState->setSurfaceBaseAddress(address);
|
||||
|
||||
ss->setCoherencyType(cpuCoherent ? R_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT
|
||||
surfaceState->setCoherencyType(cpuCoherent ? R_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT
|
||||
: R_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
|
||||
ss->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
|
||||
}
|
||||
surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
|
||||
|
||||
template <typename Family>
|
||||
void EncodeSurfaceState<Family>::encodeExtraBufferParams(GraphicsAllocation *allocation, GmmHelper *gmmHelper, void *memory, bool forceNonAuxMode, bool isReadOnlyArgument) {
|
||||
using RENDER_SURFACE_STATE = typename Family::RENDER_SURFACE_STATE;
|
||||
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
|
||||
|
||||
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(memory);
|
||||
Gmm *gmm = allocation ? allocation->getDefaultGmm() : nullptr;
|
||||
|
||||
if (gmm && gmm->isRenderCompressed && !forceNonAuxMode) {
|
||||
// Its expected to not program pitch/qpitch/baseAddress for Aux surface in CCS scenarios
|
||||
surfaceState->setCoherencyType(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
|
||||
surfaceState->setCoherencyType(R_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
|
||||
surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
}
|
||||
|
||||
if (DebugManager.flags.DisableCachingForStatefulBufferAccess.get()) {
|
||||
surfaceState->setMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));
|
||||
}
|
||||
|
||||
EncodeSurfaceState<Family>::encodeExtraBufferParams(surfaceState, allocation, gmmHelper, numAvailableDevices);
|
||||
}
|
||||
|
||||
template <typename Family>
|
||||
void *EncodeDispatchKernel<Family>::getInterfaceDescriptor(CommandContainer &container, uint32_t &iddOffset) {
|
||||
|
||||
|
@ -388,4 +388,9 @@ inline size_t EncodeWA<GfxFamily>::getAdditionalPipelineSelectSize(Device &devic
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void EncodeSurfaceState<GfxFamily>::encodeExtraBufferParams(R_SURFACE_STATE *surfaceState, GraphicsAllocation *allocation, GmmHelper *gmmHelper,
|
||||
uint32_t numAvailableDevices) {
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
@ -47,7 +47,8 @@ HWTEST_F(CommandEncodeStatesTest, givenCreatedSurfaceStateBufferWhenAllocationPr
|
||||
length.Length = static_cast<uint32_t>(allocSize - 1);
|
||||
GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 1);
|
||||
EncodeSurfaceState<FamilyType>::encodeBuffer(stateBuffer, gpuAddr, allocSize, 1,
|
||||
RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT);
|
||||
true, false, 1u,
|
||||
&allocation, pDevice->getGmmHelper());
|
||||
EXPECT_EQ(length.SurfaceState.Depth + 1u, state->getDepth());
|
||||
EXPECT_EQ(length.SurfaceState.Width + 1u, state->getWidth());
|
||||
EXPECT_EQ(length.SurfaceState.Height + 1u, state->getHeight());
|
||||
@ -73,7 +74,8 @@ HWTEST_F(CommandEncodeStatesTest, givenCreatedSurfaceStateBufferWhenAllocationNo
|
||||
length.Length = static_cast<uint32_t>(allocSize - 1);
|
||||
|
||||
EncodeSurfaceState<FamilyType>::encodeBuffer(stateBuffer, gpuAddr, allocSize, 1,
|
||||
RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT);
|
||||
true, false, 1u,
|
||||
nullptr, pDevice->getGmmHelper());
|
||||
|
||||
EXPECT_EQ(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_NULL, state->getSurfaceType());
|
||||
|
||||
@ -97,7 +99,8 @@ HWTEST_F(CommandEncodeStatesTest, givenCreatedSurfaceStateBufferWhenGpuCoherency
|
||||
length.Length = static_cast<uint32_t>(allocSize - 1);
|
||||
|
||||
EncodeSurfaceState<FamilyType>::encodeBuffer(stateBuffer, gpuAddr, allocSize, 1,
|
||||
RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
|
||||
false, false, 1u,
|
||||
nullptr, pDevice->getGmmHelper());
|
||||
|
||||
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, state->getCoherencyType());
|
||||
|
||||
|
Reference in New Issue
Block a user