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

support AGS 6.2.0 #1439

Merged
merged 2 commits into from
Mar 12, 2024
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
180 changes: 103 additions & 77 deletions external/precompiled/win64/include/amd_ags.h

Large diffs are not rendered by default.

Binary file modified external/precompiled/win64/lib/ags.lib
Binary file not shown.
Binary file modified external/precompiled/win64/lib/agsd.lib
Binary file not shown.
20 changes: 16 additions & 4 deletions framework/decode/custom_ags_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ void AgsDecoder::DecodeFunctionCall(format::ApiCallId call_id,
Decode_agsDeInitialize(call_info, parameter_buffer, buffer_size);
break;
case format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_0_1:
Decode_agsDriverExtensionsDX12_CreateDevice(call_info, parameter_buffer, buffer_size);
Decode_agsDriverExtensionsDX12_CreateDevice_601(call_info, parameter_buffer, buffer_size);
break;
case format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_2_0:
Decode_agsDriverExtensionsDX12_CreateDevice_620(call_info, parameter_buffer, buffer_size);
break;
case format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_DestroyDevice_6_0_1:
Decode_agsDriverExtensionsDX12_DestroyDevice(call_info, parameter_buffer, buffer_size);
Expand Down Expand Up @@ -141,9 +144,9 @@ AgsDecoder::Decode_agsDeInitialize(const ApiCallInfo& call_info, const uint8_t*
return bytes_read;
}

size_t AgsDecoder::Decode_agsDriverExtensionsDX12_CreateDevice(const ApiCallInfo& call_info,
const uint8_t* parameter_buffer,
size_t buffer_size)
size_t AgsDecoder::Decode_agsDriverExtensionsDX12_CreateDevice_620(const ApiCallInfo& call_info,
const uint8_t* parameter_buffer,
size_t buffer_size)
{
size_t bytes_read = 0;

Expand Down Expand Up @@ -174,6 +177,15 @@ size_t AgsDecoder::Decode_agsDriverExtensionsDX12_CreateDevice(const ApiCallInfo
return bytes_read;
}

size_t AgsDecoder::Decode_agsDriverExtensionsDX12_CreateDevice_601(const ApiCallInfo& call_info,
const uint8_t* parameter_buffer,
size_t buffer_size)
{
GFXRECON_LOG_WARNING("The current capture was made with AGS 6.0.1 but will be replayed with AGS 6.2.0. If replay "
"encounters error, a new capture may be needed.");
return Decode_agsDriverExtensionsDX12_CreateDevice_620(call_info, parameter_buffer, buffer_size);
}

size_t AgsDecoder::Decode_agsDriverExtensionsDX12_DestroyDevice(const ApiCallInfo& call_info,
const uint8_t* parameter_buffer,
size_t buffer_size)
Expand Down
9 changes: 6 additions & 3 deletions framework/decode/custom_ags_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,12 @@ class AgsDecoder : public ApiDecoder
private:
size_t Decode_agsInitialize(const ApiCallInfo& call_info, const uint8_t* parameter_buffer, size_t buffer_size);
size_t Decode_agsDeInitialize(const ApiCallInfo& call_info, const uint8_t* parameter_buffer, size_t buffer_size);
size_t Decode_agsDriverExtensionsDX12_CreateDevice(const ApiCallInfo& call_info,
const uint8_t* parameter_buffer,
size_t buffer_size);
size_t Decode_agsDriverExtensionsDX12_CreateDevice_620(const ApiCallInfo& call_info,
const uint8_t* parameter_buffer,
size_t buffer_size);
size_t Decode_agsDriverExtensionsDX12_CreateDevice_601(const ApiCallInfo& call_info,
const uint8_t* parameter_buffer,
size_t buffer_size);
size_t Decode_agsDriverExtensionsDX12_DestroyDevice(const ApiCallInfo& call_info,
const uint8_t* parameter_buffer,
size_t buffer_size);
Expand Down
21 changes: 16 additions & 5 deletions framework/decode/custom_ags_replay_consumer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
** Copyright (c) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -84,6 +84,8 @@ static std::string GetAgsResultValueString(AGSReturnCode result)
return "AGS_ADL_FAILURE";
case AGS_DX_FAILURE:
return "AGS_DX_FAILURE";
case AGS_D3DDEVICE_NOT_CREATED:
return "AGS_D3DDEVICE_NOT_CREATED";
default:
return std::to_string(result);
}
Expand Down Expand Up @@ -215,13 +217,22 @@ void AgsReplayConsumer::Process_agsInitialize(const ApiCallInfo& call_info,
{
GFXRECON_LOG_WARNING_ONCE(
"agsInitialize function was called with a non-null 'config' parameter during capture. "
"Now for replay, the parameter is set to a nullptr value, because the callback pointers can't be translated.");
"Now for replay, the parameter is set to a nullptr value, because the callback pointers can't be "
"translated.");
}

AGSConfiguration* forced_config = nullptr;
AGSConfiguration* forced_config = nullptr;
auto current_version = AGS_CURRENT_VERSION;

if (agsVersion != current_version)
{
GFXRECON_LOG_WARNING_ONCE(
"The agsInitialize function was called with an AGS version that is different from the current version."
"The replay will be processed with the latest AGS version.");
}

AGSReturnCode result =
ags_dispatch_table_.agsInitialize(agsVersion, forced_config, &current_context_, &gpu_info_replay);
ags_dispatch_table_.agsInitialize(current_version, forced_config, &current_context_, &gpu_info_replay);

CheckReplayResult("Process_agsInitialize", return_value, result);
}
Expand Down Expand Up @@ -264,7 +275,7 @@ void AgsReplayConsumer::Process_agsDriverExtensionsDX12_CreateDevice(
dx12_replay_consumer_->AddObject(&(object_info.capture_id),
reinterpret_cast<void**>(&(object_info.object)),
std::move(object_info),
format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_0_1);
format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_2_0);

