3.3. Object Model

The devices, queues, and other entities in Vulkan are represented by Vulkan objects.

Vulkan的对象包含设备,队列和其他的实体。

At the API level, all objects are referred to by handles.

在API的层级,所有的对比通过句柄被访问。

There are two classes of handles, dispatchable and nondispatchable.

有两种类型的句柄,可以分发和不可以分发。

Dispatchable handle types are a pointer to an opaque type.

可以分发的句柄类型是一个模糊类型的指针。

This pointer may be used by layers as part of intercepting API commands, and thus each API command takes a dispatchable type as its first parameter.

这个指针被layer用来拦截API命令,和每一个API的命令可以使用disapatchable类型作为它的第一个参数。

Each object of a dispatchable type must have a unique handle value during its lifetime.

每一个dispatchable的对象整个生命周期只能有唯一的句柄。

Non-dispatchable handle types are a 64-bit integer type whose meaning is implementation dependent.

non-dispatcable句柄类型是实现独立的64位整形类型。

If the privateData feature is enabled for a VkDevice, each object of a non-dispatchable type created on that device must have a handle value that is unique among objects created on that device, for the duration of the object’s lifetime.

如果VkDevice的privateData的特性启用的,每一个non-dispatchable类型的必须有一个唯一的句柄。

Otherwise, non-dispatchable handles may encode object information directly in the handle rather than acting as a reference to an underlying object, and thus may not have unique handle values.

否则,non-dispatchable句柄可以直接在句柄中编码对象信息而不是作为隐含对象的应用,和因此无需句柄值。

If handle values are not unique, then destroying one such handle must not cause identical handles of other types to become invalid, and must not cause identical handles of the same type to become invalid if that handle value has been created more times than it has been destroyed.

如果句柄不是唯一的,销毁一个这样的句柄不应该会引起其他类型的无效,和不应该引起同类型完全相同的句柄无效。

All objects created or allocated from a VkDevice (i.e. with a VkDevice as the first parameter) are private to that device, and must not be used on other devices.

一个VkDevice分配或创建的对象仅仅对该设备有效,不能用于其他的设备。

3.3.1. Object Lifetime

Objects are created or allocated by vkCreate* and vkAllocate* commands, respectively.

对象使用vkCreate*来创建,使用vkAllocate*来分配对象。

Once an object is created or allocated, its “structure” is considered to be immutable, though the contents of certain object types is still free to change.

一旦对象被创建或者被分配,它的结构体是不不变的,尽管某些对象的类型的内容仍然可以自由改变。

Objects are destroyed or freed by vkDestroy* and vkFree* commands, respectively.

对象使用vkDestory进行销毁,使用vkFree*来释放对象。

Objects that are allocated (rather than created) take resources from an existing pool object or memory heap, and when freed return resources to that pool or heap.

被分配的对象不是创建的,从已经存在的对象池或者内存堆中获取资源,当被释放返回资源到资源池中。

While object creation and destruction are generally expected to be low-frequency occurrences during runtime, allocating and freeing objects can occur at high frequency.

然而当对象呗创建和销毁的次数希望尽量少,分配和释放可以发生很多次。

Pool objects help accommodate improved performance of the allocations and frees.

对象池帮忙提升性能。

It is an application’s responsibility to track the lifetime of Vulkan objects, and not to destroy them while they are still in use.

应用程序应该跟踪vulkan对象的声明周期,如果是活动的情况下,不应该销毁它。

The ownership of application-owned memory is immediately acquired by any Vulkan command it is passed into.

Vulkan命令需要应用程序内存的所有权被传递进去。

Ownership of such memory must be released back to the application at the end of the duration of the command, so that the application can alter or free this memory as soon as all the commands that acquired it have returned.

在命令执行完,内存的所有权必须返回给应用程序,以至于应用程序可以尽早的修改或者释放内存。

The following object types are consumed when they are passed into a Vulkan command and not further accessed by the objects they are used to create.

如下的对象类型被消耗,不应该进一步被访问由创建他们的对象。

They must not be destroyed in the duration of any API command they are passed into:

他们不应该被销毁在任何API的命令被传递期间:

• VkShaderModule

• VkPipelineCache

A VkRenderPass or VkPipelineLayout object passed as a parameter to create another object is not further accessed by that object after the duration of the command it is passed into.

一个VkRenderPass或者vkPipelineLayout对象作为参数被传递来创建另外一个对象时,它不可以被访问在它传递后。

A VkRenderPass used in a command buffer follows the rules described below.

一个VkRenderPass被使用在command buffer遵循如下的规则.

VkDescriptorSetLayout objects may be accessed by commands that operate on descriptor sets allocated using that layout, and those descriptor sets must not be updated with vkUpdateDescriptorSets after the descriptor set layout has been destroyed.

操作descriptor集合的命令可以访问VkDescriptorSetLayout对象,当descriptor被销毁后vkUpdateDecriptorSets不可以更新。

Otherwise, a VkDescriptorSetLayout object passed as a parameter to create another object is not further accessed by that object after the duration of the command it is passed into.

一个vkDescriptorSetLayout对象作为参数创建另外一个对象时,将不会被访问。

The application must not destroy any other type of Vulkan object until all uses of that object by the device (such as via command buffer execution) have completed.

