vulkan icon indicating copy to clipboard operation
vulkan copied to clipboard

How to obtain PhysicalDeviceIDProperties?

Open onyn opened this issue 10 months ago • 7 comments

Hello. How can I get PhysicalDeviceIDProperties struct for my device? I've found func NewPhysicalDeviceIDPropertiesRef(ref unsafe.Pointer) function, but I have no idea where to find this pointer.

Could someone provide example?

onyn avatar Feb 27 '25 20:02 onyn

for type info use "go doc", see; https://pkg.go.dev/cmd/go#hdr-Show_documentation_for_package_or_symbol

and

for vilkan-go examples; https://github.com/vulkan-go/demos

splace avatar Mar 01 '25 23:03 splace

@splace could you point to exact function in "go doc", which provides PhysicalDeviceIDProperties?

onyn avatar Mar 02 '25 06:03 onyn

> go doc PhysicalDeviceIDProperties
package vulkan 

type PhysicalDeviceIDProperties struct {
	SType           StructureType
	PNext           unsafe.Pointer
	DeviceUUID      [16]byte
	DriverUUID      [16]byte
	DeviceLUID      [8]byte
	DeviceNodeMask  uint32
	DeviceLUIDValid Bool32

	// Has unexported fields.
}
    PhysicalDeviceIDProperties as declared in
    https://www.khronos.org/registry/vulkan/specs/1.0/man/html/VkPhysicalDeviceIDProperties.html

func NewPhysicalDeviceIDPropertiesRef(ref unsafe.Pointer) *PhysicalDeviceIDProperties
func (x *PhysicalDeviceIDProperties) Deref()
func (x *PhysicalDeviceIDProperties) Free()
func (x *PhysicalDeviceIDProperties) PassRef() (*C.VkPhysicalDeviceIDProperties, *cgoAllocMap)
func (x PhysicalDeviceIDProperties) PassValue() (C.VkPhysicalDeviceIDProperties, *cgoAllocMap)
func (x *PhysicalDeviceIDProperties) Ref() *C.VkPhysicalDeviceIDProperties


obviously vulkan has to be installed and this only works this simply when you're in its folder.

much help can be obtained using go doc.

splace avatar Mar 07 '25 20:03 splace

also just look at the packages online doc, which was generated by go doc.

https://pkg.go.dev/github.com/vulkan-go/vulkan#PhysicalDeviceIDProperties

splace avatar Mar 07 '25 20:03 splace

Ok. Let's return to my first message:

I've found func NewPhysicalDeviceIDPropertiesRef(ref unsafe.Pointer) function, but I have no idea where to find this pointer.

What your go doc say about ref unsafe.Pointer? How to find valid pointer for this function?

onyn avatar Mar 08 '25 05:03 onyn

OK, this package calls into vulkan, which is compiled c, the unsafe pointer is 'unsafe' due to this, the demos show you this working.

you call funcs to get unsafe pointers, then call on these to get an unpopulated struct that you call another func to populate, you also get a cleanup func because go garbage collecter cant see the c, c doesn't have one anyway, but vulkan has its own way off cleaning up.

i got this from looking at the demos.

splace avatar Mar 08 '25 17:03 splace

you call funcs to get unsafe pointers

What name of the function I need to call to obtain unsafe.Pointer for passing toNewPhysicalDeviceIDPropertiesRef?

onyn avatar Mar 08 '25 18:03 onyn