returned_parameters.extensionsSupported.padding = 0;
pReturnParams->GetPointer()->extensionsSupported.padding = 0;
Expand Down
4 changes: 2 additions & 2 deletions framework/decode/custom_ags_struct_decoders.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
** Copyright (c) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -277,7 +277,7 @@ size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_AGS_DX12_
bytes_read += ValueDecoder::DecodeUInt32Value((buffer + bytes_read), (buffer_size - bytes_read), &bit_value);
value->rayHitToken = bit_value;
bytes_read += ValueDecoder::DecodeUInt32Value((buffer + bytes_read), (buffer_size - bytes_read), &bit_value);
value->padding = bit_value;
value->shaderClock = (bit_value & 0x1);

return bytes_read;
}
Expand Down
13 changes: 8 additions & 5 deletions framework/encode/custom_ags_api_call_encoders.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
** Copyright (c) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -160,7 +160,10 @@ void EncodeStruct(ParameterEncoder* encoder, const AGSDX12ReturnedParams::Extens
encoder->EncodeUInt32Value(value.floatConversion);
encoder->EncodeUInt32Value(value.readLaneAt);
encoder->EncodeUInt32Value(value.rayHitToken);
encoder->EncodeUInt32Value(value.padding);
uint32_t reserved_vars = 0;
// Future "reserved_vars" could be added here
reserved_vars |= (value.shaderClock & 0x1) << 0;
encoder->EncodeUInt32Value(reserved_vars);
}

