1 /*========================== begin_copyright_notice ============================ 2 3 Copyright (C) 2017-2021 Intel Corporation 4 5 SPDX-License-Identifier: MIT 6 7 ============================= end_copyright_notice ===========================*/ 8 9 #include "Compiler/CISACodeGen/messageEncoding.hpp" 10 #include "Compiler/CISACodeGen/helper.h" 11 #include "Compiler/CISACodeGen/CISACodeGen.h" 12 #include "common/Types.hpp" 13 #include "Probe/Assertion.h" 14 15 /*********************************************************************************** 16 This File contains all the helper functions to generate the message descriptor for the different 17 messages we use for 3D compiler, once the messages are implemented in C-ISA we can get rid of this. 18 Most likely some messages will stay encoded manually by the code generator 19 20 *************************************************************************************/ 21 22 23 namespace IGC 24 { samplerSimdMode(SIMDMode simd)25 EU_SAMPLER_SIMD_MODE samplerSimdMode(SIMDMode simd) 26 { 27 if (simd == SIMDMode::SIMD8) 28 { 29 return EU_SAMPLER_SIMD_SIMD8; 30 } 31 else if (simd == SIMDMode::SIMD16) 32 { 33 return EU_SAMPLER_SIMD_SIMD16; 34 } 35 IGC_ASSERT(0); 36 return EU_SAMPLER_SIMD_SIMD8; 37 } 38 Sampler(uint messageLength,uint responseLength,bool headerPresent,EU_SAMPLER_SIMD_MODE executionMode,EU_GEN6_SAMPLER_MESSAGE_TYPE messageType,uint samplerIndex,uint resourceIndex,bool endOfThread,bool FP16Input,bool FP16Return)39 uint Sampler( 40 uint messageLength, 41 uint responseLength, 42 bool headerPresent, 43 EU_SAMPLER_SIMD_MODE executionMode, 44 EU_GEN6_SAMPLER_MESSAGE_TYPE messageType, 45 uint samplerIndex, 46 uint resourceIndex, 47 bool endOfThread, 48 bool FP16Input, 49 bool FP16Return) 50 { 51 IGC_ASSERT(resourceIndex < 256); 52 IGC_ASSERT(samplerIndex < 16); 53 IGC_ASSERT(messageType >= 0); 54 IGC_ASSERT(int(messageType) < 32); 55 IGC_ASSERT(executionMode >= 0); 56 IGC_ASSERT(int(executionMode) < 4); 57 IGC_ASSERT(responseLength < 9); 58 IGC_ASSERT(messageLength > 0); 59 IGC_ASSERT(messageLength < 16); 60 61 // if endOfThread == true, responseLength needs to be 0 62 IGC_ASSERT(!endOfThread || responseLength == 0); 63 64 SEUSamplerMessageDescriptorGen7 messageDescriptor; 65 memset(&messageDescriptor, 0, sizeof(messageDescriptor)); 66 67 messageDescriptor.DW0.All.BindingTableIndex = resourceIndex; 68 messageDescriptor.DW0.All.SamplerIndex = samplerIndex; 69 messageDescriptor.DW0.All.MessageType = messageType; 70 messageDescriptor.DW0.All.SIMDMode = executionMode; 71 messageDescriptor.DW0.All.HeaderPresent = headerPresent; 72 messageDescriptor.DW0.All.ResponseLength = responseLength; 73 messageDescriptor.DW0.All.MessageLength = messageLength; 74 messageDescriptor.DW0.All.FP16Input = FP16Input; 75 messageDescriptor.DW0.All.FP16Return = FP16Return; 76 messageDescriptor.DW0.All.EndOfThread = endOfThread; 77 78 return messageDescriptor.DW0.Value; 79 } 80 getHwAtomicOpEnum(AtomicOp op)81 EU_DATA_PORT_ATOMIC_OPERATION_TYPE getHwAtomicOpEnum(AtomicOp op) 82 { 83 switch (op) 84 { 85 case EATOMIC_AND: 86 return EU_DATA_PORT_ATOMIC_OPERATION_AND; 87 case EATOMIC_DEC: 88 return EU_DATA_PORT_ATOMIC_OPERATION_DEC; 89 case EATOMIC_IADD: 90 return EU_DATA_PORT_ATOMIC_OPERATION_ADD; 91 case EATOMIC_IMAX: 92 return EU_DATA_PORT_ATOMIC_OPERATION_IMAX; 93 case EATOMIC_IMIN: 94 return EU_DATA_PORT_ATOMIC_OPERATION_IMIN; 95 case EATOMIC_INC: 96 return EU_DATA_PORT_ATOMIC_OPERATION_INC; 97 case EATOMIC_MAX: 98 return EU_DATA_PORT_ATOMIC_OPERATION_IMAX; 99 case EATOMIC_MIN: 100 return EU_DATA_PORT_ATOMIC_OPERATION_IMIN; 101 case EATOMIC_OR: 102 return EU_DATA_PORT_ATOMIC_OPERATION_OR; 103 case EATOMIC_SUB: 104 return EU_DATA_PORT_ATOMIC_OPERATION_SUB; 105 case EATOMIC_UMAX: 106 return EU_DATA_PORT_ATOMIC_OPERATION_UMAX; 107 case EATOMIC_UMIN: 108 return EU_DATA_PORT_ATOMIC_OPERATION_UMIN; 109 case EATOMIC_CMPXCHG: 110 return EU_DATA_PORT_ATOMIC_OPERATION_CMPWR; 111 case EATOMIC_XCHG: 112 return EU_DATA_PORT_ATOMIC_OPERATION_MOV; 113 case EATOMIC_XOR: 114 return EU_DATA_PORT_ATOMIC_OPERATION_XOR; 115 case EATOMIC_PREDEC: 116 return EU_DATA_PORT_ATOMIC_OPERATION_PREDEC; 117 case EATOMIC_FMIN: 118 return EU_DATA_PORT_A64_ATOMIC_OPERATION_FMIN; 119 case EATOMIC_FMAX: 120 return EU_DATA_PORT_A64_ATOMIC_OPERATION_FMAX; 121 case EATOMIC_FCMPWR: 122 return EU_DATA_PORT_A64_ATOMIC_OPERATION_FCMPWR; 123 // 64 Bit 124 case EATOMIC_AND64: 125 return EU_DATA_PORT_A64_ATOMIC_OPERATION_AND; 126 case EATOMIC_DEC64: 127 return EU_DATA_PORT_A64_ATOMIC_OPERATION_DEC; 128 case EATOMIC_IADD64: 129 return EU_DATA_PORT_A64_ATOMIC_OPERATION_ADD; 130 case EATOMIC_IMAX64: 131 return EU_DATA_PORT_A64_ATOMIC_OPERATION_IMAX; 132 case EATOMIC_IMIN64: 133 return EU_DATA_PORT_A64_ATOMIC_OPERATION_IMIN; 134 case EATOMIC_INC64: 135 return EU_DATA_PORT_A64_ATOMIC_OPERATION_INC; 136 case EATOMIC_OR64: 137 return EU_DATA_PORT_A64_ATOMIC_OPERATION_OR; 138 case EATOMIC_SUB64: 139 return EU_DATA_PORT_A64_ATOMIC_OPERATION_SUB; 140 case EATOMIC_UMAX64: 141 return EU_DATA_PORT_A64_ATOMIC_OPERATION_UMAX; 142 case EATOMIC_UMIN64: 143 return EU_DATA_PORT_A64_ATOMIC_OPERATION_UMIN; 144 case EATOMIC_CMPXCHG64: 145 return EU_DATA_PORT_A64_ATOMIC_OPERATION_CMPWR; 146 case EATOMIC_XCHG64: 147 return EU_DATA_PORT_A64_ATOMIC_OPERATION_MOV; 148 case EATOMIC_XOR64: 149 return EU_DATA_PORT_A64_ATOMIC_OPERATION_XOR; 150 case EATOMIC_PREDEC64: 151 return EU_DATA_PORT_A64_ATOMIC_OPERATION_PREDEC; 152 default: 153 IGC_ASSERT_MESSAGE(0, "Other atomic operations not implemented"); 154 break; 155 } 156 157 return EU_DATA_PORT_ATOMIC_OPERATION_AND; 158 } 159 encodeMessageDescriptorForAtomicUnaryOp(const unsigned int messageLength,const unsigned int responseLength,bool headerPresent,const uint message_type,const bool returnData,const SIMDMode simdMode,EU_DATA_PORT_ATOMIC_OPERATION_TYPE atomic_op_type,uint binding_table_index)160 uint encodeMessageDescriptorForAtomicUnaryOp( 161 const unsigned int messageLength, 162 const unsigned int responseLength, 163 bool headerPresent, 164 const uint message_type, 165 const bool returnData, 166 const SIMDMode simdMode, 167 EU_DATA_PORT_ATOMIC_OPERATION_TYPE atomic_op_type, 168 uint binding_table_index) 169 { 170 SEUDataPortMessageDescriptorGen8_0 messageDescriptor = { 0 }; 171 172 uint messageSpecificControl = 0; 173 174 messageSpecificControl |= atomic_op_type; 175 176 if ((message_type == EU_GEN7_5_DATA_CACHE_1_MESSAGE_TYPE_ATOMIC_COUNTER_OPERATION || 177 message_type == EU_GEN7_5_DATA_CACHE_1_MESSAGE_TYPE_UNTYPED_ATOMIC_OPERATION) && 178 simdMode == SIMDMode::SIMD8) 179 { 180 messageSpecificControl |= (1 << 4); 181 } 182 183 messageDescriptor.DW0.All.BindingTableIndex = binding_table_index; 184 messageDescriptor.DW0.All.EndOfThread = false; 185 messageDescriptor.DW0.All.HeaderPresent = headerPresent; 186 messageDescriptor.DW0.All.MessageLength = messageLength; 187 188 switch (atomic_op_type) 189 { 190 191 case EU_DATA_PORT_A64_ATOMIC_OPERATION_FMIN: 192 { 193 messageDescriptor.DW0.All.MessageSpecificControl = 2;//FMIN 194 messageDescriptor.DW0.All.MessageType = EU_GEN8_DATA_PORT_1_MESSAGE_TYPE_UNTYPED_ATOMIC_FLOAT; 195 } 196 break; 197 case EU_DATA_PORT_A64_ATOMIC_OPERATION_FMAX: 198 { 199 messageSpecificControl |= (1 << 13); 200 messageDescriptor.DW0.All.MessageSpecificControl = 1;//FMAX 201 messageDescriptor.DW0.All.MessageType = EU_GEN8_DATA_PORT_1_MESSAGE_TYPE_UNTYPED_ATOMIC_FLOAT; 202 } 203 break; 204 case EU_DATA_PORT_A64_ATOMIC_OPERATION_FCMPWR: 205 { 206 messageSpecificControl |= (1 << 13); 207 messageDescriptor.DW0.All.MessageSpecificControl = 3;//FCMPWR 208 messageDescriptor.DW0.All.MessageType = EU_GEN8_DATA_PORT_1_MESSAGE_TYPE_UNTYPED_ATOMIC_FLOAT; 209 } 210 break; 211 default: 212 { 213 messageSpecificControl |= (returnData << 5); 214 messageDescriptor.DW0.All.MessageSpecificControl = messageSpecificControl; 215 messageDescriptor.DW0.All.MessageType = message_type; 216 } 217 break; 218 } 219 220 messageDescriptor.DW0.All.ResponseLength = responseLength; 221 222 return messageDescriptor.DW0.Value; 223 } 224 225 /// Currently this is a bad design since we are overloading both the functions doing the same thing. 226 /// Discriminated Unions was an idea but this one needs more thought. Templates are terrible for 227 /// dealing with multiple enum types and hence wasn't used. encodeMessageSpecificControlForReadWrite(const EU_DATA_PORT_READ_MESSAGE_TYPE messageType,const VISAChannelMask mask,const SIMDMode simdMode)228 uint encodeMessageSpecificControlForReadWrite( 229 const EU_DATA_PORT_READ_MESSAGE_TYPE messageType, 230 const VISAChannelMask mask, 231 const SIMDMode simdMode) 232 { 233 uint messageSpecificControl = 0; 234 // We need only the lowest 4 bits 235 messageSpecificControl |= (~mask & 0xF); 236 237 if (messageType == EU_DATA_PORT_READ_MESSAGE_TYPE_UNTYPED_SURFACE_READ) 238 { 239 TODO("message encoding for message specific control has to be improved."); 240 switch (simdMode) 241 { 242 case SIMDMode::SIMD8: 243 // Hate magic numbers but for now we need a quick solution. Refer to Spec 244 messageSpecificControl |= (2 << 4); // 12 is where the bits for SIMD mode start.. So 8 bits 245 // are in the structure already so we have to subtract 8 246 // for all our calculations 247 break; 248 case SIMDMode::SIMD16: 249 messageSpecificControl |= (1 << 4); 250 break; 251 default: 252 IGC_ASSERT_MESSAGE(0, "Other SIMD modes are not allowed"); 253 break; 254 } 255 } 256 257 return messageSpecificControl; 258 } 259 encodeMessageSpecificControlForReadWrite(const EU_DATA_PORT_WRITE_MESSAGE_TYPE messageType,const VISAChannelMask mask,const SIMDMode simdMode)260 uint encodeMessageSpecificControlForReadWrite( 261 const EU_DATA_PORT_WRITE_MESSAGE_TYPE messageType, 262 const VISAChannelMask mask, 263 const SIMDMode simdMode) 264 { 265 uint messageSpecificControl = 0; 266 // We need only the lowest 4 bits 267 messageSpecificControl |= (~mask & 0xF); 268 269 if (messageType == EU_DATA_PORT_WRITE_MESSAGE_TYPE_UNTYPED_SURFACE_WRITE) 270 { 271 TODO("message encoding for message specific control has to be improved."); 272 switch (simdMode) 273 { 274 case SIMDMode::SIMD8: 275 // Hate magic numbers but for now we need a quick solution. Refer to Spec 276 messageSpecificControl |= (2 << 4); // 12 is where the bits for SIMD mode start.. So 8 bits 277 // are in the structure already so we have to subtract 8 278 // for all our calculations 279 break; 280 case SIMDMode::SIMD16: 281 messageSpecificControl |= (1 << 4); 282 break; 283 default: 284 IGC_ASSERT_MESSAGE(0, "Other SIMD modes are not allowed"); 285 break; 286 } 287 } 288 else 289 { 290 IGC_ASSERT_MESSAGE(0, "Other message types haven't been implemented yet."); 291 } 292 293 return messageSpecificControl; 294 } 295 DataPortRead(const uint messageLength,const uint responseLength,const bool headerPresent,const EU_DATA_PORT_READ_MESSAGE_TYPE messageType,const uint messageSpecificControl,const bool invalidateAfterReadEnableHint,const DATA_PORT_TARGET_CACHE targetCache,const uint bindingTableIndex)296 uint DataPortRead( 297 const uint messageLength, 298 const uint responseLength, 299 const bool headerPresent, 300 const EU_DATA_PORT_READ_MESSAGE_TYPE messageType, 301 const uint messageSpecificControl, 302 const bool invalidateAfterReadEnableHint, 303 const DATA_PORT_TARGET_CACHE targetCache, 304 const uint bindingTableIndex) 305 { 306 static_assert(0 == DATA_PORT_TARGET_DATA_CACHE, "Table index order"); 307 static_assert(1 == DATA_PORT_TARGET_RENDER_CACHE, "Table index order"); 308 static_assert(2 == DATA_PORT_TARGET_SAMPLER_CACHE, "Table index order"); 309 static_assert(3 == DATA_PORT_TARGET_CONSTANT_CACHE, "Table index order"); 310 static_assert(4 == DATA_PORT_TARGET_DATA_CACHE_1, "Table index order"); 311 IGC_ASSERT_MESSAGE(0 <= targetCache, "Table index bounds check"); 312 IGC_ASSERT_MESSAGE(targetCache <= 4, "Table index bounds check"); 313 static const uint cConvertMessageType[][NUM_EU_DATA_PORT_READ_MESSAGE_TYPES] = 314 { 315 // DATA_PORT_TARGET_DATA_CACHE 316 { 317 EU_GEN7_DATA_CACHE_MESSAGE_TYPE_OWORD_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_BLOCK_READ 318 EU_GEN7_DATA_CACHE_MESSAGE_TYPE_OWORD_DUAL_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_DUAL_BLOCK_READ 319 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_MEDIA_BLOCK_READ 320 EU_GEN7_DATA_CACHE_MESSAGE_TYPE_DWORD_SCATTERED_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_DWORD_SCATTERED_READ 321 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDERTARGET_UNORM_READ 322 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_AVC_LOOPFILTER_READ 323 EU_GEN7_DATA_CACHE_MESSAGE_TYPE_UNALIGNED_OWORD_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNALIGNED_OWORD_BLOCK_READ 324 EU_GEN7_DATA_CACHE_MESSAGE_TYPE_BYTE_SCATTERED_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_BYTE_SCATTERED_READ 325 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNTYPED_SURFACE_READ 326 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_TYPED_SURFACE_READ 327 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_SCATTERED_READ 328 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_UNTYPED_SURFACE_READ 329 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_BLOCK_READ 330 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_TRANSPOSE_READ 331 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDER_TARGET_READ 332 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_SURFACE_INFO_READ 333 }, 334 // DATA_PORT_TARGET_RENDER_CACHE 335 { 336 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_BLOCK_READ 337 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_DUAL_BLOCK_READ 338 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_MEDIA_BLOCK_READ 339 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_DWORD_SCATTERED_READ 340 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDERTARGET_UNORM_READ 341 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_AVC_LOOPFILTER_READ 342 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNALIGNED_OWORD_BLOCK_READ 343 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_BYTE_SCATTERED_READ 344 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNTYPED_SURFACE_READ 345 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_TYPED_SURFACE_READ 346 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_UNTYPED_SURFACE_READ 347 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_SCATTERED_READ 348 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_BLOCK_READ 349 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_TRANSPOSE_READ 350 EU_GEN9_RENDER_CACHE_MESSAGE_TYPE_RENDER_TARGET_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDER_TARGET_READ 351 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_SURFACE_INFO_READ 352 }, 353 // DATA_PORT_TARGET_SAMPLER_CACHE 354 { 355 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_BLOCK_READ 356 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_DUAL_BLOCK_READ 357 EU_GEN7_SAMPLER_CACHE_MESSAGE_TYPE_MEDIA_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_MEDIA_BLOCK_READ 358 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_DWORD_SCATTERED_READ 359 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDERTARGET_UNORM_READ 360 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_AVC_LOOPFILTER_READ 361 EU_GEN7_SAMPLER_CACHE_MESSAGE_TYPE_UNALIGNED_OWORD_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNALIGNED_OWORD_BLOCK_READ 362 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_BYTE_SCATTERED_READ 363 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNTYPED_SURFACE_READ 364 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_TYPED_SURFACE_READ 365 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_UNTYPED_SURFACE_READ 366 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_SCATTERED_READ 367 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_BLOCK_READ 368 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_TRANSPOSE_READ 369 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDER_TARGET_READ 370 EU_GEN8_SAMPLER_CACHE_MESSAGE_TYPE_SURFACE_INFO, // EU_DATA_PORT_READ_MESSAGE_TYPE_SURFACE_INFO_READ 371 }, 372 // DATA_PORT_TARGET_CONSTANT_CACHE 373 { 374 EU_GEN7_CONSTANT_CACHE_MESSAGE_TYPE_OWORD_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_BLOCK_READ 375 EU_GEN7_CONSTANT_CACHE_MESSAGE_TYPE_OWORD_DUAL_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_DUAL_BLOCK_READ 376 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_MEDIA_BLOCK_READ 377 EU_GEN7_CONSTANT_CACHE_MESSAGE_TYPE_DWORD_SCATTERED_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_DWORD_SCATTERED_READ 378 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDERTARGET_UNORM_READ 379 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_AVC_LOOPFILTER_READ 380 EU_GEN7_CONSTANT_CACHE_MESSAGE_TYPE_UNALIGNED_OWORD_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNALIGNED_OWORD_BLOCK_READ 381 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_BYTE_SCATTERED_READ 382 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNTYPED_SURFACE_READ 383 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_TYPED_SURFACE_READ 384 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_UNTYPED_SURFACE_READ 385 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_SCATTERED_READ 386 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_BLOCK_READ 387 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_TRANSPOSE_READ 388 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDER_TARGET_READ 389 EU_GEN9_CONSTANT_CACHE_MESSAGE_SURFACE_INFO, // EU_DATA_PORT_READ_MESSAGE_TYPE_SURFACE_INFO_READ 390 }, 391 // DATA_PORT_TARGET_DATA_CACHE_1 392 { 393 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_BLOCK_READ 394 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_OWORD_DUAL_BLOCK_READ 395 EU_GEN7_5_DATA_CACHE_1_MESSAGE_TYPE_MEDIA_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_MEDIA_BLOCK_READ 396 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_DWORD_SCATTERED_READ 397 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDERTARGET_UNORM_READ 398 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_AVC_LOOPFILTER_READ 399 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNALIGNED_OWORD_BLOCK_READ 400 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_BYTE_SCATTERED_READ 401 EU_GEN7_5_DATA_CACHE_1_MESSAGE_TYPE_UNTYPED_SURFACE_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_UNTYPED_SURFACE_READ 402 EU_GEN7_5_DATA_CACHE_1_MESSAGE_TYPE_TYPED_SURFACE_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_TYPED_SURFACE_READ 403 EU_GEN8_DATA_CACHE_1_MESSAGE_TYPE_A64_UNTYPED_SURFACE_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_UNTYPED_SURFACE_READ 404 EU_GEN8_DATA_CACHE_1_MESSAGE_TYPE_A64_SCATTERED_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_SCATTERED_READ 405 EU_GEN8_DATA_CACHE_1_MESSAGE_TYPE_A64_BLOCK_READ, // EU_DATA_PORT_READ_MESSAGE_TYPE_A64_BLOCK_READ 406 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_TRANSPOSE_READ 407 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_RENDER_TARGET_READ 408 INVALID_MESSAGE_TYPE, // EU_DATA_PORT_READ_MESSAGE_TYPE_SURFACE_INFO_READ 409 } 410 }; 411 412 413 uint hwMessageType = cConvertMessageType[targetCache][messageType]; 414 SEUDataPortMessageDescriptorGen8_0 messageDescriptor; 415 memset(&messageDescriptor, 0, sizeof(messageDescriptor)); 416 417 messageDescriptor.DW0.All.BindingTableIndex = bindingTableIndex; 418 messageDescriptor.DW0.All.MessageSpecificControl = messageSpecificControl | 419 (invalidateAfterReadEnableHint ? EU_DATA_PORT_INVALIDATE_AFTER_READ_ENABLE : 0); 420 messageDescriptor.DW0.All.MessageType = hwMessageType; 421 messageDescriptor.DW0.All.HeaderPresent = headerPresent; 422 messageDescriptor.DW0.All.ResponseLength = responseLength; 423 messageDescriptor.DW0.All.MessageLength = messageLength; 424 messageDescriptor.DW0.All.EndOfThread = false; 425 426 return messageDescriptor.DW0.Value; 427 } 428 DataPortWrite(const uint messageLength,const uint responseLength,const bool headerPresent,const bool endOfThread,const EU_DATA_PORT_WRITE_MESSAGE_TYPE messageType,const uint messageSpecificControl,const bool invalidateAfterReadEnable,const uint bindingTableIndex)429 uint DataPortWrite( 430 const uint messageLength, 431 const uint responseLength, 432 const bool headerPresent, 433 const bool endOfThread, 434 const EU_DATA_PORT_WRITE_MESSAGE_TYPE messageType, 435 const uint messageSpecificControl, 436 const bool invalidateAfterReadEnable, 437 const uint bindingTableIndex) 438 { 439 IGC_ASSERT(messageLength > 0); 440 IGC_ASSERT(messageLength < 16); 441 IGC_ASSERT(responseLength < 9); 442 443 SEUDataPortMessageDescriptorGen8_0 messageDescriptor; 444 memset(&messageDescriptor, 0, sizeof(messageDescriptor)); 445 446 messageDescriptor.DW0.All.BindingTableIndex = bindingTableIndex; 447 messageDescriptor.DW0.All.MessageSpecificControl = messageSpecificControl; 448 messageDescriptor.DW0.All.MessageType = 449 cConvertDataPortWriteMessageType[messageType]; 450 messageDescriptor.DW0.All.HeaderPresent = headerPresent; 451 messageDescriptor.DW0.All.ResponseLength = responseLength; 452 messageDescriptor.DW0.All.MessageLength = messageLength; 453 454 return messageDescriptor.DW0.Value; 455 } 456 PixelDataPort(const bool precisionSubType,const uint messageLength,const uint responseLength,const bool headerPresent,const bool perCoarse,const bool perSample,const bool lastRT,const bool secondHalf,const EU_GEN6_DATA_PORT_RENDER_TARGET_WRITE_CONTROL messageSubType,const uint bindingTableIndex)457 uint PixelDataPort( 458 const bool precisionSubType, 459 const uint messageLength, 460 const uint responseLength, 461 const bool headerPresent, 462 const bool perCoarse, 463 const bool perSample, 464 const bool lastRT, 465 const bool secondHalf, 466 const EU_GEN6_DATA_PORT_RENDER_TARGET_WRITE_CONTROL messageSubType, 467 const uint bindingTableIndex) 468 { 469 IGC_ASSERT(messageLength > 0); 470 IGC_ASSERT(messageLength < 16); 471 IGC_ASSERT(responseLength < 9); 472 473 SEUPixelDataPortMessageDescriptorGen8_0 messageDescriptor; 474 memset(&messageDescriptor, 0, sizeof(messageDescriptor)); 475 476 messageDescriptor.DW0.All.BindingTableIndex = bindingTableIndex; 477 messageDescriptor.DW0.All.MessageSubType = messageSubType; 478 messageDescriptor.DW0.All.Slot = secondHalf; 479 messageDescriptor.DW0.All.LastRT = lastRT; 480 messageDescriptor.DW0.All.PerSample = perSample; 481 messageDescriptor.DW0.All.MessageType = EU_GEN9_RENDER_CACHE_MESSAGE_TYPE_RENDER_TARGET_WRITE; 482 messageDescriptor.DW0.All.PerCoarse = perCoarse; 483 messageDescriptor.DW0.All.HeaderPresent = headerPresent; 484 messageDescriptor.DW0.All.ResponseLength = responseLength; 485 messageDescriptor.DW0.All.MessageLength = messageLength; 486 messageDescriptor.DW0.All.PrecisionSubType = precisionSubType; 487 488 return messageDescriptor.DW0.Value; 489 } 490 UrbMessage(const uint messageLength,const uint responseLength,const bool endOfThread,const bool perSlotOffset,const bool channelMaskPresent,const uint globalOffset,const EU_URB_OPCODE urbOpcode)491 uint UrbMessage( 492 const uint messageLength, 493 const uint responseLength, 494 const bool endOfThread, 495 const bool perSlotOffset, 496 const bool channelMaskPresent, 497 const uint globalOffset, 498 const EU_URB_OPCODE urbOpcode) 499 { 500 SEUURBMessageDescriptorGen8_0 messageDescriptor; 501 memset(&messageDescriptor, 0, sizeof(messageDescriptor)); 502 503 messageDescriptor.DW0.Simd8.URBOpcode = urbOpcode; 504 messageDescriptor.DW0.Simd8.GlobalOffset = globalOffset; 505 messageDescriptor.DW0.Simd8.ChannelMaskPresent = channelMaskPresent; 506 messageDescriptor.DW0.Simd8.PerSlotOffset = perSlotOffset; 507 messageDescriptor.DW0.Simd8.ResponseLength = responseLength; 508 messageDescriptor.DW0.Simd8.MessageLength = messageLength; 509 messageDescriptor.DW0.Simd8.HeaderPresent = true; 510 511 return messageDescriptor.DW0.Value; 512 } 513 GetSystemThreadBindingTableIndex(void) const514 uint CBTILayout::GetSystemThreadBindingTableIndex(void) const 515 { 516 return m_pLayout->systemThreadIdx; 517 } 518 GetBindingTableEntryCount(void) const519 uint CBTILayout::GetBindingTableEntryCount(void) const 520 { 521 return m_pLayout->maxBTsize; 522 } 523 GetTextureIndex(uint index) const524 uint CBTILayout::GetTextureIndex(uint index) const 525 { 526 uint idx = m_pLayout->minResourceIdx + index; 527 return idx; 528 } 529 GetNullSurfaceIdx() const530 uint CBTILayout::GetNullSurfaceIdx() const 531 { 532 return m_pLayout->NULLSurfaceIdx; 533 } 534 GetUavIndex(uint index) const535 uint CBTILayout::GetUavIndex(uint index) const 536 { 537 uint idx = m_pLayout->minUAVIdx + index; 538 return idx; 539 } 540 GetRenderTargetIndex(uint index) const541 uint CBTILayout::GetRenderTargetIndex(uint index) const 542 { 543 uint idx = m_pLayout->minColorBufferIdx + index; 544 545 IGC_ASSERT(m_ColorBufferMappings.size() == 0 || idx < m_ColorBufferMappings.size()); 546 if (idx < m_ColorBufferMappings.size()) 547 { 548 idx = m_ColorBufferMappings[idx]; 549 } 550 551 return idx; 552 } 553 GetConstantBufferIndex(uint index) const554 uint CBTILayout::GetConstantBufferIndex(uint index) const 555 { 556 uint idx = m_pLayout->minConstantBufferIdx + index; 557 return idx; 558 } 559 GetTGSMIndex() const560 uint CBTILayout::GetTGSMIndex() const 561 { 562 return m_pLayout->TGSMIdx; 563 } 564 GetScratchSurfaceBindingTableIndex() const565 uint CBTILayout::GetScratchSurfaceBindingTableIndex() const 566 { 567 IGC_ASSERT(m_pLayout != NULL); 568 return SCRATCH_SPACE_BTI; 569 } 570 GetStatelessBindingTableIndex() const571 uint CBTILayout::GetStatelessBindingTableIndex() const 572 { 573 IGC_ASSERT(m_pLayout != NULL); 574 return STATELESS_BTI; 575 } 576 GetImmediateConstantBufferOffset() const577 uint CBTILayout::GetImmediateConstantBufferOffset() const 578 { 579 IGC_ASSERT(m_pLayout != NULL); 580 return m_pLayout->immediateConstantBufferOffset; 581 } 582 GetDrawIndirectBufferIndex() const583 uint CBTILayout::GetDrawIndirectBufferIndex() const 584 { 585 IGC_ASSERT(m_pLayout != NULL); 586 return m_pLayout->indirectBufferOffset; 587 } 588 getModifiableLayout()589 USC::SShaderStageBTLayout* COCLBTILayout::getModifiableLayout() 590 { 591 return const_cast<USC::SShaderStageBTLayout*>(m_pLayout); 592 } 593 pixelInterpolatorSimDMode(SIMDMode simd)594 EU_PIXEL_INTERPOLATOR_SIMD_MODE pixelInterpolatorSimDMode(SIMDMode simd) 595 { 596 if (simd == SIMDMode::SIMD8) 597 { 598 return EU_PI_MESSAGE_SIMD8; 599 } 600 else if (simd == SIMDMode::SIMD16) 601 { 602 return EU_PI_MESSAGE_SIMD16; 603 } 604 IGC_ASSERT(0); 605 return EU_PI_MESSAGE_SIMD8; 606 } 607 PixelInterpolator(unsigned int messageLength,unsigned int responseLength,unsigned int pass,EU_PIXEL_INTERPOLATOR_SIMD_MODE executionMode,EU_PIXEL_INTERPOLATOR_MESSAGE_TYPE messageType,EU_PIXEL_INTERPOLATOR_INTERPOLATION_MODE interpolationMode,const unsigned int sampleindex)608 unsigned int PixelInterpolator( 609 unsigned int messageLength, 610 unsigned int responseLength, 611 unsigned int pass, 612 EU_PIXEL_INTERPOLATOR_SIMD_MODE executionMode, 613 EU_PIXEL_INTERPOLATOR_MESSAGE_TYPE messageType, 614 EU_PIXEL_INTERPOLATOR_INTERPOLATION_MODE interpolationMode, 615 const unsigned int sampleindex) 616 { 617 IGC_ASSERT(messageType >= 0); 618 IGC_ASSERT(int(messageType) < 4); 619 IGC_ASSERT(executionMode >= 0); 620 IGC_ASSERT(int(executionMode) < 4); 621 622 SEUPixelInterpolatorSampleIndexMessageDescriptorGen7_0 messageDescriptor; 623 memset(&messageDescriptor, 0, sizeof(messageDescriptor)); 624 625 messageDescriptor.DW0.All.SampleIndex = sampleindex; 626 messageDescriptor.DW0.All.MessageType = messageType; 627 messageDescriptor.DW0.All.InterpolationMode = interpolationMode; 628 messageDescriptor.DW0.All.SIMDMode = executionMode; 629 messageDescriptor.DW0.All.HeaderPresent = false; 630 messageDescriptor.DW0.All.SlotGroupSelect = pass; 631 messageDescriptor.DW0.All.ResponseLength = responseLength; 632 messageDescriptor.DW0.All.MessageLength = messageLength; 633 messageDescriptor.DW0.All.EndOfThread = false; 634 635 return messageDescriptor.DW0.Value; 636 } 637 PixelInterpolator(unsigned int messageLength,unsigned int responseLength,unsigned int pass,EU_PIXEL_INTERPOLATOR_SIMD_MODE executionMode,EU_PIXEL_INTERPOLATOR_MESSAGE_TYPE messageType,EU_PIXEL_INTERPOLATOR_INTERPOLATION_MODE interpolationMode,unsigned int perMessageXOffset,unsigned int perMessageYOffset)638 unsigned int PixelInterpolator( 639 unsigned int messageLength, 640 unsigned int responseLength, 641 unsigned int pass, 642 EU_PIXEL_INTERPOLATOR_SIMD_MODE executionMode, 643 EU_PIXEL_INTERPOLATOR_MESSAGE_TYPE messageType, 644 EU_PIXEL_INTERPOLATOR_INTERPOLATION_MODE interpolationMode, 645 unsigned int perMessageXOffset, 646 unsigned int perMessageYOffset) 647 { 648 IGC_ASSERT(messageType >= 0); 649 IGC_ASSERT(int(messageType) < 4); 650 IGC_ASSERT(executionMode >= 0); 651 IGC_ASSERT(int(executionMode) < 4); 652 653 SEUPixelInterpolatorOffsetMessageDescriptorGen7_0 messageDescriptor; 654 memset(&messageDescriptor, 0, sizeof(messageDescriptor)); 655 656 messageDescriptor.DW0.All.MessageType = messageType; 657 messageDescriptor.DW0.All.PerMessageXOffset = perMessageXOffset; 658 messageDescriptor.DW0.All.PerMessageYOffset = perMessageYOffset; 659 messageDescriptor.DW0.All.InterpolationMode = interpolationMode; 660 messageDescriptor.DW0.All.SlotGroupSelect = pass; 661 messageDescriptor.DW0.All.SIMDMode = executionMode; 662 messageDescriptor.DW0.All.HeaderPresent = false; 663 messageDescriptor.DW0.All.ResponseLength = responseLength; 664 messageDescriptor.DW0.All.MessageLength = messageLength; 665 messageDescriptor.DW0.All.EndOfThread = false; 666 667 return messageDescriptor.DW0.Value; 668 } 669 PixelInterpolator(const DWORD messageLength,const DWORD responseLength,const DWORD pass,bool IsCoarse,EU_PIXEL_INTERPOLATOR_SIMD_MODE executionMode,EU_PIXEL_INTERPOLATOR_MESSAGE_TYPE messageType,EU_PIXEL_INTERPOLATOR_INTERPOLATION_MODE interpolationMode)670 unsigned int PixelInterpolator( 671 const DWORD messageLength, 672 const DWORD responseLength, 673 const DWORD pass, 674 bool IsCoarse, 675 EU_PIXEL_INTERPOLATOR_SIMD_MODE executionMode, 676 EU_PIXEL_INTERPOLATOR_MESSAGE_TYPE messageType, 677 EU_PIXEL_INTERPOLATOR_INTERPOLATION_MODE interpolationMode) 678 { 679 SEUPixelInterpolatorMessageDescriptorGen7_0 messageDescriptor; 680 memset(&messageDescriptor, 0, sizeof(messageDescriptor)); 681 682 messageDescriptor.DW0.All.MessageType = messageType; 683 messageDescriptor.DW0.All.InterpolationMode = interpolationMode; 684 messageDescriptor.DW0.All.SlotGroupSelect = pass; 685 messageDescriptor.DW0.All.SIMDMode = executionMode; 686 messageDescriptor.DW0.All.HeaderPresent = false; 687 messageDescriptor.DW0.All.ResponseLength = responseLength; 688 messageDescriptor.DW0.All.MessageLength = messageLength; 689 messageDescriptor.DW0.All.EndOfThread = false; 690 messageDescriptor.DW0.All.ShadingRate = IsCoarse ? 1 : 0; 691 692 return messageDescriptor.DW0.Value; 693 } 694 VMEDescriptor(COMMON_ISA_VME_STREAM_MODE streamMode,const uint32_t bti,const uint32_t msgType,const uint32_t regs2snd,const uint32_t regs2rcv)695 uint32_t VMEDescriptor( 696 COMMON_ISA_VME_STREAM_MODE streamMode, 697 const uint32_t bti, 698 const uint32_t msgType, 699 const uint32_t regs2snd, 700 const uint32_t regs2rcv 701 ) 702 { 703 VMEMessageDescriptorGen8_0 messageDescriptor = { 0 }; 704 705 messageDescriptor.DW0.All.BindingTableIndex = bti; 706 messageDescriptor.DW0.All.MessageType = msgType; 707 messageDescriptor.DW0.All.StreamOutEnable = (streamMode == VME_STREAM_IN_OUT) || (streamMode == VME_STREAM_OUT); 708 messageDescriptor.DW0.All.StreamInEnable = (streamMode == VME_STREAM_IN_OUT) || (streamMode == VME_STREAM_IN); 709 messageDescriptor.DW0.All.HeaderPresent = true; 710 messageDescriptor.DW0.All.MessageLength = regs2snd; 711 messageDescriptor.DW0.All.ResponseLength = regs2rcv; 712 713 return messageDescriptor.DW0.Value; 714 } 715 716 PIPullPixelPayload(EU_PIXEL_INTERPOLATOR_SIMD_MODE executionMode,DWORD responseLength,DWORD messageLenght,bool inputCoverage,bool linearCentroidBary,bool linearCenterBary,bool perspectiveCentroid,bool perspectiveCenter,bool OutputCoverageMask)717 unsigned int PIPullPixelPayload( 718 EU_PIXEL_INTERPOLATOR_SIMD_MODE executionMode, 719 DWORD responseLength, 720 DWORD messageLenght, 721 bool inputCoverage, 722 bool linearCentroidBary, 723 bool linearCenterBary, 724 bool perspectiveCentroid, 725 bool perspectiveCenter, 726 bool OutputCoverageMask) 727 { 728 union CoarseToPixelMappingMessageDescriptor 729 { 730 struct 731 { 732 unsigned int InputConverage : BITFIELD_BIT(0); 733 unsigned int LinearCentroidBary : BITFIELD_BIT(1); 734 unsigned int LinearCenterBary : BITFIELD_BIT(2); 735 unsigned int PerspectiveCentroid : BITFIELD_BIT(3); 736 unsigned int PerspectiveCenter : BITFIELD_BIT(4); 737 unsigned int OutputCoverageMask : BITFIELD_BIT(5); 738 unsigned int : BITFIELD_RANGE(6, 7); 739 unsigned int PixelShaderPhase : BITFIELD_RANGE(8, 11); 740 unsigned int MessageType : BITFIELD_RANGE(12, 13); 741 unsigned int InterpolationMode : BITFIELD_BIT(14); 742 unsigned int ShadingRate : BITFIELD_BIT(15); 743 unsigned int SimdMode : BITFIELD_BIT(16); 744 unsigned int : BITFIELD_RANGE(17, 18); 745 unsigned int HeaderPresent : BITFIELD_BIT(19); 746 unsigned int ResponseLength : BITFIELD_RANGE(20, 24); 747 unsigned int MessageLength : BITFIELD_RANGE(25, 28); 748 unsigned int : BITFIELD_RANGE(29, 30); 749 unsigned int EndOfThread : BITFIELD_BIT(31); 750 } All; 751 752 unsigned int Value; 753 }; 754 755 CoarseToPixelMappingMessageDescriptor messageDesc; 756 messageDesc.Value = 0; 757 messageDesc.All.ShadingRate = 1; // Coarse rate 758 messageDesc.All.SimdMode = executionMode; 759 messageDesc.All.InputConverage = inputCoverage; 760 messageDesc.All.LinearCentroidBary = linearCentroidBary; 761 messageDesc.All.LinearCenterBary = linearCenterBary; 762 messageDesc.All.PerspectiveCentroid = perspectiveCentroid; 763 messageDesc.All.PerspectiveCenter = perspectiveCenter; 764 messageDesc.All.OutputCoverageMask = OutputCoverageMask; 765 messageDesc.All.MessageLength = messageLenght; 766 messageDesc.All.ResponseLength = responseLength; 767 768 return messageDesc.Value; 769 } 770 771 772 773 } // namespace IGC 774