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

Re-attempt adding Android Frame boundary extension implementation #1288

Merged
merged 2 commits into from
Oct 6, 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
Empty file modified android/gradlew
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions framework/decode/file_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,7 @@ bool FileProcessor::IsFrameDelimiter(format::ApiCallId call_id) const
// This code is deprecated and no new API calls should be added. Instead, end of frame markers are used to track
// the file processor's frame count.
return ((call_id == format::ApiCallId::ApiCall_vkQueuePresentKHR) ||
(call_id == format::ApiCallId::ApiCall_vkFrameBoundaryANDROID) ||
(call_id == format::ApiCallId::ApiCall_IDXGISwapChain_Present) ||
(call_id == format::ApiCallId::ApiCall_IDXGISwapChain1_Present1));
}
Expand Down
10 changes: 10 additions & 0 deletions framework/encode/custom_vulkan_encoder_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ struct CustomEncoderPostCall<format::ApiCallId::ApiCall_vkQueuePresentKHR>
}
};

template <>
struct CustomEncoderPostCall<format::ApiCallId::ApiCall_vkFrameBoundaryANDROID>
{
template <typename... Args>
static void Dispatch(VulkanCaptureManager* manager, Args... args)
{
manager->PostProcess_vkFrameBoundaryANDROID(args...);
}
};

