-
Notifications
You must be signed in to change notification settings - Fork 2
/
image_view.go
33 lines (29 loc) · 1.26 KB
/
image_view.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package core1_2
import (
"github.com/vkngwrapper/core/common"
"github.com/vkngwrapper/core/core1_0"
"github.com/vkngwrapper/core/core1_1"
"github.com/vkngwrapper/core/driver"
)
// VulkanImageView is an implementation of the ImageView interface that actually communicates with Vulkan. This
// is the default implementation. See the interface for more documentation.
type VulkanImageView struct {
core1_1.ImageView
}
// PromoteImageView accepts a ImageView object from any core version. If provided an image view that supports
// at least core 1.2, it will return a core1_2.ImageView. Otherwise, it will return nil. This method
// will always return a core1_2.VulkanImageView, even if it is provided a VulkanImageView from a higher
// core version. Two Vulkan 1.2 compatible ImageView objects with the same ImageView.Handle will
// return the same interface value when passed to this method.
func PromoteImageView(imageView core1_0.ImageView) ImageView {
if !imageView.APIVersion().IsAtLeast(common.Vulkan1_2) {
return nil
}
promotedImageView := core1_1.PromoteImageView(imageView)
return imageView.Driver().ObjectStore().GetOrCreate(
driver.VulkanHandle(imageView.Handle()),
driver.Core1_2,
func() any {
return &VulkanImageView{promotedImageView}
}).(ImageView)
}