| 1 |
/*========================== begin_copyright_notice ============================ |
| 2 |
|
| 3 |
Copyright (C) 2022 Intel Corporation |
| 4 |
|
| 5 |
SPDX-License-Identifier: MIT |
| 6 |
|
| 7 |
============================= end_copyright_notice ===========================*/ |
| 8 |
|
| 9 |
#include "MessageDecoderE64.hpp" |
| 10 |
|
| 11 |
using namespace iga; |
| 12 |
|
| 13 |
#define LSC_LOOKUP_TABLE(FIELD, OFF, LEN, TBL) \ |
| 14 |
lookupFromTable(FIELD, OFF, LEN, TBL, sizeof(TBL) / sizeof(TBL[0])) |
| 15 |
|
| 16 |
struct MessageDecoderSamplerE64 : MessageDecoderE64 { |
| 17 |
MessageDecoderSamplerE64(Platform _platform, SFID _sfid, ExecSize _execSize, |
| 18 |
int _src0Len, int _src1Len, uint64_t _desc, |
| 19 |
RegRef id0, RegRef id1, DecodeResult &_result) |
| 20 |
: MessageDecoderE64(_platform, _sfid, _execSize, _src0Len, _src1Len, |
| 21 |
_desc, id0, id1, _result) {} |
| 22 |
|
| 23 |
void decode(); |
| 24 |
|
| 25 |
private: |
| 26 |
std::string decodeChannels(bool); |
| 27 |
}; // MessageDecoderSamplerE64 |
| 28 |
|
| 29 |
void MessageDecoderSamplerE64::decode() { |
| 30 |
addDocs( |
| 31 |
DocRef::MSGOP, "SAMPLER_MESSAGE_TYPE", "64985", |
| 32 |
DocRef::DESC, "MESSAGE_DESCRIPTOR_SAMPLING_ENGINE_Efficient64bit", "57021", |
| 33 |
DocRef::SRC0, "SAMPLER_MSG_HEADER_64bit_Eff", "57024"); |
| 34 |
|
| 35 |
// Desc[5:0] SamplerMessageType |
| 36 |
const auto enc = getDescBits(0, 6); |
| 37 |
const SamplerMessageDescription smpOpInfo = |
| 38 |
LookupSamplerMessageDescription(enc, 32, false); |
| 39 |
addField("SamplerMessageType", 0, 6, enc, smpOpInfo.mnemonic); |
| 40 |
|
| 41 |
const auto &opInfo = lookupSendOp(smpOpInfo.op); |
| 42 |
result.info.op = smpOpInfo.op; |
| 43 |
result.info.symbol = opInfo.mnemonic; |
| 44 |
result.info.addrType = AddrType::SURF; |
| 45 |
result.info.execWidth = execSize == ExecSize::INVALID ? 32 : int(execSize); |
| 46 |
// |
| 47 |
result.info.surfaceState = indDesc0; |
| 48 |
result.info.samplerState = indDesc1; |
| 49 |
if (!opInfo.isValid()) { |
| 50 |
error(0, 6, "invalid SamplerMessageType"); |
| 51 |
return; |
| 52 |
} |
| 53 |
|
| 54 |
// description string |
| 55 |
std::stringstream dss; |
| 56 |
dss << opInfo.mnemonic; |
| 57 |
// |
| 58 |
// Desc[6] EnableLSCBacking |
| 59 |
decodeField("EnableLscBacking", 6, 1, |
| 60 |
[&] (uint32_t val, std::stringstream &ss) { |
| 61 |
ss << (val == 0 ? "Disabled" : "Enabled"); |
| 62 |
}); |
| 63 |
// |
| 64 |
// Desc[10:7] varies based on sampler message type |
| 65 |
bool gather4 = opInfo.hasAttr(SendOpDefinition::Attr::GATHER4); |
| 66 |
dss << decodeChannels(gather4); |
| 67 |
// |
| 68 |
// Desc[13:11] SURFACE_TYPE_HINT |
| 69 |
dss << decodeSurfaceTypeHint(); |
| 70 |
|
| 71 |
// Desc[14] AddressInputFormat |
| 72 |
decodeField("AddressInputFormat", 14, 1, |
| 73 |
[&] (uint32_t val, std::stringstream &ss) { |
| 74 |
result.info.addrSizeBits = (val == 0 ? 32 : 16); |
| 75 |
ss << (val == 0 ? "AIF32" : "AIF16"); |
| 76 |
if (result.info.addrSizeBits == 16) { |
| 77 |
dss << ".a16"; |
| 78 |
} |
| 79 |
}); |
| 80 |
// Desc[15] DataReturnFormat |
| 81 |
decodeField("DataReturnFormat", 15, 1, |
| 82 |
[&] (uint32_t val, std::stringstream &ss) { |
| 83 |
result.info.elemSizeBitsRegFile = (val == 0 ? 32 : 16); |
| 84 |
result.info.elemSizeBitsMemory = result.info.elemSizeBitsRegFile; |
| 85 |
ss << (val == 0 ? "DRF32" : "DRF16"); |
| 86 |
if (result.info.elemSizeBitsRegFile == 16) { |
| 87 |
dss << ".d16"; |
| 88 |
} |
| 89 |
}); |
| 90 |
|
| 91 |
decodeCacheControlValue(opInfo.op); |
| 92 |
|
| 93 |
auto trtt = getDescBits(20, 1); |
| 94 |
if (trtt) { |
| 95 |
result.info.description += " w/ trtt"; |
| 96 |
dss << ".trtt"; |
| 97 |
} |
| 98 |
addField("TRTT_NULL", 20, 1, trtt, |
| 99 |
trtt ? "include status register" : "no status return"); |
| 100 |
// |
| 101 |
auto feedback = getDescBits(21, 1); |
| 102 |
if (feedback) { |
| 103 |
dss << ".feedback"; |
| 104 |
} |
| 105 |
addField("IncludeFeedbackSurface", 21, 1, feedback, |
| 106 |
feedback ? "Feedback surface included in header" |
| 107 |
: "No feedback header"); |
| 108 |
|
| 109 |
decodeSsIdx(); |
| 110 |
if (result.info.surfaceStateIndex != 0) |
| 111 |
dss << ".ssidx=" << result.info.surfaceStateIndex; |
| 112 |
|
| 113 |
decodeSmsIdx(); |
| 114 |
if (result.info.samplerStateIndex != 0) |
| 115 |
dss << ".smsidx=" << result.info.samplerStateIndex; |
| 116 |
|
| 117 |
decodeUvrOffsets(); |
| 118 |
if (!result.syntax.immOffset.empty()) |
| 119 |
dss << ".uvroff" << result.syntax.immOffset; |
| 120 |
|
| 121 |
addReserved(42, 5); |
| 122 |
|
| 123 |
|
| 124 |
if (src0Len >= 0 && src1Len >= 0) { |
| 125 |
int srcPayloads = src0Len + src1Len; |
| 126 |
if (feedback) // one of the registers is the header |
| 127 |
srcPayloads--; |
| 128 |
int coords = srcPayloads / 2; |
| 129 |
auto s = smpOpInfo.describeParams(coords); |
| 130 |
if (!s.empty()) |
| 131 |
dss << ": " << s; |
| 132 |
} |
| 133 |
result.info.description = dss.str(); |
| 134 |
|
| 135 |
int dstCmp = |
| 136 |
std::max<int>(result.info.execWidth * result.info.elemSizeBitsRegFile / 8, |
| 137 |
BYTES_PER_REGISTER); |
| 138 |
result.info.dstLenBytes = dstCmp * result.info.elemsPerAddr; |
| 139 |
if (trtt) { // includes an extra phase with the status bits |
| 140 |
result.info.dstLenBytes += BYTES_PER_REGISTER; |
| 141 |
if (execSize == ExecSize::SIMD32) { //in SIMD32 mode, 2 trailing regsiters |
| 142 |
result.info.dstLenBytes += BYTES_PER_REGISTER; |
| 143 |
} |
| 144 |
} |
| 145 |
if (src0Len >= 0) |
| 146 |
result.info.src0LenBytes = src0Len * BYTES_PER_REGISTER; |
| 147 |
if (src1Len >= 0) |
| 148 |
result.info.src1LenBytes = src1Len * BYTES_PER_REGISTER; |
| 149 |
} |
| 150 |
|
| 151 |
std::string MessageDecoderSamplerE64::decodeChannels(bool gather4) { |
| 152 |
// If gather4 message: |
| 153 |
// Desc[8:7] RESERVED |
| 154 |
// Desc[10:9] Gather4SourceChannelSelect |
| 155 |
// ELSE |
| 156 |
// Desc[10:7] WriteChannelMask |
| 157 |
std::string syn; |
| 158 |
if (gather4) { |
| 159 |
// https://gfxspecs.intel.com/Predator/Home/Index/71638 |
| 160 |
addReserved(7, 2); |
| 161 |
auto g4 = getDescBits(9, 2); |
| 162 |
std::string meaning; |
| 163 |
switch (g4) { |
| 164 |
case 0: |
| 165 |
meaning = "select R channel"; |
| 166 |
syn = ".r"; |
| 167 |
break; |
| 168 |
case 1: |
| 169 |
meaning = "select G channel"; |
| 170 |
syn = ".g"; |
| 171 |
break; |
| 172 |
case 2: |
| 173 |
meaning = "select B channel"; |
| 174 |
syn = ".b"; |
| 175 |
break; |
| 176 |
case 3: |
| 177 |
meaning = "select A channel"; |
| 178 |
syn = ".a"; |
| 179 |
break; |
| 180 |
} |
| 181 |
addField("Gather4SourceChannelSelect", 9, 2, g4, meaning); |
| 182 |
result.info.elemsPerAddr = 4; |
| 183 |
} else { |
| 184 |
result.info.addAttr(MessageInfo::Attr::HAS_CHMASK); |
| 185 |
syn = decodeVectorSizeCmask("rgba"); |
| 186 |
} |
| 187 |
return syn; |
| 188 |
} |
| 189 |
|
| 190 |
void iga::DecodeMessageSamplerE64(Platform platform, SFID sfid, |
| 191 |
ExecSize execSize, int src0Len, int src1Len, |
| 192 |
uint64_t desc, RegRef id0, RegRef id1, |
| 193 |
DecodeResult &result) { |
| 194 |
MessageDecoderSamplerE64 mdec {platform, sfid, execSize, src0Len, src1Len, |
| 195 |
desc, id0, id1, result}; |
| 196 |
mdec.decode(); |
| 197 |
if (result.errors.empty()) { |
| 198 |
mdec.checkBytesLen("src0", result.info.src0LenBytes, src0Len); |
| 199 |
mdec.checkBytesLen("src1", result.info.src1LenBytes, src1Len); |
| 200 |
} |
| 201 |
} |