template <>
struct CustomEncoderPostCall<format::ApiCallId::ApiCall_vkGetBufferMemoryRequirements>
{
Expand Down
5 changes: 5 additions & 0 deletions framework/encode/vulkan_capture_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,11 @@ class VulkanCaptureManager : public CaptureManager
void PostProcess_vkCmdDebugMarkerInsertEXT(VkCommandBuffer commandBuffer,
const VkDebugMarkerMarkerInfoEXT* pMarkerInfo);

void PostProcess_vkFrameBoundaryANDROID(VkDevice device, VkSemaphore semaphore, VkImage image)
{
EndFrame();
}

#if defined(__ANDROID__)
void OverrideGetPhysicalDeviceSurfacePresentModesKHR(uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes);
#endif
Expand Down
30 changes: 30 additions & 0 deletions framework/format/VK_ANDROID_frame_boundary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
** Copyright (c) 2023 LunarG, Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
** to deal in the Software without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Software, and to permit persons to whom the
** Software is furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
** FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
** DEALINGS IN THE SOFTWARE.
*/

#ifndef GFXRECON_VK_ANDROID_FRAME_BOUNDARY
#define GFXRECON_VK_ANDROID_FRAME_BOUNDARY

#include "vulkan/vulkan.h"

typedef void(VKAPI_PTR* PFN_vkFrameBoundaryANDROID)(VkDevice device, VkSemaphore semaphore, VkImage image);

#endif
5 changes: 3 additions & 2 deletions framework/format/api_call_id.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright (c) 2018-2021 Valve Corporation
** Copyright (c) 2018-2021 LunarG, Inc.
** Copyright (c) 2018-2023 Valve Corporation
** Copyright (c) 2018-2023 LunarG, Inc.
** Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining a
Expand Down Expand Up @@ -699,6 +699,7 @@ enum ApiCallId : uint32_t
ApiCall_vkGetRenderingAreaGranularityKHR = MakeApiCallId(ApiFamily_Vulkan, 0x12d9),
ApiCall_vkGetDeviceImageSubresourceLayoutKHR = MakeApiCallId(ApiFamily_Vulkan, 0x12da),
ApiCall_vkGetImageSubresourceLayout2KHR = MakeApiCallId(ApiFamily_Vulkan, 0x12db),
ApiCall_vkFrameBoundaryANDROID = MakeApiCallId(ApiFamily_Vulkan, 0x12dc),

ApiCall_VulkanLast,

Expand Down
5 changes: 3 additions & 2 deletions framework/format/platform_types.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright (c) 2018-2020 Valve Corporation
** Copyright (c) 2018-2020 LunarG, Inc.
** Copyright (c) 2018-2023 Valve Corporation
** Copyright (c) 2018-2023 LunarG, Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
Expand All @@ -25,6 +25,7 @@
#define GFXRECON_PLATFORM_TYPES_H

#include "util/logging.h"
#include "VK_ANDROID_frame_boundary.h"

#include "vulkan/vulkan.h"

Expand Down
1 change: 1 addition & 0 deletions framework/generated/generated_layer_func_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ const std::unordered_map<std::string, PFN_vkVoidFunction> func_table = {
{ "vkGetDeviceImageSubresourceLayoutKHR", reinterpret_cast<PFN_vkVoidFunction>(encode::GetDeviceImageSubresourceLayoutKHR) },
{ "vkGetImageSubresourceLayout2KHR", reinterpret_cast<PFN_vkVoidFunction>(encode::GetImageSubresourceLayout2KHR) },
{ "vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR", reinterpret_cast<PFN_vkVoidFunction>(encode::GetPhysicalDeviceCooperativeMatrixPropertiesKHR) },
{ "vkFrameBoundaryANDROID", reinterpret_cast<PFN_vkVoidFunction>(encode::FrameBoundaryANDROID) },
{ "vkCreateDebugReportCallbackEXT", reinterpret_cast<PFN_vkVoidFunction>(encode::CreateDebugReportCallbackEXT) },
{ "vkDestroyDebugReportCallbackEXT", reinterpret_cast<PFN_vkVoidFunction>(encode::DestroyDebugReportCallbackEXT) },
{ "vkDebugReportMessageEXT", reinterpret_cast<PFN_vkVoidFunction>(encode::DebugReportMessageEXT) },
Expand Down
33 changes: 33 additions & 0 deletions framework/generated/generated_vulkan_api_call_encoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13532,6 +13532,39 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceCooperativeMatrixPropertiesKHR(
return result;
}

VKAPI_ATTR void VKAPI_CALL FrameBoundaryANDROID(
VkDevice device,
VkSemaphore semaphore,
VkImage image)
{
auto force_command_serialization = VulkanCaptureManager::Get()->GetForceCommandSerialization();
std::shared_lock<CaptureManager::ApiCallMutexT> shared_api_call_lock;
std::unique_lock<CaptureManager::ApiCallMutexT> exclusive_api_call_lock;
if (force_command_serialization)
{
exclusive_api_call_lock = VulkanCaptureManager::AcquireExclusiveApiCallLock();
}
else
{
shared_api_call_lock = VulkanCaptureManager::AcquireSharedApiCallLock();
}

CustomEncoderPreCall<format::ApiCallId::ApiCall_vkFrameBoundaryANDROID>::Dispatch(VulkanCaptureManager::Get(), device, semaphore, image);

auto encoder = VulkanCaptureManager::Get()->BeginApiCallCapture(format::ApiCallId::ApiCall_vkFrameBoundaryANDROID);
if (encoder)
{
encoder->EncodeHandleValue<DeviceWrapper>(device);
encoder->EncodeHandleValue<SemaphoreWrapper>(semaphore);
encoder->EncodeHandleValue<ImageWrapper>(image);
VulkanCaptureManager::Get()->EndApiCallCapture();
}

GetDeviceTable(device)->FrameBoundaryANDROID(device, semaphore, image);

CustomEncoderPostCall<format::ApiCallId::ApiCall_vkFrameBoundaryANDROID>::Dispatch(VulkanCaptureManager::Get(), device, semaphore, image);
}

VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(
VkInstance instance,
const VkDebugReportCallbackCreateInfoEXT* pCreateInfo,
Expand Down
5 changes: 5 additions & 0 deletions framework/generated/generated_vulkan_api_call_encoders.h
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,11 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceCooperativeMatrixPropertiesKHR(
uint32_t* pPropertyCount,
VkCooperativeMatrixPropertiesKHR* pProperties);

VKAPI_ATTR void VKAPI_CALL FrameBoundaryANDROID(
VkDevice device,
VkSemaphore semaphore,
VkImage image);

VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(
VkInstance instance,
const VkDebugReportCallbackCreateInfoEXT* pCreateInfo,
Expand Down
6 changes: 6 additions & 0 deletions framework/generated/generated_vulkan_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,12 @@ class VulkanConsumer : public VulkanConsumerBase
PointerDecoder<uint32_t>* pPropertyCount,
StructPointerDecoder<Decoded_VkCooperativeMatrixPropertiesKHR>* pProperties) {}

virtual void Process_vkFrameBoundaryANDROID(
const ApiCallInfo& call_info,
format::HandleId device,
format::HandleId semaphore,
format::HandleId image) {}

virtual void Process_vkCreateDebugReportCallbackEXT(
const ApiCallInfo& call_info,
VkResult returnValue,
Expand Down
23 changes: 23 additions & 0 deletions framework/generated/generated_vulkan_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7699,6 +7699,26 @@ size_t VulkanDecoder::Decode_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR(c
return bytes_read;
}

size_t VulkanDecoder::Decode_vkFrameBoundaryANDROID(const ApiCallInfo& call_info, const uint8_t* parameter_buffer, size_t buffer_size)
{
size_t bytes_read = 0;

format::HandleId device;
format::HandleId semaphore;
format::HandleId image;

bytes_read += ValueDecoder::DecodeHandleIdValue((parameter_buffer + bytes_read), (buffer_size - bytes_read), &device);
bytes_read += ValueDecoder::DecodeHandleIdValue((parameter_buffer + bytes_read), (buffer_size - bytes_read), &semaphore);
bytes_read += ValueDecoder::DecodeHandleIdValue((parameter_buffer + bytes_read), (buffer_size - bytes_read), &image);

for (auto consumer : GetConsumers())
{
consumer->Process_vkFrameBoundaryANDROID(call_info, device, semaphore, image);
}

return bytes_read;
}

size_t VulkanDecoder::Decode_vkCreateDebugReportCallbackEXT(const ApiCallInfo& call_info, const uint8_t* parameter_buffer, size_t buffer_size)
{
size_t bytes_read = 0;
Expand Down Expand Up @@ -14277,6 +14297,9 @@ void VulkanDecoder::DecodeFunctionCall(format::ApiCallId call_id,
case format::ApiCallId::ApiCall_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR:
Decode_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR(call_info, parameter_buffer, buffer_size);
break;
case format::ApiCallId::ApiCall_vkFrameBoundaryANDROID:
Decode_vkFrameBoundaryANDROID(call_info, parameter_buffer, buffer_size);
break;
case format::ApiCallId::ApiCall_vkCreateDebugReportCallbackEXT:
Decode_vkCreateDebugReportCallbackEXT(call_info, parameter_buffer, buffer_size);
break;
Expand Down
2 changes: 2 additions & 0 deletions framework/generated/generated_vulkan_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ class VulkanDecoder : public VulkanDecoderBase

size_t Decode_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR(const ApiCallInfo& call_info, const uint8_t* parameter_buffer, size_t buffer_size);

size_t Decode_vkFrameBoundaryANDROID(const ApiCallInfo& call_info, const uint8_t* parameter_buffer, size_t buffer_size);

size_t Decode_vkCreateDebugReportCallbackEXT(const ApiCallInfo& call_info, const uint8_t* parameter_buffer, size_t buffer_size);

size_t Decode_vkDestroyDebugReportCallbackEXT(const ApiCallInfo& call_info, const uint8_t* parameter_buffer, size_t buffer_size);
Expand Down
3 changes: 3 additions & 0 deletions framework/generated/generated_vulkan_dispatch_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ static VKAPI_ATTR void VKAPI_CALL CmdBindIndexBuffer2KHR(VkCommandBuffer, VkBuff
static VKAPI_ATTR void VKAPI_CALL GetRenderingAreaGranularityKHR(VkDevice, const VkRenderingAreaInfoKHR*, VkExtent2D*) { GFXRECON_LOG_WARNING_ONCE("Unsupported function vkGetRenderingAreaGranularityKHR was called, resulting in no-op behavior."); }
static VKAPI_ATTR void VKAPI_CALL GetDeviceImageSubresourceLayoutKHR(VkDevice, const VkDeviceImageSubresourceInfoKHR*, VkSubresourceLayout2KHR*) { GFXRECON_LOG_WARNING_ONCE("Unsupported function vkGetDeviceImageSubresourceLayoutKHR was called, resulting in no-op behavior."); }
static VKAPI_ATTR void VKAPI_CALL GetImageSubresourceLayout2KHR(VkDevice, VkImage, const VkImageSubresource2KHR*, VkSubresourceLayout2KHR*) { GFXRECON_LOG_WARNING_ONCE("Unsupported function vkGetImageSubresourceLayout2KHR was called, resulting in no-op behavior."); }
static VKAPI_ATTR void VKAPI_CALL FrameBoundaryANDROID(VkDevice, VkSemaphore, VkImage) { GFXRECON_LOG_WARNING_ONCE("Unsupported function vkFrameBoundaryANDROID was called, resulting in no-op behavior."); }
static VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectTagEXT(VkDevice, const VkDebugMarkerObjectTagInfoEXT*) { GFXRECON_LOG_WARNING_ONCE("Unsupported function vkDebugMarkerSetObjectTagEXT was called, resulting in no-op behavior."); return VK_SUCCESS; }
static VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectNameEXT(VkDevice, const VkDebugMarkerObjectNameInfoEXT*) { GFXRECON_LOG_WARNING_ONCE("Unsupported function vkDebugMarkerSetObjectNameEXT was called, resulting in no-op behavior."); return VK_SUCCESS; }
static VKAPI_ATTR void VKAPI_CALL CmdDebugMarkerBeginEXT(VkCommandBuffer, const VkDebugMarkerMarkerInfoEXT*) { GFXRECON_LOG_WARNING_ONCE("Unsupported function vkCmdDebugMarkerBeginEXT was called, resulting in no-op behavior."); }
Expand Down Expand Up @@ -1090,6 +1091,7 @@ struct DeviceTable
PFN_vkGetRenderingAreaGranularityKHR GetRenderingAreaGranularityKHR{ noop::GetRenderingAreaGranularityKHR };
PFN_vkGetDeviceImageSubresourceLayoutKHR GetDeviceImageSubresourceLayoutKHR{ noop::GetDeviceImageSubresourceLayoutKHR };
PFN_vkGetImageSubresourceLayout2KHR GetImageSubresourceLayout2KHR{ noop::GetImageSubresourceLayout2KHR };
PFN_vkFrameBoundaryANDROID FrameBoundaryANDROID{ noop::FrameBoundaryANDROID };
PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT{ noop::DebugMarkerSetObjectTagEXT };
PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT{ noop::DebugMarkerSetObjectNameEXT };
PFN_vkCmdDebugMarkerBeginEXT CmdDebugMarkerBeginEXT{ noop::CmdDebugMarkerBeginEXT };
Expand Down Expand Up @@ -1728,6 +1730,7 @@ static void LoadDeviceTable(PFN_vkGetDeviceProcAddr gpa, VkDevice device, Device
LoadFunction(gpa, device, "vkGetRenderingAreaGranularityKHR", &table->GetRenderingAreaGranularityKHR);
LoadFunction(gpa, device, "vkGetDeviceImageSubresourceLayoutKHR", &table->GetDeviceImageSubresourceLayoutKHR);
LoadFunction(gpa, device, "vkGetImageSubresourceLayout2KHR", &table->GetImageSubresourceLayout2KHR);
LoadFunction(gpa, device, "vkFrameBoundaryANDROID", &table->FrameBoundaryANDROID);
LoadFunction(gpa, device, "vkDebugMarkerSetObjectTagEXT", &table->DebugMarkerSetObjectTagEXT);
LoadFunction(gpa, device, "vkDebugMarkerSetObjectNameEXT", &table->DebugMarkerSetObjectNameEXT);
LoadFunction(gpa, device, "vkCmdDebugMarkerBeginEXT", &table->CmdDebugMarkerBeginEXT);
Expand Down
14 changes: 14 additions & 0 deletions framework/generated/generated_vulkan_export_json_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5628,6 +5628,20 @@ void VulkanExportJsonConsumer::Process_vkGetPhysicalDeviceCooperativeMatrixPrope
WriteBlockEnd();
}

void VulkanExportJsonConsumer::Process_vkFrameBoundaryANDROID(
const ApiCallInfo& call_info,
format::HandleId device,
format::HandleId semaphore,
format::HandleId image)
{
nlohmann::ordered_json& jdata = WriteApiCallStart(call_info, "vkFrameBoundaryANDROID");
auto& args = jdata[NameArgs()];
HandleToJson(args["device"], device, json_options_);
HandleToJson(args["semaphore"], semaphore, json_options_);
HandleToJson(args["image"], image, json_options_);
WriteBlockEnd();
}

void VulkanExportJsonConsumer::Process_vkCreateDebugReportCallbackEXT(
const ApiCallInfo& call_info,
VkResult returnValue,
Expand Down
6 changes: 6 additions & 0 deletions framework/generated/generated_vulkan_export_json_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,12 @@ class VulkanExportJsonConsumer : public VulkanExportJsonConsumerBase
PointerDecoder<uint32_t>* pPropertyCount,
StructPointerDecoder<Decoded_VkCooperativeMatrixPropertiesKHR>* pProperties) override;

virtual void Process_vkFrameBoundaryANDROID(
const ApiCallInfo& call_info,
format::HandleId device,
format::HandleId semaphore,
format::HandleId image) override;

virtual void Process_vkCreateDebugReportCallbackEXT(
const ApiCallInfo& call_info,
VkResult returnValue,
Expand Down
13 changes: 13 additions & 0 deletions framework/generated/generated_vulkan_replay_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5440,6 +5440,19 @@ void VulkanReplayConsumer::Process_vkGetPhysicalDeviceCooperativeMatrixPropertie
if (pProperties->IsNull()) { SetOutputArrayCount<PhysicalDeviceInfo>(physicalDevice, kPhysicalDeviceArrayGetPhysicalDeviceCooperativeMatrixPropertiesKHR, *out_pPropertyCount, &VulkanObjectInfoTable::GetPhysicalDeviceInfo); }
}

void VulkanReplayConsumer::Process_vkFrameBoundaryANDROID(
const ApiCallInfo& call_info,
format::HandleId device,
format::HandleId semaphore,
format::HandleId image)
{
VkDevice in_device = MapHandle<DeviceInfo>(device, &VulkanObjectInfoTable::GetDeviceInfo);
VkSemaphore in_semaphore = MapHandle<SemaphoreInfo>(semaphore, &VulkanObjectInfoTable::GetSemaphoreInfo);
VkImage in_image = MapHandle<ImageInfo>(image, &VulkanObjectInfoTable::GetImageInfo);

GetDeviceTable(in_device)->FrameBoundaryANDROID(in_device, in_semaphore, in_image);
}

void VulkanReplayConsumer::Process_vkCreateDebugReportCallbackEXT(
const ApiCallInfo& call_info,
VkResult returnValue,
Expand Down
6 changes: 6 additions & 0 deletions framework/generated/generated_vulkan_replay_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,12 @@ class VulkanReplayConsumer : public VulkanReplayConsumerBase
PointerDecoder<uint32_t>* pPropertyCount,
StructPointerDecoder<Decoded_VkCooperativeMatrixPropertiesKHR>* pProperties) override;

virtual void Process_vkFrameBoundaryANDROID(
const ApiCallInfo& call_info,
format::HandleId device,
format::HandleId semaphore,
format::HandleId image) override;

virtual void Process_vkCreateDebugReportCallbackEXT(
const ApiCallInfo& call_info,
VkResult returnValue,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<registry>
<commands>
<command>
<proto><type>void</type> <name>vkFrameBoundaryANDROID</name></proto>
<param><type>VkDevice</type> <name>device</name></param>
<param><type>VkSemaphore</type> <name>semaphore</name></param>
<param><type>VkImage</type> <name>image</name></param>
</command>
</commands>
<extensions>
<extension name="VK_ANDROID_frame_boundary" platform="android" author="ANDROID" type="device" supported="vulkan">
<require>
<command name="vkFrameBoundaryANDROID"/>
</require>
</extension>
</extensions>
</registry>
Loading