Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of variant #38

Merged
merged 5 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
git branch -a
sudo apt-get update --yes
sudo apt-get install --yes git clang-format-14
sudo apt-get install python3-mako --yes

- name: Run lint script
run: ./scripts/clangformat.sh
Expand All @@ -51,6 +52,10 @@ jobs:
version: 1.10.0
- uses: ilammy/msvc-dev-cmd@v1
- uses: ilammy/setup-nasm@v1
- name: Install dependency
run: |
C:/hostedtoolcache/windows/Python/3.11.6/x64/python3.exe -m pip install mako
C:/hostedtoolcache/windows/Python/3.12.0/x64/python3.exe -m pip install mako
- name: Build the UI
run: |
mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A x64 ..
Expand All @@ -77,6 +82,10 @@ jobs:
version: 1.10.0
- uses: ilammy/msvc-dev-cmd@v1
- uses: ilammy/setup-nasm@v1
- name: Install dependency
run: |
C:/hostedtoolcache/windows/Python/3.11.6/x64/python3.exe -m pip install mako
C:/hostedtoolcache/windows/Python/3.12.0/x64/python3.exe -m pip install mako
- name: Build the UI
run: |
mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A x64 ..
Expand All @@ -96,6 +105,8 @@ jobs:
run: |
sudo apt-get update --yes
sudo apt-get install --yes cmake gcc-10 clang-14 libsystemd-dev libbsd-dev ninja-build
/opt/hostedtoolcache/Python/3.11.6/x64/bin/pip install mako
/opt/hostedtoolcache/Python/3.12.0/x64/bin/pip install mako
which gcc-10
which clang-14
- name: Prepare Vulkan SDK
Expand All @@ -120,6 +131,8 @@ jobs:
run: |
sudo apt-get update --yes
sudo apt-get install --yes cmake gcc-10 clang-14 libsystemd-dev libbsd-dev ninja-build
/opt/hostedtoolcache/Python/3.11.6/x64/bin/pip install mako
/opt/hostedtoolcache/Python/3.12.0/x64/bin/pip install mako
which gcc-10
which clang-14
- name: Prepare Vulkan SDK
Expand All @@ -142,6 +155,7 @@ jobs:
run: |
sudo apt-get update --yes
sudo apt-get install --yes cmake ninja-build
sudo apt-get install python3-mako --yes
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
Expand Down
41 changes: 40 additions & 1 deletion dive_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ else()
set(NATVIS_FILES "")
endif()

# Disable following warnings for compiling .c files in mesa
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-override-init -Wno-sign-compare")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

Expand All @@ -37,6 +40,8 @@ set(PM4_INFO_FILE "${DIVE_CORE_GENERATED_FILE_DIR}/pm4_info")
set(PM4_GENERATED_SRC_FILE "${DIVE_CORE_GENERATED_FILE_DIR}/pm4_info.cpp")
set(PM4_GENERATED_HDR_FILE "${DIVE_CORE_GENERATED_FILE_DIR}/pm4_info.h")
set(ADRENO_HDR_FILE "${DIVE_CORE_GENERATED_FILE_DIR}/adreno.h")
set(A6XX_PY_FILE "${DIVE_CORE_GENERATED_FILE_DIR}/a6xx.py")
set(FREEDRENO_DEVICES_HDR_FILE "${DIVE_CORE_GENERATED_FILE_DIR}/freedreno_devices.h")

if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
find_program (Python3_EXECUTABLE python3)
Expand Down Expand Up @@ -72,6 +77,33 @@ add_custom_command(
)
add_custom_target(adreno_header ALL DEPENDS ${ADRENO_HDR_FILE})

add_custom_command(
OUTPUT ${A6XX_PY_FILE}
COMMAND ${Python3_EXECUTABLE} ${THIRDPARTY_DIRECTORY}/mesa/src/freedreno/registers/gen_header.py
"--rnn"
"${THIRDPARTY_DIRECTORY}/mesa/src/freedreno/registers"
"--xml"
"${THIRDPARTY_DIRECTORY}/mesa/src/freedreno/registers/adreno/a6xx.xml"
"py-defines"
> ${A6XX_PY_FILE}
DEPENDS "${THIRDPARTY_DIRECTORY}/mesa/src/freedreno/registers/gen_header.py"
WORKING_DIRECTORY ${THIRDPARTY_DIRECTORY}/mesa/src/freedreno/registers
VERBATIM
)
add_custom_target(a6xx_py ALL DEPENDS ${A6XX_PY_FILE})

