!90 merge cherry-pick-mr-87-1772594300797-auto into OpenHarmony-6.1-Release

同步差异

Created-by: zlGiteelz
Commit-by: ZhangLiang
Merged-by: openharmony_ci
Description: 同步差异
https://gitcode.com/openharmony/third_party_vulkan-loader/issues/101

See merge request: openharmony/third_party_vulkan-loader!90
This commit is contained in:
openharmony_ci
2026-03-05 15:32:10 +08:00
5 changed files with 553 additions and 34 deletions
@@ -28,6 +28,7 @@
#pragma once
#include <vulkan/vulkan.h>
#include "vulkan_header_ext_huawei.h"
#if !defined(PFN_GetPhysicalDeviceProcAddr)
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
@@ -0,0 +1,81 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
* Description: vulkan api partial render extended function. Will delete when vulkan-headers heuristic
* Create: 2023/11/27
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
typedef enum VkStructureTypeHUAWEI {
VK_STRUCTURE_TYPE_BLUR_COLOR_FILTER_INFO_HUAWEI = VK_STRUCTURE_TYPE_MAX_ENUM - 15,
VK_STRUCTURE_TYPE_BLUR_NOISE_INFO_HUAWEI = VK_STRUCTURE_TYPE_MAX_ENUM - 14,
VK_STRUCTURE_TYPE_DRAW_BLUR_IMAGE_INFO_HUAWEI = VK_STRUCTURE_TYPE_MAX_ENUM - 13,
/* for hts/ffts semaphore */
VK_STRUCTURE_TYPE_SEMAPHORE_EXT_CREATE_INFO_HUAWEI = VK_STRUCTURE_TYPE_MAX_ENUM - 11,
VK_STRUCTURE_TYPE_RENDER_PASS_DAMAGE_REGION_BEGIN_INFO_TYPE = VK_STRUCTURE_TYPE_MAX_ENUM - 7
} VkstructureTypeHUAWEI;
typedef struct VkRenderPassDamageRegionBeginInfo {
enum VkStructureTypeHUAWEI sType;
const void* pNext;
uint32_t regionCount;
const VkRect2D* regions;
} VkRenderPassDamageRegionBeginInfo;
#define VK_HUAWEI_DRAW_BLUR_IMAGE 1
#define VK_HUAWEI_DRAW_BLUR_IMAGE_SPEC_VERSION 10
#define VK_HUAWEI_DRAW_BLUR_IMAGE_EXTENSION_NAME "VK_HUAWEI_draw_blur_image"
#define VK_HUAWEI_GPU_ERROR_RECOVER (-199999999)
typedef enum VkBlurOriginTypeHUAWEI {
BLUR_ORIGIN_NONE_FLIP_HUAWEI = 0,
BLUR_ORIGIN_Y_AXIS_FLIP_HUAWEI = 1,
} VkBlurOriginTypeHUAWEI;
typedef struct VkDrawBlurImageInfoHUAWEI {
enum VkStructureTypeHUAWEI sType;
const void* pNext;
float sigma;
VkBlurOriginTypeHUAWEI origin;
VkRect2D srcRegion;
VkRect2D dstRegion;
VkImageView srcImageView;
} VkDrawBlurImageInfoHUAWEI;
typedef struct VkBlurNoiseInfoHUAWEI {
enum VkStructureTypeHUAWEI sType;
const void* pNext;
float noiseRatio;
} VkBlurNoiseInfoHUAWEI;
typedef struct VkBlurColorFilterInfoHUAWEI {
enum VkStructureTypeHUAWEI sType;
const void* pNext;
float saturation;
float brightness;
} VkBlurColorFilterInfoHUAWEI;
typedef void (VKAPI_PTR *PFN_vkCmdDrawBlurImageHUAWEI)(VkCommandBuffer commandBuffer,\
const VkDrawBlurImageInfoHUAWEI *drawBlurImageInfo);
typedef VkResult (VKAPI_PTR *PFN_vkGetBlurImageSizeHUAWEI)(VkDevice device, \
const VkDrawBlurImageInfoHUAWEI *drawBlurImageInfo, VkRect2D *pSize);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR void VKAPI_CALL vkCmdDrawBlurImageHUAWEI(
VkCommandBuffer commandBuffer,
const VkDrawBlurImageInfoHUAWEI* drawBlurImageInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkGetBlurImageSizeHUAWEI(
VkDevice device,
const VkDrawBlurImageInfoHUAWEI* drawBlurImageInfo,
VkRect2D* pSize);
#endif
#ifdef __cplusplus
}
#endif
+4 -5
View File
@@ -12,14 +12,14 @@
# limitations under the License.
import("//build/ohos.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")
## Build libvulkan_debug_trace.so {{{
ohos_shared_library("vulkan_debug_trace_layer") {
sources = [ "vk_debug_trace_layer.cpp" ]
include_dirs = [
"debug_trace_layer",
"include",
"../../loader",
"../../loader/generated"
]
defines = [
"VK_NO_PROTOTYPES",
@@ -32,13 +32,12 @@ ohos_shared_library("vulkan_debug_trace_layer") {
"-g3",
]
cflags_cc = [ "-std=c++17" ]
deps = [ "$graphic_2d_root/utils:scoped_bytrace" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"vulkan-headers:vulkan_headers",
"vulkan-loader:vulkan_loader",
"hitrace:hitrace_meter",
"vulkan-headers:vulkan_headers"
]
output_name = "vulkan_debug"
@@ -17,12 +17,12 @@
#include <cstring>
#include <memory>
#include <scoped_bytrace.h>
#include <string>
#include <thread>
#include <unordered_map>
struct LayerData {
struct LayerData
{
VkInstance instance = VK_NULL_HANDLE;
VkDevice device = VK_NULL_HANDLE;
uint32_t instanceVersion = VK_API_VERSION_1_0;
@@ -30,16 +30,16 @@ struct LayerData {
std::unique_ptr<VkLayerInstanceDispatchTable> instanceDispatchTable;
std::unordered_map<VkDebugUtilsMessengerEXT, VkDebugUtilsMessengerCreateInfoEXT> debugCallbacks;
PFN_vkSetDeviceLoaderData fpSetDeviceLoaderData = nullptr;
std::bitset<Extension::EXTENSION_COUNT> enabledExtensions;
// std::bitset<Extension::EXTENSION_COUNT> enabledExtensions;
};
typedef uintptr_t DispatchKey;
static std::mutex g_layerDataMutex;
static std::unordered_map<DispatchKey, LayerData*> g_layerDataMap;
static const VkLayerProperties g_layerProperties = { DEBUG_LAYER_NAME, VK_LAYER_API_VERSION, 1, "Vulkan Debug Layer" };
static const VkLayerProperties g_layerProperties = {DEBUG_LAYER_NAME, VK_LAYER_API_VERSION, 1, "Vulkan Debug Layer"};
template<typename T>
template <typename T>
DispatchKey GetDispatchKey(const T object)
{
return reinterpret_cast<DispatchKey>(*reinterpret_cast<void* const*>(object));
@@ -93,10 +93,10 @@ void FreeLayerData(DispatchKey key)
}
}
VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(
const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
{
ScopedBytrace trace(__func__);
RS_TRACE_NAME(__func__);
if (!pCreateInfo || !pAllocator || !pInstance) {
return VK_ERROR_INITIALIZATION_FAILED;
}
@@ -118,14 +118,13 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(
LayerData* instanceLayerData = GetLayerData(GetDispatchKey(*pInstance));
instanceLayerData->instance = *pInstance;
instanceLayerData->instanceDispatchTable = std::make_unique<VkLayerInstanceDispatchTable>();
layer_init_instance_dispatch_table(
*pInstance, instanceLayerData->instanceDispatchTable.get(), getInstanceProc);
layer_init_instance_dispatch_table(*pInstance, instanceLayerData->instanceDispatchTable.get(), getInstanceProc);
return result;
}
VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator)
{
ScopedBytrace trace(__func__);
RS_TRACE_NAME(__func__);
if (instance == VK_NULL_HANDLE) {
return;
}
@@ -137,9 +136,9 @@ VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocati
}
VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator, VkDevice* pDevice)
const VkAllocationCallbacks* pAllocator, VkDevice* pDevice)
{
ScopedBytrace trace(__func__);
RS_TRACE_NAME(__func__);
if (!pCreateInfo || !pAllocator || !pDevice) {
return VK_ERROR_INITIALIZATION_FAILED;
}
@@ -162,7 +161,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physicalDevice, con
PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chainInfo->u.pLayerInfo->pfnNextGetInstanceProcAddr;
PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chainInfo->u.pLayerInfo->pfnNextGetDeviceProcAddr;
PFN_vkCreateDevice fpCreateDevice =
(PFN_vkCreateDevice)fpGetInstanceProcAddr(gpuLayerData->instance, "vkCreateDevice");
(PFN_vkCreateDevice)fpGetInstanceProcAddr(physicalDeviceData->instance, "vkCreateDevice");
if (fpCreateDevice == nullptr) {
return VK_ERROR_INITIALIZATION_FAILED;
}
@@ -191,15 +190,15 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physicalDevice, con
VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator)
{
ScopedBytrace trace(__func__);
RS_TRACE_NAME(__func__);
DispatchKey deviceKey = GetDispatchKey(device);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->DestroyDevice(device, pAllocator);
FreeLayerData(deviceKey);
}
VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(
const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties)
VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char* pLayerName, uint32_t* pCount,
VkExtensionProperties* pProperties)
{
if (pLayerName == nullptr || pCount == nullptr) {
return VK_ERROR_LAYER_NOT_PRESENT;
@@ -238,8 +237,9 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t* pCount
}
}
VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(
VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties)
VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
const char* pLayerName, uint32_t* pCount,
VkExtensionProperties* pProperties)
{
if (pLayerName == nullptr || pCount == nullptr) {
return VK_ERROR_LAYER_NOT_PRESENT;
@@ -259,10 +259,231 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(
}
}
VKAPI_ATTR VkResult VKAPI_CALL hook_vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo,
const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory)
{
RS_TRACE_NAME("hook_vkAllocateMemory");
DispatchKey deviceKey = GetDispatchKey(device);
LayerData* deviceData = GetLayerData(deviceKey);
return deviceData->deviceDispatchTable->AllocateMemory(device, pAllocateInfo, pAllocator, pMemory);
}
VKAPI_ATTR void VKAPI_CALL hook_vkFreeMemory(VkDevice device, VkDeviceMemory memory,
const VkAllocationCallbacks* pAllocator)
{
RS_TRACE_NAME("hook_vkFreeMemory");
DispatchKey deviceKey = GetDispatchKey(device);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->FreeMemory(device, memory, pAllocator);
}
VKAPI_ATTR VkResult VKAPI_CALL hook_vkAllocateCommandBuffers(VkDevice device,
const VkCommandBufferAllocateInfo* pAllocateInfo,
VkCommandBuffer* pCommandBuffers)
{
RS_TRACE_NAME("hook_vkAllocateCommandBuffers");
DispatchKey deviceKey = GetDispatchKey(device);
LayerData* deviceData = GetLayerData(deviceKey);
return deviceData->deviceDispatchTable->AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers);
}
VKAPI_ATTR VkResult VKAPI_CALL hook_vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits,
VkFence fence)
{
RS_TRACE_NAME("hook_vkQueueSubmit");
DispatchKey deviceKey = GetDispatchKey(queue);
LayerData* deviceData = GetLayerData(deviceKey);
return deviceData->deviceDispatchTable->QueueSubmit(queue, submitCount, pSubmits, fence);
}
VKAPI_ATTR void VKAPI_CALL hook_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
uint32_t commandBufferCount,
const VkCommandBuffer* pCommandBuffers)
{
RS_TRACE_NAME("hook_vkFreeCommandBuffers");
DispatchKey deviceKey = GetDispatchKey(device);
LayerData* deviceData = GetLayerData(deviceKey);
return deviceData->deviceDispatchTable->FreeCommandBuffers(device, commandPool, commandBufferCount,
pCommandBuffers);
}
VKAPI_ATTR VkResult VKAPI_CALL hook_vkBeginCommandBuffer(VkCommandBuffer commandBuffer,
const VkCommandBufferBeginInfo* pBeginInfo)
{
RS_TRACE_NAME("hook_vkBeginCommandBuffer");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
return deviceData->deviceDispatchTable->BeginCommandBuffer(commandBuffer, pBeginInfo);
}
VKAPI_ATTR VkResult VKAPI_CALL hook_vkEndCommandBuffer(VkCommandBuffer commandBuffer)
{
RS_TRACE_NAME("hook_vkEndCommandBuffer");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
return deviceData->deviceDispatchTable->EndCommandBuffer(commandBuffer);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData)
{
RS_TRACE_NAME("hook_vkCmdUpdateBuffer");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
return deviceData->deviceDispatchTable->CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
uint32_t regionCount, const VkBufferCopy* pRegions)
{
RS_TRACE_NAME("hook_vkCmdCopyBuffer");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
return deviceData->deviceDispatchTable->CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
VkImageLayout srcImageLayout, VkImage dstImage,
VkImageLayout dstImageLayout, uint32_t regionCount,
const VkImageCopy* pRegions)
{
RS_TRACE_NAME("hook_vkCmdCopyImage");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout,
regionCount, pRegions);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
VkImageLayout srcImageLayout, VkImage dstImage,
VkImageLayout dstImageLayout, uint32_t regionCount,
const VkImageBlit* pRegions, VkFilter filter)
{
RS_TRACE_NAME("hook_vkCmdBlitImage");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout,
regionCount, pRegions, filter);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
VkImage dstImage, VkImageLayout dstImageLayout,
uint32_t regionCount, const VkBufferImageCopy* pRegions)
{
RS_TRACE_NAME("hook_vkCmdCopyBufferToImage");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage, dstImageLayout,
regionCount, pRegions);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
VkImageLayout srcImageLayout, VkBuffer dstBuffer,
uint32_t regionCount, const VkBufferImageCopy* pRegions)
{
RS_TRACE_NAME("hook_vkCmdCopyImageToBuffer");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer,
regionCount, pRegions);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
{
RS_TRACE_NAME("hook_vkCmdFillBuffer");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
VkImageLayout imageLayout, const VkClearColorValue* pColor,
uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
{
RS_TRACE_NAME("hook_vkCmdClearColorImage");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image,
VkImageLayout imageLayout,
const VkClearDepthStencilValue* pDepthStencil,
uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
{
RS_TRACE_NAME("hook_vkCmdClearDepthStencilImage");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil,
rangeCount, pRanges);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
const VkClearAttachment* pAttachments, uint32_t rectCount,
const VkClearRect* pRects)
{
RS_TRACE_NAME("hook_vkCmdClearAttachments");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdClearAttachments(commandBuffer, attachmentCount, pAttachments, rectCount,
pRects);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage,
VkImageLayout srcImageLayout, VkImage dstImage,
VkImageLayout dstImageLayout, uint32_t regionCount,
const VkImageResolve* pRegions)
{
RS_TRACE_NAME("hook_vkCmdResolveImage");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout,
regionCount, pRegions);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer,
const VkRenderPassBeginInfo* pRenderPassBegin,
VkSubpassContents contents)
{
RS_TRACE_NAME("hook_vkCmdBeginRenderPass");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
uint32_t firstVertex, uint32_t firstInstance)
{
RS_TRACE_NAME("hook_vkCmdDraw");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount,
uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset,
uint32_t firstInstance)
{
RS_TRACE_NAME("hook_vkCmdDrawIndexed");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset,
firstInstance);
}
VKAPI_ATTR void VKAPI_CALL hook_vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
{
RS_TRACE_NAME("hook_vkCmdEndRenderPass");
DispatchKey deviceKey = GetDispatchKey(commandBuffer);
LayerData* deviceData = GetLayerData(deviceKey);
deviceData->deviceDispatchTable->CmdEndRenderPass(commandBuffer);
}
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char* funcName)
{
if (!funcName)
return nullptr;
if (!funcName) return nullptr;
if (std::strcmp(funcName, "vkGetDeviceProcAddr") == 0) {
return reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr);
@@ -270,6 +491,42 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons
if (std::strcmp(funcName, "vkDestroyDevice") == 0) {
return reinterpret_cast<PFN_vkVoidFunction>(DestroyDevice);
}
if (strcmp("vkAllocateMemory", funcName) == 0) {
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkAllocateMemory);
}
if (!strcmp(funcName, "vkFreeMemory")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkFreeMemory);
if (!strcmp(funcName, "vkAllocateCommandBuffers"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkAllocateCommandBuffers);
if (!strcmp(funcName, "vkFreeCommandBuffers"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkFreeCommandBuffers);
if (!strcmp(funcName, "vkBeginCommandBuffer"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkBeginCommandBuffer);
if (!strcmp(funcName, "vkEndCommandBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkEndCommandBuffer);
if (!strcmp(funcName, "vkQueueSubmit")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkQueueSubmit);
if (!strcmp(funcName, "vkCmdCopyBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdCopyBuffer);
if (!strcmp(funcName, "vkCmdCopyImage")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdCopyImage);
if (!strcmp(funcName, "vkCmdBlitImage")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdBlitImage);
if (!strcmp(funcName, "vkCmdCopyBufferToImage"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdCopyBufferToImage);
if (!strcmp(funcName, "vkCmdCopyImageToBuffer"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdCopyImageToBuffer);
if (!strcmp(funcName, "vkCmdUpdateBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdUpdateBuffer);
if (!strcmp(funcName, "vkCmdFillBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdFillBuffer);
if (!strcmp(funcName, "vkCmdClearColorImage"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdClearColorImage);
if (!strcmp(funcName, "vkCmdClearDepthStencilImage"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdClearDepthStencilImage);
if (!strcmp(funcName, "vkCmdClearAttachments"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdClearAttachments);
if (!strcmp(funcName, "vkCmdResolveImage")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdResolveImage);
if (!strcmp(funcName, "vkCmdEndRenderPass")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdEndRenderPass);
if (!strcmp(funcName, "vkCmdDrawIndexed")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdDrawIndexed);
if (!strcmp(funcName, "vkCmdDraw")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdDraw);
if (!strcmp(funcName, "vkCmdBeginRenderPass"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdBeginRenderPass);
LayerData* devData = GetLayerData(GetDispatchKey(device));
VkLayerDispatchTable* pTable = devData->deviceDispatchTable.get();
@@ -281,8 +538,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char* funcName)
{
if (!funcName)
return nullptr;
if (!funcName) return nullptr;
if (std::strcmp(funcName, "vkGetInstanceProcAddr") == 0) {
return reinterpret_cast<PFN_vkVoidFunction>(GetInstanceProcAddr);
@@ -306,6 +562,43 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance
return reinterpret_cast<PFN_vkVoidFunction>(EnumerateDeviceExtensionProperties);
}
if (strcmp("vkAllocateMemory", funcName) == 0) {
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkAllocateMemory);
}
if (!strcmp(funcName, "vkFreeMemory")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkFreeMemory);
if (!strcmp(funcName, "vkAllocateCommandBuffers"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkAllocateCommandBuffers);
if (!strcmp(funcName, "vkFreeCommandBuffers"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkFreeCommandBuffers);
if (!strcmp(funcName, "vkBeginCommandBuffer"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkBeginCommandBuffer);
if (!strcmp(funcName, "vkEndCommandBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkEndCommandBuffer);
if (!strcmp(funcName, "vkQueueSubmit")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkQueueSubmit);
if (!strcmp(funcName, "vkCmdCopyBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdCopyBuffer);
if (!strcmp(funcName, "vkCmdCopyImage")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdCopyImage);
if (!strcmp(funcName, "vkCmdBlitImage")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdBlitImage);
if (!strcmp(funcName, "vkCmdCopyBufferToImage"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdCopyBufferToImage);
if (!strcmp(funcName, "vkCmdCopyImageToBuffer"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdCopyImageToBuffer);
if (!strcmp(funcName, "vkCmdUpdateBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdUpdateBuffer);
if (!strcmp(funcName, "vkCmdFillBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdFillBuffer);
if (!strcmp(funcName, "vkCmdClearColorImage"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdClearColorImage);
if (!strcmp(funcName, "vkCmdClearDepthStencilImage"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdClearDepthStencilImage);
if (!strcmp(funcName, "vkCmdClearAttachments"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdClearAttachments);
if (!strcmp(funcName, "vkCmdResolveImage")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdResolveImage);
if (!strcmp(funcName, "vkCmdEndRenderPass")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdEndRenderPass);
if (!strcmp(funcName, "vkCmdDrawIndexed")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdDrawIndexed);
if (!strcmp(funcName, "vkCmdDraw")) return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdDraw);
if (!strcmp(funcName, "vkCmdBeginRenderPass"))
return reinterpret_cast<PFN_vkVoidFunction>(hook_vkCmdBeginRenderPass);
LayerData* layerData = GetLayerData(GetDispatchKey(instance));
VkLayerInstanceDispatchTable* pTable = layerData->instanceDispatchTable.get();
if (pTable == nullptr) {
@@ -331,8 +624,8 @@ DEBUG_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(
return GetDeviceProcAddr(device, funcName);
}
DEBUG_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(
VkInstance instance, const char* funcName)
DEBUG_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance,
const char* funcName)
{
return GetInstanceProcAddr(instance, funcName);
}
@@ -343,14 +636,15 @@ DEBUG_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionPr
return EnumerateInstanceExtensionProperties(pLayerName, pPropertyCount, pProperties);
}
DEBUG_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
DEBUG_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount,
VkExtensionProperties* pProperties)
{
return EnumerateDeviceExtensionProperties(physicalDevice, pLayerName, pPropertyCount, pProperties);
}
DEBUG_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(
uint32_t* pPropertyCount, VkLayerProperties* pProperties)
DEBUG_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t* pPropertyCount,
VkLayerProperties* pProperties)
{
return EnumerateInstanceLayerProperties(pPropertyCount, pProperties);
}
@@ -19,6 +19,150 @@
#include "vk_dispatch_table_helper.h"
#include "vk_layer_dispatch_table.h"
#ifndef ROSEN_TRACE_DISABLE
#include "hitrace_meter.h"
// deprecated:USE RS_TRACE_BEGIN_XXX instead
#define ROSEN_TRACE_BEGIN(tag, name) StartTrace(tag, name)
#define RS_TRACE_BEGIN(name) ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP | HITRACE_TAG_COMMERCIAL, name)
// deprecated:USE RS_TRACE_END_XXX instead
#define ROSEN_TRACE_END(tag) FinishTrace(tag)
#define RS_TRACE_END() ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP | HITRACE_TAG_COMMERCIAL)
#define RS_TRACE_NAME(name) HITRACE_METER_NAME(HITRACE_TAG_GRAPHIC_AGP | HITRACE_TAG_COMMERCIAL, name)
#define RS_TRACE_NAME_FMT(fmt, ...) \
HITRACE_METER_FMT(HITRACE_TAG_GRAPHIC_AGP | HITRACE_TAG_COMMERCIAL, fmt, ##__VA_ARGS__)
#define RS_ASYNC_TRACE_BEGIN(name, value) StartAsyncTrace(HITRACE_TAG_GRAPHIC_AGP | HITRACE_TAG_COMMERCIAL, name, value)
#define RS_ASYNC_TRACE_END(name, value) FinishAsyncTrace(HITRACE_TAG_GRAPHIC_AGP | HITRACE_TAG_COMMERCIAL, name, value)
#define RS_TRACE_INT(name, value) CountTrace(HITRACE_TAG_GRAPHIC_AGP | HITRACE_TAG_COMMERCIAL, name, value)
#define RS_TRACE_FUNC() RS_TRACE_NAME(__func__)
// DEBUG level
#define RS_TRACE_BEGIN_DEBUG(name, customArgs) \
StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_DEBUG, HITRACE_TAG_GRAPHIC_AGP, name, customArgs)
#define RS_TRACE_END_DEBUG(name) \
FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_DEBUG, HITRACE_TAG_GRAPHIC_AGP)
#define RS_TRACE_NAME_DEBUG(name, customArgs) \
HITRACE_METER_NAME_EX(HiTraceOutputLevel::HITRACE_LEVEL_DEBUG, HITRACE_TAG_GRAPHIC_AGP, name, customArgs)
#define RS_TRACE_NAME_FMT_DEBUG(customArgs, fmt, ...) \
HITRACE_METER_FMT_EX(HiTraceOutputLevel::HITRACE_LEVEL_DEBUG, HITRACE_TAG_GRAPHIC_AGP, \
customArgs, fmt, ##__VA_ARGS__)
#define RS_ASYNC_TRACE_BEGIN_DEBUG(name, value, customCategory, customArgs) \
StartAsyncTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_DEBUG, HITRACE_TAG_GRAPHIC_AGP, name, value, \
customCategory, customArgs)
#define RS_ASYNC_TRACE_END_DEBUG(name, value) \
FinishAsyncTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_DEBUG, HITRACE_TAG_GRAPHIC_AGP, name, value)
#define RS_TRACE_INT_DEBUG(name, value) \
CountTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_DEBUG, HITRACE_TAG_GRAPHIC_AGP, name, value)
#define RS_TRACE_FUNC_DEBUG() RS_TRACE_NAME_DEBUG(__func__, "")
// INFO level
#define RS_TRACE_BEGIN_INFO(name, customArgs) \
StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_GRAPHIC_AGP, name, customArgs)
#define RS_TRACE_END_INFO(name) \
FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_GRAPHIC_AGP)
#define RS_TRACE_NAME_INFO(name, customArgs) \
HITRACE_METER_NAME_EX(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_GRAPHIC_AGP, name, customArgs)
#define RS_TRACE_NAME_FMT_INFO(customArgs, fmt, ...) \
HITRACE_METER_FMT_EX(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_GRAPHIC_AGP, \
customArgs, fmt, ##__VA_ARGS__)
#define RS_ASYNC_TRACE_BEGIN_INFO(name, value, customCategory, customArgs) \
StartAsyncTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_GRAPHIC_AGP, name, value, \
customCategory, customArgs)
#define RS_ASYNC_TRACE_END_INFO(name, value) \
FinishAsyncTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_GRAPHIC_AGP, name, value)
#define RS_TRACE_INT_INFO(name, value) \
CountTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_INFO, HITRACE_TAG_GRAPHIC_AGP, name, value)
#define RS_TRACE_FUNC_INFO() RS_TRACE_NAME_INFO(__func__, "")
// CRITICAL level
#define RS_TRACE_BEGIN_CRITICAL(name, customArgs) \
StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_CRITICAL, HITRACE_TAG_GRAPHIC_AGP, name, customArgs)
#define RS_TRACE_END_CRITICAL(name) \
FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_CRITICAL, HITRACE_TAG_GRAPHIC_AGP)
#define RS_TRACE_NAME_CRITICAL(name, customArgs) \
HITRACE_METER_NAME_EX(HiTraceOutputLevel::HITRACE_LEVEL_CRITICAL, HITRACE_TAG_GRAPHIC_AGP, name, customArgs)
#define RS_TRACE_NAME_FMT_CRITICAL(customArgs, fmt, ...) \
HITRACE_METER_FMT_EX(HiTraceOutputLevel::HITRACE_LEVEL_CRITICAL, HITRACE_TAG_GRAPHIC_AGP, \
customArgs, fmt, ##__VA_ARGS__)
#define RS_ASYNC_TRACE_BEGIN_CRITICAL(name, value, customCategory, customArgs) \
StartAsyncTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_CRITICAL, HITRACE_TAG_GRAPHIC_AGP, name, value, \
customCategory, customArgs)
#define RS_ASYNC_TRACE_END_CRITICAL(name, value) \
FinishAsyncTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_CRITICAL, HITRACE_TAG_GRAPHIC_AGP, name, value)
#define RS_TRACE_INT_CRITICAL(name, value) \
CountTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_CRITICAL, HITRACE_TAG_GRAPHIC_AGP, name, value)
#define RS_TRACE_FUNC_CRITICAL() RS_TRACE_NAME_CRITICAL(__func__, "")
// COMMERCIAL level
#define RS_TRACE_BEGIN_COMMERCIAL(name, customArgs) \
StartTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_COMMERCIAL, HITRACE_TAG_GRAPHIC_AGP, name, customArgs)
#define RS_TRACE_END_COMMERCIAL(name) \
FinishTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_COMMERCIAL, HITRACE_TAG_GRAPHIC_AGP)
#define RS_TRACE_NAME_COMMERCIAL(name, customArgs) \
HITRACE_METER_NAME_EX(HiTraceOutputLevel::HITRACE_LEVEL_COMMERCIAL, HITRACE_TAG_GRAPHIC_AGP, name, customArgs)
#define RS_TRACE_NAME_FMT_COMMERCIAL(customArgs, fmt, ...) \
HITRACE_METER_FMT_EX(HiTraceOutputLevel::HITRACE_LEVEL_COMMERCIAL, HITRACE_TAG_GRAPHIC_AGP, \
customArgs, fmt, ##__VA_ARGS__)
#define RS_ASYNC_TRACE_BEGIN_COMMERCIAL(name, value, customCategory, customArgs) \
StartAsyncTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_COMMERCIAL, HITRACE_TAG_GRAPHIC_AGP, name, value, \
customCategory, customArgs)
#define RS_ASYNC_TRACE_END_COMMERCIAL(name, value) \
FinishAsyncTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_COMMERCIAL, HITRACE_TAG_GRAPHIC_AGP, name, value)
#define RS_TRACE_INT_COMMERCIAL(name, value) \
CountTraceEx(HiTraceOutputLevel::HITRACE_LEVEL_COMMERCIAL, HITRACE_TAG_GRAPHIC_AGP, name, value)
#define RS_TRACE_FUNC_COMMERCIAL() RS_TRACE_NAME_COMMERCIAL(__func__, "")
#else
#define ROSEN_TRACE_BEGIN(tag, name)
#define RS_TRACE_BEGIN(name)
#define ROSEN_TRACE_END(tag)
#define RS_TRACE_END()
#define RS_TRACE_NAME(name)
#define RS_TRACE_NAME_FMT(fmt, ...)
#define RS_ASYNC_TRACE_BEGIN(name, value)
#define RS_ASYNC_TRACE_END(name, value)
#define RS_TRACE_INT(name, value)
#define RS_TRACE_FUNC()
// DEBUG level
#define RS_TRACE_BEGIN_DEBUG(name, customArgs)
#define RS_TRACE_END_DEBUG(name)
#define RS_TRACE_NAME_DEBUG(name, customArgs)
#define RS_TRACE_NAME_FMT_DEBUG(customArgs, fmt, ...)
#define RS_ASYNC_TRACE_BEGIN_DEBUG(name, value, customCategory, customArgs)
#define RS_ASYNC_TRACE_END_DEBUG(name, value)
#define RS_TRACE_INT_DEBUG(name, value)
#define RS_TRACE_FUNC_DEBUG()
// INFO level
#define RS_TRACE_BEGIN_INFO(name, customArgs)
#define RS_TRACE_END_INFO(name)
#define RS_TRACE_NAME_INFO(name, customArgs)
#define RS_TRACE_NAME_FMT_INFO(customArgs, fmt, ...)
#define RS_ASYNC_TRACE_BEGIN_INFO(name, value, customCategory, customArgs)
#define RS_ASYNC_TRACE_END_INFO(name, value)
#define RS_TRACE_INT_INFO(name, value)
#define RS_TRACE_FUNC_INFO()
// CRITICAL level
#define RS_TRACE_BEGIN_CRITICAL(name, customArgs)
#define RS_TRACE_END_CRITICAL(name)
#define RS_TRACE_NAME_CRITICAL(name, customArgs)
#define RS_TRACE_NAME_FMT_CRITICAL(customArgs, fmt, ...)
#define RS_ASYNC_TRACE_BEGIN_CRITICAL(name, value, customCategory, customArgs)
#define RS_ASYNC_TRACE_END_CRITICAL(name, value)
#define RS_TRACE_INT_CRITICAL(name, value)
#define RS_TRACE_FUNC_CRITICAL()
// COMMERCIAL level
#define RS_TRACE_BEGIN_COMMERCIAL(name, customArgs)
#define RS_TRACE_END_COMMERCIAL(name)
#define RS_TRACE_NAME_COMMERCIAL(name, customArgs)
#define RS_TRACE_NAME_FMT_COMMERCIAL(customArgs, fmt, ...)
#define RS_ASYNC_TRACE_BEGIN_COMMERCIAL(name, value, customCategory, customArgs)
#define RS_ASYNC_TRACE_END_COMMERCIAL(name, value)
#define RS_TRACE_INT_COMMERCIAL(name, value)
#define RS_TRACE_FUNC_COMMERCIAL()
#endif
#define DEBUG_LAYER_NAME "VK_LAYER_DEBUG_layer"
#define VK_LAYER_API_VERSION VK_MAKE_VERSION(1, 0, 0)