refactor: remove duplicated code for genCmdCast functions

Related-To: NEO-10641
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk 2024-08-09 12:20:27 +00:00 committed by Compute-Runtime-Automation
parent a860adc457
commit 8fe9751449
9 changed files with 143 additions and 118 deletions

View File

@ -7140,7 +7140,7 @@ struct STATE_SYSTEM_MEM_FENCE_ADDRESS {
uint32_t ContextRestoreInvalid : BITFIELD_RANGE(15, 15);
uint32_t _3DCommandSubOpcode : BITFIELD_RANGE(16, 23);
uint32_t _3DCommandOpcode : BITFIELD_RANGE(24, 26);
uint32_t CommandSubType : BITFIELD_RANGE(27, 28);
uint32_t CommandSubtype : BITFIELD_RANGE(27, 28);
uint32_t CommandType : BITFIELD_RANGE(29, 31);
// DWORD 1-2
uint64_t Reserved011 : BITFIELD_RANGE(0, 11);
@ -7189,9 +7189,9 @@ struct STATE_PREFETCH {
// DWORD 0
uint32_t DwordLength : BITFIELD_RANGE(0, 7);
uint32_t Reserved814 : BITFIELD_RANGE(8, 15);
uint32_t _3dCommandSubOpcode : BITFIELD_RANGE(16, 23);
uint32_t _3dCommandOpcode : BITFIELD_RANGE(24, 26);
uint32_t CommandSubType : BITFIELD_RANGE(27, 28);
uint32_t _3DCommandSubOpcode : BITFIELD_RANGE(16, 23);
uint32_t _3DCommandOpcode : BITFIELD_RANGE(24, 26);
uint32_t CommandSubtype : BITFIELD_RANGE(27, 28);
uint32_t CommandType : BITFIELD_RANGE(29, 31);
// DWORD 1
uint32_t PrefetchSize : BITFIELD_RANGE(0, 9);
@ -7216,7 +7216,7 @@ struct STATE_PREFETCH {
inline void init() {
memset(&TheStructure, 0, sizeof(TheStructure));
TheStructure.Common.DwordLength = 0x2;
TheStructure.Common._3dCommandSubOpcode = 0x3;
TheStructure.Common._3DCommandSubOpcode = 0x3;
TheStructure.Common.CommandType = 0x3;
}

View File

@ -17,7 +17,6 @@ target_sources(neo_libult_common PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_l3_control.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_mi_arb.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_sip.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_xy_block_copy.inl
${CMAKE_CURRENT_SOURCE_DIR}/gen_cmd_parse.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse_base.inl
@ -30,9 +29,19 @@ if(TESTS_DG2_AND_LATER)
)
endif()
if(TESTS_XE2_AND_LATER)
if(TESTS_PVC_AND_LATER)
target_sources(neo_libult_common PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse_xe2_hpg_and_later.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_mem_fence.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_mem_set.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_state_prefetch.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_system_mem_fence_address.inl
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_xy_block_copy.inl
)
endif()
if(TESTS_XE2_AND_LATER)
target_sources(neo_libult_common PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_state_context_data_base_address.inl
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse_xe2_hpg_and_later.inl
)
endif()

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
using namespace NEO;
using MI_MEM_FENCE = GenStruct::MI_MEM_FENCE;
template <>
MI_MEM_FENCE *genCmdCast<MI_MEM_FENCE *>(void *buffer) {
auto pCmd = reinterpret_cast<MI_MEM_FENCE *>(buffer);
return (0x0 == pCmd->TheStructure.Common.MiCommandSubOpcode &&
0x9 == pCmd->TheStructure.Common.MiCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
using namespace NEO;
using MEM_SET = GenStruct::MEM_SET;
template <>
MEM_SET *genCmdCast<MEM_SET *>(void *buffer) {
auto pCmd = reinterpret_cast<MEM_SET *>(buffer);
return (0x5 == pCmd->TheStructure.Common.DwordLength &&
0x5B == pCmd->TheStructure.Common.InstructionTarget_Opcode &&
0x2 == pCmd->TheStructure.Common.Client)
? pCmd
: nullptr;
}

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
using namespace NEO;
using STATE_CONTEXT_DATA_BASE_ADDRESS = GenStruct::STATE_CONTEXT_DATA_BASE_ADDRESS;
template <>
STATE_CONTEXT_DATA_BASE_ADDRESS *genCmdCast<STATE_CONTEXT_DATA_BASE_ADDRESS *>(void *buffer) {
auto pCmd = reinterpret_cast<STATE_CONTEXT_DATA_BASE_ADDRESS *>(buffer);
return (0x1 == pCmd->TheStructure.Common.DwordLength &&
0xb == pCmd->TheStructure.Common._3DCommandSubOpcode &&
0x1 == pCmd->TheStructure.Common._3DCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandSubtype &&
0x3 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
using namespace NEO;
using STATE_PREFETCH = GenStruct::STATE_PREFETCH;
template <>
STATE_PREFETCH *genCmdCast<STATE_PREFETCH *>(void *buffer) {
auto pCmd = reinterpret_cast<STATE_PREFETCH *>(buffer);
return (0x2 == pCmd->TheStructure.Common.DwordLength &&
0x3 == pCmd->TheStructure.Common._3DCommandSubOpcode &&
0x0 == pCmd->TheStructure.Common._3DCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandSubtype &&
0x3 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
using namespace NEO;
using STATE_SYSTEM_MEM_FENCE_ADDRESS = GenStruct::STATE_SYSTEM_MEM_FENCE_ADDRESS;
template <>
STATE_SYSTEM_MEM_FENCE_ADDRESS *genCmdCast<STATE_SYSTEM_MEM_FENCE_ADDRESS *>(void *buffer) {
auto pCmd = reinterpret_cast<STATE_SYSTEM_MEM_FENCE_ADDRESS *>(buffer);
return (0x1 == pCmd->TheStructure.Common.DwordLength &&
0x9 == pCmd->TheStructure.Common._3DCommandSubOpcode &&
0x1 == pCmd->TheStructure.Common._3DCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandSubtype &&
0x3 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}

View File

@ -9,6 +9,11 @@
using GenStruct = NEO::Xe2HpgCore;
using GenGfxFamily = NEO::Xe2HpgCoreFamily;
#include "shared/test/common/cmd_parse/cmd_parse_mem_fence.inl"
#include "shared/test/common/cmd_parse/cmd_parse_mem_set.inl"
#include "shared/test/common/cmd_parse/cmd_parse_state_context_data_base_address.inl"
#include "shared/test/common/cmd_parse/cmd_parse_state_prefetch.inl"
#include "shared/test/common/cmd_parse/cmd_parse_system_mem_fence_address.inl"
#include "shared/test/common/cmd_parse/cmd_parse_xy_block_copy.inl"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
@ -18,67 +23,6 @@ using STATE_PREFETCH = GenStruct::STATE_PREFETCH;
using MEM_SET = GenStruct::MEM_SET;
using STATE_CONTEXT_DATA_BASE_ADDRESS = GenStruct::STATE_CONTEXT_DATA_BASE_ADDRESS;
template <>
MI_MEM_FENCE *genCmdCast<MI_MEM_FENCE *>(void *buffer) {
auto pCmd = reinterpret_cast<MI_MEM_FENCE *>(buffer);
return (0x0 == pCmd->TheStructure.Common.MiCommandSubOpcode &&
0x9 == pCmd->TheStructure.Common.MiCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}
template <>
STATE_SYSTEM_MEM_FENCE_ADDRESS *genCmdCast<STATE_SYSTEM_MEM_FENCE_ADDRESS *>(void *buffer) {
auto pCmd = reinterpret_cast<STATE_SYSTEM_MEM_FENCE_ADDRESS *>(buffer);
return (0x1 == pCmd->TheStructure.Common.DwordLength &&
0x9 == pCmd->TheStructure.Common._3DCommandSubOpcode &&
0x1 == pCmd->TheStructure.Common._3DCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandSubtype &&
0x3 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}
template <>
STATE_PREFETCH *genCmdCast<STATE_PREFETCH *>(void *buffer) {
auto pCmd = reinterpret_cast<STATE_PREFETCH *>(buffer);
return (0x2 == pCmd->TheStructure.Common.DwordLength &&
0x3 == pCmd->TheStructure.Common._3DCommandSubOpcode &&
0x0 == pCmd->TheStructure.Common._3DCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandSubtype &&
0x3 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}
template <>
MEM_SET *genCmdCast<MEM_SET *>(void *buffer) {
auto pCmd = reinterpret_cast<MEM_SET *>(buffer);
return (0x5 == pCmd->TheStructure.Common.DwordLength &&
0x5B == pCmd->TheStructure.Common.InstructionTarget_Opcode &&
0x2 == pCmd->TheStructure.Common.Client)
? pCmd
: nullptr;
}
template <>
STATE_CONTEXT_DATA_BASE_ADDRESS *genCmdCast<STATE_CONTEXT_DATA_BASE_ADDRESS *>(void *buffer) {
auto pCmd = reinterpret_cast<STATE_CONTEXT_DATA_BASE_ADDRESS *>(buffer);
return (0x1 == pCmd->TheStructure.Common.DwordLength &&
0xb == pCmd->TheStructure.Common._3DCommandSubOpcode &&
0x1 == pCmd->TheStructure.Common._3DCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandSubtype &&
0x3 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}
template <>
size_t CmdParse<GenGfxFamily>::getAdditionalCommandLength(void *cmd) {
{

View File

@ -9,6 +9,10 @@
using GenStruct = NEO::XeHpcCore;
using GenGfxFamily = NEO::XeHpcCoreFamily;
#include "shared/test/common/cmd_parse/cmd_parse_mem_fence.inl"
#include "shared/test/common/cmd_parse/cmd_parse_mem_set.inl"
#include "shared/test/common/cmd_parse/cmd_parse_state_prefetch.inl"
#include "shared/test/common/cmd_parse/cmd_parse_system_mem_fence_address.inl"
#include "shared/test/common/cmd_parse/cmd_parse_xy_block_copy.inl"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
@ -17,54 +21,6 @@ using STATE_SYSTEM_MEM_FENCE_ADDRESS = GenStruct::STATE_SYSTEM_MEM_FENCE_ADDRESS
using STATE_PREFETCH = GenStruct::STATE_PREFETCH;
using MEM_SET = GenStruct::MEM_SET;
template <>
MI_MEM_FENCE *genCmdCast<MI_MEM_FENCE *>(void *buffer) {
auto pCmd = reinterpret_cast<MI_MEM_FENCE *>(buffer);
return (0x0 == pCmd->TheStructure.Common.MiCommandSubOpcode &&
0x9 == pCmd->TheStructure.Common.MiCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}
template <>
STATE_SYSTEM_MEM_FENCE_ADDRESS *genCmdCast<STATE_SYSTEM_MEM_FENCE_ADDRESS *>(void *buffer) {
auto pCmd = reinterpret_cast<STATE_SYSTEM_MEM_FENCE_ADDRESS *>(buffer);
return (0x1 == pCmd->TheStructure.Common.DwordLength &&
0x9 == pCmd->TheStructure.Common._3DCommandSubOpcode &&
0x1 == pCmd->TheStructure.Common._3DCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandSubType &&
0x3 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}
template <>
STATE_PREFETCH *genCmdCast<STATE_PREFETCH *>(void *buffer) {
auto pCmd = reinterpret_cast<STATE_PREFETCH *>(buffer);
return (0x2 == pCmd->TheStructure.Common.DwordLength &&
0x3 == pCmd->TheStructure.Common._3dCommandSubOpcode &&
0x0 == pCmd->TheStructure.Common._3dCommandOpcode &&
0x0 == pCmd->TheStructure.Common.CommandSubType &&
0x3 == pCmd->TheStructure.Common.CommandType)
? pCmd
: nullptr;
}
template <>
MEM_SET *genCmdCast<MEM_SET *>(void *buffer) {
auto pCmd = reinterpret_cast<MEM_SET *>(buffer);
return (0x5 == pCmd->TheStructure.Common.DwordLength &&
0x5B == pCmd->TheStructure.Common.InstructionTarget_Opcode &&
0x2 == pCmd->TheStructure.Common.Client)
? pCmd
: nullptr;
}
template <>
size_t CmdParse<GenGfxFamily>::getAdditionalCommandLength(void *cmd) {
{