add_custom_command(
OUTPUT ${FREEDRENO_DEVICES_HDR_FILE}
COMMAND ${Python3_EXECUTABLE} ${THIRDPARTY_DIRECTORY}/mesa/src/freedreno/common/freedreno_devices.py
"-p"
"${DIVE_CORE_GENERATED_FILE_DIR}"
> ${FREEDRENO_DEVICES_HDR_FILE}
DEPENDS "${THIRDPARTY_DIRECTORY}/mesa/src/freedreno/common/freedreno_devices.py"
"${A6XX_PY_FILE}"
VERBATIM
)
add_custom_target(freedreno_devices_header ALL DEPENDS ${FREEDRENO_DEVICES_HDR_FILE})

file(GLOB_RECURSE HDR_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
file(GLOB_RECURSE SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
list(FILTER SRC_FILES EXCLUDE REGEX "_tests.cpp$")
Expand All @@ -85,20 +117,27 @@ endif()
file(GLOB_RECURSE COMMON_HDR_FILES "${CMAKE_SOURCE_DIR}/dive_core/common/*.h")
file(GLOB_RECURSE COMMON_SRC_FILES "${CMAKE_SOURCE_DIR}/dive_core/common/*.cpp")

file(GLOB_RECURSE FREEDRENO_SRC_FILES "${THIRDPARTY_DIRECTORY}/mesa/src/freedreno/common/freedreno_dev_info.c")
shanminchao marked this conversation as resolved.
Show resolved Hide resolved

include_directories(${THIRDPARTY_DIRECTORY}/Vulkan-Headers/include ${CMAKE_SOURCE_DIR} ${DIVE_CORE_GENERATED_FILE_DIR})

include_directories(${CMAKE_SOURCE_DIR}/capture_layer)
include_directories(${CMAKE_SOURCE_DIR}/capture_layer/generated)

include_directories(${THIRDPARTY_DIRECTORY}/mesa/src/freedreno/common)
include_directories(${THIRDPARTY_DIRECTORY}/mesa/src/)


add_definitions(-DLITTLEENDIAN_CPU) # Required for some PAL files

add_library(${PROJECT_NAME} STATIC ${HDR_FILES} ${SRC_FILES}
${COMMON_HDR_FILES} ${COMMON_SRC_FILES} ${PM4_GENERATED_SRC_FILE} ${NATVIS_FILES}
${COMMON_HDR_FILES} ${COMMON_SRC_FILES} ${PM4_GENERATED_SRC_FILE} ${NATVIS_FILES} ${FREEDRENO_SRC_FILES}
"${CMAKE_SOURCE_DIR}/capture_layer/generated/command_printer.cpp" "${CMAKE_SOURCE_DIR}/capture_layer/command_printer_brief.cpp"
"${CMAKE_SOURCE_DIR}/capture_layer/generated/command_decoder.cpp" )
add_dependencies(${PROJECT_NAME} pm4_info)
add_dependencies(${PROJECT_NAME} adreno_header)
add_dependencies(${PROJECT_NAME} a6xx_py)
add_dependencies(${PROJECT_NAME} freedreno_devices_header)


if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
Expand Down
24 changes: 19 additions & 5 deletions dive_core/capture_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "capture_layer/generated/command_decoder.h"
#include "capture_layer/generated/command_printer.h"
#include "dive_core/command_hierarchy.h"
#include "freedreno_dev_info.h"
#include "pm4_info.h"

namespace Dive
{
Expand Down Expand Up @@ -946,18 +948,30 @@ CaptureData::LoadResult CaptureData::LoadAdrenoRdFile(std::istream &capture_file
case RD_NONE:
case RD_TEST:
case RD_CMD:
// case RD_GPUADDR:
case RD_CONTEXT:
case RD_CMDSTREAM:
// case RD_CMDSTREAM_ADDR:
case RD_PARAM:
case RD_FLUSH:
case RD_PROGRAM:
case RD_VERT_SHADER:
case RD_FRAG_SHADER:
// case RD_BUFFER_CONTENTS:
case RD_FRAG_SHADER: capture_file.seekg(block_info.m_data_size, std::ios::cur); break;
case RD_GPU_ID:
case RD_CHIP_ID: capture_file.seekg(block_info.m_data_size, std::ios::cur);
{
DIVE_ASSERT(block_info.m_data_size == 4);
uint32_t gpu_id = 0;
capture_file.read(reinterpret_cast<char *>(&gpu_id), block_info.m_data_size);
SetGPUID(gpu_id / 100);
}
break;
case RD_CHIP_ID:
{
DIVE_ASSERT(block_info.m_data_size == 8);
fd_dev_id dev_id;
capture_file.read(reinterpret_cast<char *>(&dev_id.chip_id), block_info.m_data_size);
auto info = fd_dev_info(&dev_id);
SetGPUID(info->chip);
}
break;
}
}
m_memory.Finalize(true, true);
Expand Down
68 changes: 68 additions & 0 deletions dive_core/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,72 @@
# Common functions
import ctypes
import re
c_uint8 = ctypes.c_uint8

class BitfieldsBits(ctypes.LittleEndianStructure):
_fields_ = [
("A2XX", c_uint8, 1),
("A3XX", c_uint8, 1),
("A4XX", c_uint8, 1),
("A5XX", c_uint8, 1),
("A6XX", c_uint8, 1),
("A7XX", c_uint8, 1),
]

class Bitfields(ctypes.Union):
_fields_ = [("bits", BitfieldsBits),
("asbyte", c_uint8)]

# convert "variants" string to bitfield
def GetGPUVariantsBitField(str):
pattern = r"A\d{1}XX"
gpu_list = re.findall(pattern, str)
bitfields = Bitfields()
bitfields.asbyte = 0
a_count = len(gpu_list)
if a_count == 0:
return 0
dash_count = len(re.findall(r"-", str))

# if there is a "-""
# 1. if there are 2 A?xx, we need to add the ones between the 2
# 2. if there is only 1 A?XX, we need to add all following ones
if dash_count != 0:
begin = end = gpu_list[0]
skip = False
if a_count == 2:
end = gpu_list[1]
else:
end = bitfields._fields_[0][1]._fields_[-1][0]
if end != begin:
gpu_list.append(end)
else:
skip = True

# iterate all elements in BitfieldsBits to add the missing ones into "gpu_list"
# note that the begin and end have already added to "gpu_list"
if not skip:
need_add = False
for e in bitfields._fields_[0][1]._fields_:
if e[0] == end:
need_add = False
break

if need_add:
gpu_list.append(e[0])

if e[0] == begin:
need_add = True

for var in gpu_list:
match var:
case "A2XX": bitfields.bits.A2XX = 1
case "A3XX": bitfields.bits.A3XX = 1
case "A4XX": bitfields.bits.A4XX = 1
case "A5XX": bitfields.bits.A5XX = 1
case "A6XX": bitfields.bits.A6XX = 1
case "A7XX": bitfields.bits.A7XX = 1
return bitfields.asbyte

# ---------------------------------------------------------------------------------------
def isBuiltInType(type):
Expand Down
10 changes: 7 additions & 3 deletions dive_core/data_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,17 @@ void CaptureMetadataCreator::FillHardwareSpecificStates(EventStateInfo::Iterator
const uint32_t binw = bitfields.BINW << reg_field_w->m_shr;
const uint32_t binh = bitfields.BINH << reg_field_h->m_shr;
const a6xx_render_mode render_mode = bitfields.RENDER_MODE;
// TODO(wangra): this is only available on a6xx, should disable this on a7xx captures
const a6xx_buffers_location buffers_location = bitfields.BUFFERS_LOCATION;

event_state_it->SetBinW(binw);
event_state_it->SetBinH(binh);
event_state_it->SetRenderMode(render_mode);
event_state_it->SetBuffersLocation(buffers_location);

// this is only available on a6xx
if (IsFieldEnabled(GetRegFieldByName("BUFFERS_LOCATION", reg_info)))
{
const a6xx_buffers_location buffers_location = bitfields.BUFFERS_LOCATION;
event_state_it->SetBuffersLocation(buffers_location);
}
}

// helper lane related
Expand Down
Loading
Loading