void EncodeStruct(ParameterEncoder* encoder, const AGSDisplaySettings& value)
Expand Down Expand Up @@ -219,10 +222,10 @@ void Encode_agsDriverExtensionsDX12_CreateDevice(AGSReturnCode
AGSContext* context,
const AGSDX12DeviceCreationParams* creationParams,
const AGSDX12ExtensionParams* extensionParams,
AGSDX12ReturnedParams* returnedParams)
AGSDX12ReturnedParams* returnedParams,
format::ApiCallId api_id)
{
auto encoder = D3D12CaptureManager::Get()->BeginTrackedApiCallCapture(
format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_0_1);
auto encoder = D3D12CaptureManager::Get()->BeginTrackedApiCallCapture(api_id);
if (encoder)
{
bool omit_output_data = false;
Expand Down
3 changes: 2 additions & 1 deletion framework/encode/custom_ags_api_call_encoders.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ void Encode_agsDriverExtensionsDX12_CreateDevice(AGSReturnCode
AGSContext* context,
const AGSDX12DeviceCreationParams* creationParams,
const AGSDX12ExtensionParams* extensionParams,
AGSDX12ReturnedParams* returnedParams);
AGSDX12ReturnedParams* returnedParams,
format::ApiCallId api_id);

void Encode_agsDriverExtensionsDX12_DestroyDevice(AGSReturnCode result,
AGSContext* context,
Expand Down
70 changes: 55 additions & 15 deletions framework/encode/custom_ags_wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ AMD_AGS_API AGSReturnCode agsInitialize(int agsVersion,
{
AGSReturnCode result = AGSReturnCode::AGS_SUCCESS;

auto manager = D3D12CaptureManager::Get();
auto manager = D3D12CaptureManager::Get();
manager->SetAgsVersion(agsVersion);
if (((agsVersion >> 22) & 0x3FF) < AMD_AGS_VERSION_MAJOR)
{
GFXRECON_LOG_ERROR("The AGS version is not supported.");
}
auto call_scope = manager->IncrementCallScope();

if (call_scope == 1)
Expand Down Expand Up @@ -134,22 +139,57 @@ AMD_AGS_API AGSReturnCode agsDriverExtensionsDX12_CreateDevice(AGSContext*
{
shared_api_call_lock = D3D12CaptureManager::AcquireSharedApiCallLock();
}

CustomWrapperPreCall<format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_0_1>::Dispatch(
manager, context, creationParams, extensionParams, returnedParams);

result = manager->GetAgsDispatchTable().agsDriverExtensionsDX12_CreateDevice(
context, creationParams, extensionParams, returnedParams);

if (SUCCEEDED(result))
auto ags_version = manager->GetAgsVersion();
int ags_major = (ags_version >> 22) & 0x3FF;
int ags_minor = (ags_version >> 12) & 0x3FF;
if (ags_version == AGS_CURRENT_VERSION)
{
WrapObject(creationParams->iid, reinterpret_cast<void**>(&(returnedParams->pDevice)), nullptr);
CustomWrapperPreCall<format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_2_0>::Dispatch(
manager, context, creationParams, extensionParams, returnedParams);

result = manager->GetAgsDispatchTable().agsDriverExtensionsDX12_CreateDevice(
context, creationParams, extensionParams, returnedParams);

if (SUCCEEDED(result))
{
WrapObject(creationParams->iid, reinterpret_cast<void**>(&(returnedParams->pDevice)), nullptr);
}

Encode_agsDriverExtensionsDX12_CreateDevice(
result,
context,
creationParams,
extensionParams,
returnedParams,
format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_2_0);

CustomWrapperPostCall<format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_2_0>::Dispatch(
manager, result, context, creationParams, extensionParams, returnedParams);
}
else if (ags_major == AMD_AGS_VERSION_MAJOR && ags_minor < 2)
{
CustomWrapperPreCall<format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_0_1>::Dispatch(
manager, context, creationParams, extensionParams, returnedParams);

result = manager->GetAgsDispatchTable().agsDriverExtensionsDX12_CreateDevice(
context, creationParams, extensionParams, returnedParams);

if (SUCCEEDED(result))
{
WrapObject(creationParams->iid, reinterpret_cast<void**>(&(returnedParams->pDevice)), nullptr);
}

Encode_agsDriverExtensionsDX12_CreateDevice(
result,
context,
creationParams,
extensionParams,
returnedParams,
format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_0_1);

CustomWrapperPostCall<format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_0_1>::Dispatch(
manager, result, context, creationParams, extensionParams, returnedParams);
}

Encode_agsDriverExtensionsDX12_CreateDevice(result, context, creationParams, extensionParams, returnedParams);

CustomWrapperPostCall<format::ApiCallId::ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_0_1>::Dispatch(
manager, result, context, creationParams, extensionParams, returnedParams);
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions framework/encode/d3d12_capture_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,10 @@ class D3D12CaptureManager : public CaptureManager
bool AddFillMemoryResourceValueCommand(
const std::map<uint64_t, Dx12ResourceValueAnnotator::Dx12FillCommandResourceValue>& resource_values);

void SetAgsVersion(int ags_version) { ags_version_ = ags_version; }

int GetAgsVersion() { return ags_version_; }

protected:
D3D12CaptureManager();

Expand Down Expand Up @@ -791,6 +795,7 @@ class D3D12CaptureManager : public CaptureManager
DxgiDispatchTable dxgi_dispatch_table_; ///< DXGI dispatch table for functions retrieved from the DXGI DLL.
D3D12DispatchTable d3d12_dispatch_table_; ///< D3D12 dispatch table for functions retrieved from the D3D12 DLL.
AgsDispatchTable ags_dispatch_table_; ///< ags dispatch table for functions retrieved from the AGS DLL.
int ags_version_{}; ///< ags version.
static thread_local uint32_t call_scope_; ///< Per-thread scope count to determine when an intercepted API call is
///< being made directly by the application.
bool debug_layer_enabled_; ///< Track if debug layer has been enabled.
Expand Down
3 changes: 2 additions & 1 deletion framework/format/api_call_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,8 @@ enum ApiCallId : uint32_t
ApiCall_Ags_agsDriverExtensionsDX12_PushMarker_6_0_1 = MakeApiCallId(ApiFamily_AGS, 0x1007),
ApiCall_Ags_agsDriverExtensionsDX12_PopMarker_6_0_1 = MakeApiCallId(ApiFamily_AGS, 0x1008),
ApiCall_Ags_agsDriverExtensionsDX12_SetMarker_6_0_1 = MakeApiCallId(ApiFamily_AGS, 0x1009),

ApiCall_Ags_agsDriverExtensionsDX12_CreateDevice_6_2_0 = MakeApiCallId(ApiFamily_AGS, 0x100a),

ApiCall_D3D12Last,

// clang-format on
Expand Down
Loading