5#define FML_USED_ON_EMBEDDER
14#include "flutter/fml/synchronization/count_down_latch.h"
15#include "flutter/shell/platform/embedder/tests/embedder_config_builder.h"
16#include "flutter/shell/platform/embedder/tests/embedder_test.h"
17#include "flutter/shell/platform/embedder/tests/embedder_test_context_vulkan.h"
18#include "flutter/shell/platform/embedder/tests/embedder_unittests_util.h"
19#include "flutter/testing/testing.h"
36struct VulkanProcInfo {
43static_assert(std::is_trivially_destructible_v<VulkanProcInfo>);
45VulkanProcInfo g_vulkan_proc_info;
51 FML_DCHECK(g_vulkan_proc_info.queue_submit_proc_addr !=
nullptr);
52 g_vulkan_proc_info.did_call_queue_submit =
true;
53 return g_vulkan_proc_info.queue_submit_proc_addr(
queue, submitCount, pSubmits,
58int StrcmpFixed(
const char* str1,
const char (&str2)[
N]) {
59 return strncmp(str1, str2,
N - 1);
63 FML_DCHECK(g_vulkan_proc_info.get_device_proc_addr !=
nullptr);
64 if (StrcmpFixed(pName,
"vkQueueSubmit") == 0) {
65 g_vulkan_proc_info.queue_submit_proc_addr =
67 g_vulkan_proc_info.get_device_proc_addr(
device, pName));
70 return g_vulkan_proc_info.get_device_proc_addr(
device, pName);
74 FML_DCHECK(g_vulkan_proc_info.get_instance_proc_addr !=
nullptr);
75 if (StrcmpFixed(pName,
"vkGetDeviceProcAddr") == 0) {
76 g_vulkan_proc_info.get_device_proc_addr =
78 g_vulkan_proc_info.get_instance_proc_addr(
instance, pName));
81 return g_vulkan_proc_info.get_instance_proc_addr(
instance, pName);
84template <
typename T,
typename U>
85struct CheckSameSignature : std::false_type {};
87template <
typename Ret,
typename... Args>
88struct CheckSameSignature<Ret(Args...), Ret(Args...)> : std::true_type {};
90static_assert(CheckSameSignature<
decltype(GetInstanceProcAddr),
92static_assert(CheckSameSignature<
decltype(GetDeviceProcAddr),
101 context.AddIsolateCreateCallback([&latch]() { latch.
Signal(); });
103 builder.SetVulkanRendererConfig(
106 const char*
name) ->
void* {
107 if (StrcmpFixed(
name,
"vkGetInstanceProcAddr") == 0) {
108 g_vulkan_proc_info.get_instance_proc_addr =
112 return reinterpret_cast<void*
>(GetInstanceProcAddr);
118 ASSERT_TRUE(
engine.is_valid());
122 EXPECT_TRUE(g_vulkan_proc_info.did_call_queue_submit);
static void * InstanceProcAddr(void *user_data, FlutterVulkanInstanceHandle instance, const char *name)
void * FlutterVulkanInstanceHandle
Alias for VkInstance.
decltype(vkGetInstanceProcAddr) * get_instance_proc_addr
bool did_call_queue_submit
decltype(vkGetDeviceProcAddr) * get_device_proc_addr
decltype(vkQueueSubmit) * queue_submit_proc_addr
#define FML_DCHECK(condition)
TEST_F(DisplayListTest, Defaults)
testing::EmbedderTest EmbedderTest
DEF_SWITCHES_START aot vmservice shared library name
static constexpr SkISize Make(int32_t w, int32_t h)
#define EXPECT_TRUE(handle)
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *pName)
VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence)
void(VKAPI_PTR * PFN_vkVoidFunction)(void)