-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
layer: Add minimum reflection on layer settings
- Loading branch information
1 parent
79d5fb1
commit e36ed76
Showing
9 changed files
with
95 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
// | ||
// Author(s): | ||
// - Christophe Riccio <[email protected]> | ||
|
||
#include "layer_settings_util.hpp" | ||
|
||
#include <sstream> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
// | ||
// Author(s): | ||
// - Christophe Riccio <[email protected]> | ||
|
||
#include "vulkan/layer/vk_layer_settings.h" | ||
#include "layer_settings_util.hpp" | ||
#include "layer_settings_manager.hpp" | ||
|
@@ -17,38 +18,34 @@ | |
#include <cctype> | ||
#include <cstring> | ||
#include <cstdint> | ||
#include <unordered_map> | ||
|
||
static std::unordered_map<VkInstance, vl::LayerSettings> layer_setting_sets; | ||
|
||
// This is used only for unit tests in test_layer_setting_file | ||
void test_helper_SetLayerSetting(VlLayerSettingSet layerSettingSet, const char *pSettingName, const char *pValue) { | ||
assert(layerSettingSet != VK_NULL_HANDLE); | ||
void test_helper_SetLayerSetting(VkInstance instance, const char *pSettingName, const char *pValue) { | ||
assert(instance != VK_NULL_HANDLE); | ||
assert(pSettingName != nullptr); | ||
assert(pValue != nullptr); | ||
|
||
vl::LayerSettings *layer_setting_set = (vl::LayerSettings *)layerSettingSet; | ||
vl::LayerSettings& layer_setting_set = ::layer_setting_sets[instance]; | ||
|
||
layer_setting_set->SetFileSetting(pSettingName, pValue); | ||
layer_setting_set.SetFileSetting(pSettingName, pValue); | ||
} | ||
|
||
VkResult vlCreateLayerSettingSet(const char *pLayerName, const VkLayerSettingsCreateInfoEXT *pCreateInfo, | ||
const VkAllocationCallbacks *pAllocator, VL_LAYER_SETTING_LOG_CALLBACK pCallback, | ||
VlLayerSettingSet *pLayerSettingSet) { | ||
(void)pAllocator; | ||
VkResult vlRegisterLayerSettings(VkInstance instance, const char *pLayerName, uint32_t settingCount, | ||
VkLayerSettingPropertiesEXT *pSettings, const VkAllocationCallbacks *pAllocator) { | ||
vl::LayerSettings layer_settings(pLayerName, settingCount, pSettings, pAllocator); | ||
|
||
vl::LayerSettings* layer_setting_set = new vl::LayerSettings(pLayerName, pCreateInfo, pAllocator, pCallback); | ||
*pLayerSettingSet = (VlLayerSettingSet)layer_setting_set; | ||
::layer_setting_sets | ||
|
||
return VK_SUCCESS; | ||
} | ||
|
||
void vlDestroyLayerSettingSet(VlLayerSettingSet layerSettingSet, const VkAllocationCallbacks *pAllocator) { | ||
(void)pAllocator; | ||
::layer_setting_sets.insert(std::pair(instance, layer_settings)); | ||
|
||
vl::LayerSettings *layer_setting_set = (vl::LayerSettings*)layerSettingSet; | ||
delete layer_setting_set; | ||
return VK_SUCCESS; | ||
} | ||
|
||
VkBool32 vlHasLayerSetting(VlLayerSettingSet layerSettingSet, const char *pSettingName) { | ||
assert(layerSettingSet != VK_NULL_HANDLE); | ||
VkBool32 vlHasLayerSetting(VkInstance instance, const char *pLayerName, const char *pSettingName) { | ||
assert(pSettingName); | ||
assert(!std::string(pSettingName).empty()); | ||
|
||
|
@@ -61,15 +58,15 @@ VkBool32 vlHasLayerSetting(VlLayerSettingSet layerSettingSet, const char *pSetti | |
return (has_env_setting || has_file_setting || has_api_setting) ? VK_TRUE : VK_FALSE; | ||
} | ||
|
||
VkResult vlGetLayerSettingValues(VlLayerSettingSet layerSettingSet, const char *pSettingName, VkLayerSettingTypeEXT type, | ||
VkResult vlGetLayerSettingValues(VkInstance instance, const char *pLayerName, const char *pSettingName, VkLayerSettingTypeEXT type, | ||
uint32_t *pValueCount, void *pValues) { | ||
assert(pValueCount != nullptr); | ||
|
||
if (layerSettingSet == VK_NULL_HANDLE) { | ||
if (instance == VK_NULL_HANDLE) { | ||
return VK_ERROR_INITIALIZATION_FAILED; | ||
} | ||
|
||
if (!vlHasLayerSetting(layerSettingSet, pSettingName)) { | ||
if (!vlHasLayerSetting(instance, pLayerName, pSettingName)) { | ||
*pValueCount = 0; | ||
return VK_SUCCESS; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
// | ||
// Author(s): | ||
// - Christophe Riccio <[email protected]> | ||
|
||
#include "vulkan/layer/vk_layer_settings.hpp" | ||
|
||
static std::string Merge(const std::vector<std::string> &strings) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2023 The Khronos Group Inc. | ||
// Copyright 2023 Valve Corporation | ||
// Copyright 2023 LunarG, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Author(s): | ||
// - Christophe Riccio <[email protected]> | ||
|
||
#include "vulkan/layer/vk_layer_settings_ext.h" | ||
#include <cassert> | ||
#include <cstring> | ||
|
||
#if defined(__GNUC__) && __GNUC__ >= 4 | ||
#define LAYER_EXPORT __attribute__((visibility("default"))) | ||
#else | ||
#define LAYER_EXPORT | ||
#endif | ||
|
||
// Keep synchronized with VkLayer_khronos_profiles.def / VkLayer_khronos_profiles.map | ||
extern "C" { | ||
|
||
LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerSettingsEXT( | ||
VkInstance instance, const char* pLayerName, | ||
uint32_t* pSettingCount, | ||
VkLayerSettingPropertiesEXT* pSettings) { | ||
|
||
assert(pSettingCount != nullptr); | ||
|
||
if (strcmp(pLayerName, VK_EXT_LAYER_SETTINGS_EXTENSION_NAME) != 0) { | ||
return VK_SUCCESS; | ||
} | ||
|
||
if (*pSettingCount > 0 && pSettings != nullptr) { | ||
|
||
} else { | ||
|
||
} | ||
|
||
return VK_SUCCESS; | ||
} | ||
|
||
} // extern "C" |