直到设备使用完,应用程序不会销毁任何其他类型的vulkan对象。

The following Vulkan objects must not be destroyed while any command buffers using the object are in the pending state:

如果comman buffer处于pending状态,下面的vulkan对象不应该被销毁:

• VkEvent • VkQueryPool 

VkBuffer

• VkBufferView

• VkImage

• VkImageView

• VkPipeline

• VkSampler

• VkSamplerYcbcrConversion

• VkDescriptorPool

• VkFramebuffer

• VkRenderPass

• VkCommandBuffer

• VkCommandPool

• VkDeviceMemory

• VkDescriptorSet

Destroying these objects will move any command buffers that are in the recording or executable state, and are using those objects, to the invalid state.

销毁上面对象会让他们从recording或者执行状态转移到无效状态。

The following Vulkan objects must not be destroyed while any queue is executing commands that use the object:

当队列正在使用这些对象时,下面的对象不能被销毁。

• VkFence

• VkSemaphore

• VkCommandBuffer

• VkCommandPool

In general, objects can be destroyed or freed in any order, even if the object being freed is involved in the use of another object (e.g. use of a resource in a view, use of a view in a descriptor set, use of an object in a command buffer, binding of a memory allocation to a resource), as long as any object that uses the freed object is not further used in any way except to be destroyed or to be reset in such a way that it no longer uses the other object (such as resetting a command buffer).

一般来说,对象可以以任何顺序销毁或者被释放,尽管被释放的对象正在被其他的对象使用。

If the object has been reset, then it can be used as if it never used the freed object.

如果对象被重置,然后他可以它可以像从未使用过释放的对象一样使用。

An exception to this is when there is a parent/child relationship between objects.

一个例外是当有一个parenent/child关系在这些对象之间。

In this case, the application must not destroy a parent object before its children, except when the parent is explicitly defined to free its children when it is destroyed (e.g. for pool objects, as defined below).

这种情况下,应用程序一定不能先于子对象销毁父对象。

VkCommandPool objects are parents of VkCommandBuffer objects.

VKCommandpool对象时VkCommandBuffer对象的父对象。

VkDescriptorPool objects are parents of VkDescriptorSet objects.

VKDescriptorPool对象时VkDescriptorSet对象的父对象。

VkDevice objects are parents of many object types (all that take a VkDevice as a parameter to their creation).

VKDevice是很多对象类型的父对象。

The following Vulkan objects have specific restrictions for when they can be destroyed:

下面的对象销毁时有特别的限制:

• VkQueue objects cannot be explicitly destroyed. Instead, they are implicitly destroyed when the

VkDevice object they are retrieved from is destroyed.

VKqueue对象不能被显示销毁。相反,当VkDevice对象被销毁,他们可以被隐含销毁。

Destroying a pool object implicitly frees all objects allocated from that pool.

销毁一个pool对象隐含销毁了从这个pool分配的所有的对象。

Specifically, destroying VkCommandPool frees all VkCommandBuffer objects that were allocated from it, and destroying VkDescriptorPool frees all VkDescriptorSet objects that were allocated from it.

特别,销毁VkCommandPool相当于销毁了从它分配的所有的VkCommandBuffer,销毁VkDescriptorPool相当于销毁了所有从它分配的VkDescriptorSet。

VkDevice objects can be destroyed when all VkQueue objects retrieved from them are idle, and all objects created from them have been destroyed. This includes the following objects:

VKDevice对象可以被销毁,当所有的VkQueue对象是idle,和所有的从它中创建的对象被销毁。它包括如下的对象:

◦ VkFence ◦ VkSemaphore ◦ VkEvent ◦ VkQueryPool ◦ VkBuffer ◦ VkBufferView ◦ VkImage ◦ VkImageView ◦ VkShaderModule ◦ VkPipelineCache ◦ VkPipeline ◦ VkPipelineLayout ◦ VkSampler ◦ VkSamplerYcbcrConversion ◦ VkDescriptorSetLayout ◦ VkDescriptorPool ◦ VkFramebuffer ◦ VkRenderPass ◦ VkCommandPool ◦ VkCommandBuffer ◦ VkDeviceMemory

• VkPhysicalDevice objects cannot be explicitly destroyed. Instead, they are implicitly destroyed when the VkInstance object they are retrieved from is destroyed.

VkPhsicalDevice对象不能被显式销毁。相反,当所有的VkInstance对象从它中分配的被销毁时,他们可以隐式销毁。

• VkInstance objects can be destroyed once all VkDevice objects created from any of its VkPhysicalDevice objects have been destroyed

一旦所有的从VkPhysicalDevice对象分配的VKDevice对象被销毁,VKInstance对象可以被销毁。

3.3.2. External Object Handles

As defined above, the scope of object handles created or allocated from a VkDevice is limited to that logical device.

如上面定义,从VKDevice创建或者分配的对象句柄的使用范围被限制到那个逻辑设备。

Objects which are not in scope are said to be external.

对象不在那个范围被认为是外部的external。

To bring an external object into scope, an external handle must be exported from the object in the source scope and imported into the destination scope.

为了引入外部的对象到这个范围,一个外部的句柄必须从源范围导出和在目的范围进行导入。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值