mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Use bliter for memoryFill
Change-Id: I2e60d1b436cb2955952b62b1eb43d9efbe70d19b Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
1bb0134a6c
commit
67198ea705
@@ -74,11 +74,17 @@ struct BlitProperties {
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct BlitCommandsHelper {
|
||||
using COLOR_DEPTH = typename GfxFamily::XY_COLOR_BLT::COLOR_DEPTH;
|
||||
static size_t estimateBlitCommandsSize(Vec3<size_t> copySize, const CsrDependencies &csrDependencies, bool updateTimestampPacket);
|
||||
static size_t estimateBlitCommandsSize(const BlitPropertiesContainer &blitPropertiesContainer, const HardwareInfo &hwInfo);
|
||||
static uint64_t calculateBlitCommandDestinationBaseAddress(const BlitProperties &blitProperties, uint64_t offset, uint64_t row, uint64_t slice);
|
||||
static uint64_t calculateBlitCommandSourceBaseAddress(const BlitProperties &blitProperties, uint64_t offset, uint64_t row, uint64_t slice);
|
||||
static void dispatchBlitCommandsForBuffer(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
static void dispatchBlitMemoryColorFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, size_t patternSize, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
template <size_t patternSize>
|
||||
static void dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth);
|
||||
static void appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
static void appendBlitCommandsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename GfxFamily::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
static void appendTilingEnable(typename GfxFamily::XY_COLOR_BLT &blitCmd);
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -128,5 +128,43 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBuffer(const BlitProp
|
||||
}
|
||||
}
|
||||
}
|
||||
template <typename GfxFamily>
|
||||
template <size_t patternSize>
|
||||
void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) {
|
||||
using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT;
|
||||
auto blitCmd = GfxFamily::cmdInitXyColorBlt;
|
||||
|
||||
blitCmd.setFillColor(pattern);
|
||||
blitCmd.setColorDepth(depth);
|
||||
|
||||
appendBlitCommandsForFillBuffer(dstAlloc, blitCmd, rootDeviceEnvironment);
|
||||
|
||||
uint64_t offset = 0;
|
||||
uint64_t sizeToFill = size;
|
||||
while (sizeToFill != 0) {
|
||||
auto tmpCmd = blitCmd;
|
||||
tmpCmd.setDestinationBaseAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast<size_t>(offset)));
|
||||
uint64_t height = 0;
|
||||
uint64_t width = 0;
|
||||
if (sizeToFill <= BlitterConstants::maxBlitWidth) {
|
||||
width = sizeToFill;
|
||||
height = 1;
|
||||
} else {
|
||||
width = BlitterConstants::maxBlitWidth;
|
||||
height = std::min((sizeToFill / width), BlitterConstants::maxBlitHeight);
|
||||
if (height > 1) {
|
||||
appendTilingEnable(tmpCmd);
|
||||
}
|
||||
}
|
||||
tmpCmd.setTransferWidth(static_cast<uint32_t>(width));
|
||||
tmpCmd.setTransferHeight(static_cast<uint32_t>(height));
|
||||
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width));
|
||||
auto cmd = linearStream.getSpaceForCmd<XY_COLOR_BLT>();
|
||||
*cmd = tmpCmd;
|
||||
auto blitSize = width * height;
|
||||
offset += (blitSize);
|
||||
sizeToFill -= blitSize;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -12,4 +12,32 @@ namespace NEO {
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename GfxFamily::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT;
|
||||
if (blitCmd.getColorDepth() == XY_COLOR_BLT::COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR) {
|
||||
blitCmd.set32BppByteMask(XY_COLOR_BLT::_32BPP_BYTE_MASK::_32BPP_BYTE_MASK_WRITE_RGBA_CHANNEL);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryColorFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, size_t patternSize, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
switch (patternSize) {
|
||||
case 1:
|
||||
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill<1>(dstAlloc, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR);
|
||||
break;
|
||||
case 2:
|
||||
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill<2>(dstAlloc, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR1555);
|
||||
break;
|
||||
default:
|
||||
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill<4>(dstAlloc, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::appendTilingEnable(typename GfxFamily::XY_COLOR_BLT &blitCmd) {
|
||||
using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT;
|
||||
blitCmd.setDestTilingEnable(XY_COLOR_BLT::DEST_TILING_ENABLE::DEST_TILING_ENABLE_TILING_ENABLED);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -56,8 +56,10 @@ constexpr uint64_t MB = MemoryConstants::megaByte;
|
||||
constexpr uint64_t GB = MemoryConstants::gigaByte;
|
||||
|
||||
namespace BlitterConstants {
|
||||
constexpr uint64_t maxBlitWidth = 0x7FC0; // 0x7FFF aligned to cacheline size
|
||||
constexpr uint64_t maxBlitHeight = 0x3FC0; // 0x4000 aligned to cacheline size
|
||||
constexpr uint64_t maxBlitWidth = 0x7FC0; // 0x7FFF aligned to cacheline size
|
||||
constexpr uint64_t maxBlitHeight = 0x3FC0; // 0x4000 aligned to cacheline size
|
||||
constexpr uint64_t maxBlitSetWidth = 0x1FFC0; // 0x20000 aligned to cacheline size
|
||||
constexpr uint64_t maxBlitSetHeight = 0x1FFC0; // 0x20000 aligned to cacheline size
|
||||
enum class BlitDirection : uint32_t {
|
||||
BufferToHostPtr,
|
||||
HostPtrToBuffer,
|
||||
|
||||
Reference in New Issue
Block a user