简体   繁体   English

Vulkan层可以在运行时更改吗?

[英]Can Vulkan Layers change at Runtime?

So I was wanting to make a library to make Vulkan programming easier. 所以我想建立一个库来简化Vulkan编程。 You can see it at Github , but don't expect anything big soon ;). 您可以在Github上看到它,但不要指望很快有大的事情;)。 I want to make a function called getInstanceLayerProperties which returns all the layer properties (obviously). 我想创建一个名为getInstanceLayerProperties的函数,该函数返回所有图层属性(显然)。 Seeing as this could be slower, I wanted to optimize it. 看到这可能会比较慢,所以我想对其进行优化。 My idea is simple: store it as an pre-calculated array. 我的想法很简单:将其存储为预先计算的数组。 All I need to know is: Can the Vulkan layers change during Runtime. 我需要知道的是:Vulkan层是否可以在运行时更改。 For example, say I cached the values of vkEnumerateInstanceLayerProperties . 例如,说我缓存了vkEnumerateInstanceLayerProperties的值。 Can new layer properties be removed, added, or changed so that if I call that function again, I would get different results? 是否可以删除,添加或更改新的图层属性,以便再次调用该函数会得到不同的结果?

The vkEnumerate*Properties return information about the state of the system as it exists at the time the call was made. vkEnumerate * Properties返回有关系统状态的信息,该状态在进行调用时就存在。 That seemed pretty obvious to to us as we were writing the spec, but I can see how that may not be as obvious to someone new to Vulkan. 在我们编写规范时,这对我们来说似乎很明显,但是我可以看到,对于Vulkan的新手来说,这可能并不那么明显。

As the layers are defined outside Vulkan, they can change over time. 由于图层是在Vulkan之外定义的,因此它们会随着时间变化。 Not likely, but they can. 不太可能,但是可以。 That is one of the reasons these calls can return VK_INCOMPLETE. 这就是这些调用可以返回VK_INCOMPLETE的原因之一。 A typical use would be to first make the call to get the count, allocate space for the result and then get the data. 典型的用法是先进行调用以获取计数,为结果分配空间,然后获取数据。 If the list grew between those two calls, the app would see VK_INCOMPLETE and know that something changed. 如果列表在这两个调用之间增加,则该应用程序将看到VK_INCOMPLETE并知道发生了一些变化。

First of all, I would note that this is a perfect way NOT to optimize code. 首先,我要指出,这是不优化代码的完美方法。 It is not and semanticaly even can't be a hot-spot. 从语义上讲,它不是热点,甚至也不能成为热点。
You can't even make use of the cached information unless you destroy your old instance/device and create a new one. 除非销毁旧实例/设备并创建新实例/设备,否则您甚至无法利用缓存的信息。

Now to answer: 现在回答:

Spec-wise there is no statements that explicitly prevent result invalidation. 规范方面,没有明确禁止结果无效的语句。

UPDATE2: Therefore those may change anytime. UPDATE2:因此,这些内容可能随时更改。 Though that would be rare. 虽然那是罕见的。 Only definitive result is wheter vkCreateInstance() returns VK_SUCCESS or VK_ERROR_LAYER_NOT_PRESENT . 只有最终的结果是vkCreateInstance()返回VK_SUCCESSVK_ERROR_LAYER_NOT_PRESENT

(Actually I kinda dislike, that practically all vkGet* and vkEnumerate* commands do not state the nature of invariability of their results. But then I somewhat forgot to raise that as a GitHub Issue...UPDATE2: did that now, before I forget again) (实际上,我有点不喜欢,几乎所有的vkGet*vkEnumerate*命令都没有说明其结果不变性的性质。但是后来我有点忘了把它作为GitHub Issue ... UPDATE2提出来了,现在这样做了,在我忘记之前再次)

Implementation-wise code doing that should be open source. 这样做的实现方式代码应该是开源的。 This should be part of official "The Loader" (also being part of the LunarG SDK). 这应该是官方“ The Loader”的一部分(也是LunarG SDK的一部分)。 I may investigate later. 我可能稍后再调查。 Though it is reasonable to assume new set of layers is read every time from the registry (on Windows, that is). 尽管可以合理地假设每次都从注册表中读取新的一组图层(在Windows中)。 Admittedly, that is somewhat useless information anyway, since they may decide to change that behavior. 诚然,无论如何这都是些无用的信息,因为他们可能决定改变这种行为。

UPDATE: I just scanned it only quickly, but indeed it seems the layers are scanned anew on each call of the vkEnumerateInstanceLayerProperties : https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/blob/74d013a5438f47a66a77d5375d1cdeef3f0beca7/loader/trampoline.c#L227 更新:我只是很快地扫描了它,但实际上似乎在每次调用vkEnumerateInstanceLayerProperties都重新扫描了这些层: https : //github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/blob/74d013a5438f47a66a77d5375d1cdeef3f0beca7/loader/trader/travel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM