Lines Matching refs:layer

64 Functions for testing of layer interception of unknown functions. Note the need to pass a pointer to the layer and the name
65 of the called function as a parameter, this is necessary to allow a generic layer implementation, as the layer must look up
66 the function pointer to use. A real layer would store the function pointer in a dedicated structure per-instance/device, but
67 since the TestLayer is a generic layer, there isn't a fixed list of functions that should be supported.
70 PFN_vkVoidFunction find_custom_func(TestLayer* layer, const char* name) {
71 if (layer->custom_dispatch_functions.count(name) > 0) {
72 return layer->custom_dispatch_functions.at(name);
79 static VKAPI_ATTR uint32_t VKAPI_CALL func_zero(DispatchableHandleType handle, TestLayer* layer, const char* name, uint32_t i) {
80 auto func = reinterpret_cast<decltype(&func_zero)>(find_custom_func(layer, name));
82 return func(handle, layer, name, i + 3);
84 static VKAPI_ATTR uint32_t VKAPI_CALL func_one(DispatchableHandleType handle, TestLayer* layer, const char* name, uint32_t i,
86 auto func = reinterpret_cast<decltype(&func_one)>(find_custom_func(layer, name));
88 return func(handle, layer, name, i + 2, f + 1.f);
90 static VKAPI_ATTR float VKAPI_CALL func_two(DispatchableHandleType handle, TestLayer* layer, const char* name, uint32_t foo,
92 auto func = reinterpret_cast<decltype(&func_two)>(find_custom_func(layer, name));
94 return func(handle, layer, name, foo + 1, bar + 2, baz * 2);
96 static VKAPI_ATTR int VKAPI_CALL func_three(DispatchableHandleType handle, TestLayer* layer, const char* name, int* ptr_a,
98 auto func = reinterpret_cast<decltype(&func_three)>(find_custom_func(layer, name));
102 return func(handle, layer, name, ptr_a, ptr_b);
104 static VKAPI_ATTR float VKAPI_CALL func_four(DispatchableHandleType handle, TestLayer* layer, const char* name, int* ptr_a,
106 auto func = reinterpret_cast<decltype(&func_four)>(find_custom_func(layer, name));
108 return func(handle, layer, name, ptr_a, ptr_b, foo + 4, bar + 5, k + 1, l + 2, 'd', 'e', 'f');
144 // Add data to the function_list, which could be a driver or a layer list of implementation functions.
157 // Add device interception functions to a layer. Need to call `add_custom_device_interception_function` since the layer has
160 void fill_device_intercept_functions(TestLayer& layer, std::vector<std::string>& func_names, FunctionStruct const& funcs,
163 layer.add_custom_device_interception_function(func_names.at(i++), to_vkVoidFunction(funcs.func_zero));
164 layer.add_custom_device_interception_function(func_names.at(i++), to_vkVoidFunction(funcs.func_one));
165 layer.add_custom_device_interception_function(func_names.at(i++), to_vkVoidFunction(funcs.func_two));
166 layer.add_custom_device_interception_function(func_names.at(i++), to_vkVoidFunction(funcs.func_three));
167 layer.add_custom_device_interception_function(func_names.at(i++), to_vkVoidFunction(funcs.func_four));
170 // Add physical device interception functions to a layer. Need to call `add_custom_device_interception_function` since the
171 // layer has to setup a unordered_map for storing the next function in the chain, and key it based on the name
173 void fill_phys_dev_intercept_functions(TestLayer& layer, std::vector<std::string>& func_names, FunctionStruct const& funcs,
176 layer.add_custom_physical_device_intercept_function(func_names.at(i++), to_vkVoidFunction(funcs.func_zero));
177 layer.add_custom_physical_device_intercept_function(func_names.at(i++), to_vkVoidFunction(funcs.func_one));
178 layer.add_custom_physical_device_intercept_function(func_names.at(i++), to_vkVoidFunction(funcs.func_two));
179 layer.add_custom_physical_device_intercept_function(func_names.at(i++), to_vkVoidFunction(funcs.func_three));
180 layer.add_custom_physical_device_intercept_function(func_names.at(i++), to_vkVoidFunction(funcs.func_four));
216 void check_layer_custom_functions(FunctionLoader& loader, ParentType parent, DispatchableHandleType handle, TestLayer& layer,
222 EXPECT_EQ(returned_func_i(handle, &layer, func_names.at(i).c_str(), i), (i + 3) * 3);
226 EXPECT_EQ(returned_func_if(handle, &layer, func_names.at(i).c_str(), i, i + 1.f), (i + 2) * 3 + (i + 2) * 10);
231 EXPECT_NEAR(returned_func_iif(handle, &layer, func_names.at(i).c_str(), i * 10, i * 5, 0.1234f),
239 EXPECT_EQ(returned_func_pp(handle, &layer, func_names.at(i).c_str(), &x, &y),
248 returned_func_ppiiffccc(handle, &layer, func_names.at(i).c_str(), &x, &y, 200, 300, 0.123f, 1001.89f, 'a', 'b', 'c'),
250 0.001f); // layer changes abc to def
257 TestLayer& layer, FunctionStruct const&, std::vector<std::string>& func_names,
262 EXPECT_EQ(1337U, returned_func_i(handle, &layer, func_names.at(i).c_str(), i));
266 EXPECT_EQ(1337U, returned_func_if(handle, &layer, func_names.at(i).c_str(), i, i + 1.f));
271 EXPECT_NEAR(-1337.0, returned_func_iif(handle, &layer, func_names.at(i).c_str(), i * 10, i * 5, 0.1234f), 0.001);
278 EXPECT_EQ(-1337, returned_func_pp(handle, &layer, func_names.at(i).c_str(), &x, &y));
287 returned_func_ppiiffccc(handle, &layer, func_names.at(i).c_str(), &x, &y, 200, 300, 0.123f, 1001.89f, 'a', 'b', 'c'),
295 TestLayer& layer, FunctionStruct const&, std::vector<std::string>& func_names,
300 EXPECT_EQ(returned_func_i(handle, &layer, func_names.at(i).c_str(), i), (i)*3);
304 EXPECT_EQ(returned_func_if(handle, &layer, func_names.at(i).c_str(), i, i + 1.f), (i)*3 + (i + 1) * 10);
309 EXPECT_NEAR(returned_func_iif(handle, &layer, func_names.at(i).c_str(), i * 10, i * 5, 0.1234f),
317 EXPECT_EQ(returned_func_pp(handle, &layer, func_names.at(i).c_str(), &x, &y),
326 returned_func_ppiiffccc(handle, &layer, func_names.at(i).c_str(), &x, &y, 200, 300, 0.123f, 1001.89f, 'a', 'b', 'c'),
436 auto& layer = env.get_test_layer();
437 fill_implementation_functions(layer.custom_physical_device_implementation_functions, function_names,
444 check_layer_custom_functions_no_interception(env.vulkan_functions, inst.inst, phys_dev, layer,
505 auto& layer = env.get_test_layer();
506 fill_phys_dev_intercept_functions(layer, function_names, layer_intercept_physical_device_functions{}, function_count);
512 check_layer_custom_functions_no_implementation(env.vulkan_functions, inst.inst, phys_dev, layer,
529 auto& layer = env.get_test_layer();
530 fill_phys_dev_intercept_functions(layer, function_names, layer_intercept_physical_device_functions{}, function_count);
536 check_layer_custom_functions(env.vulkan_functions, inst.inst, phys_dev, layer, layer_intercept_physical_device_functions{},
791 static TestLayer* layer;
795 TestLayer* LayerInterceptData<UniqueType>::layer = nullptr;
806 reinterpret_cast<decltype(&implementation)>(LayerType::layer->get_custom_intercept_function(LayerType::name));
834 reinterpret_cast<decltype(&implementation)>(LayerType::layer->get_custom_intercept_function(LayerType::name));
865 reinterpret_cast<decltype(&implementation)>(LayerType::layer->get_custom_intercept_function(LayerType::name));
900 reinterpret_cast<decltype(&implementation)>(LayerType::layer->get_custom_intercept_function(LayerType::name));
949 reinterpret_cast<decltype(&implementation)>(LayerType::layer->get_custom_intercept_function(LayerType::name));
1002 // Find how many layers intercept this function, stop if any layer 'implements' the function, thus doesn't return
1029 static void add_to_layer(UnknownFunction& func, TestLayer& layer, LayerStruct) {
1030 LayerInterceptData<LayerStruct>::layer = &layer;
1032 layer.add_custom_device_interception_function(
1037 static void add_implementation_to_layer(UnknownFunction& func, TestLayer& layer) {
1038 layer.add_custom_device_implementation_function({func.name.c_str(), to_vkVoidFunction(Function::implementation)});
1056 static void add_to_layer(UnknownFunction& func, TestLayer& layer, LayerStruct) {
1057 LayerInterceptData<LayerStruct>::layer = &layer;
1059 layer.add_custom_physical_device_intercept_function(
1064 static void add_implementation_to_layer(UnknownFunction& func, TestLayer& layer) {
1065 layer.add_custom_physical_device_implementation_function({func.name.c_str(), to_vkVoidFunction(Function::implementation)});