vulkan-go / vulkan

Vulkan API bindings for Go programming language
MIT License
742 stars 55 forks source link

PhysicalDeviceProperties -> Limits, all values returned from GetPhysicalDeviceProperties() are set to 0 #55

Closed mojzesh closed 3 years ago

mojzesh commented 3 years ago

Hey! Thanks for great library!

I spotted the following issue with this lib. today on macOS. When I call GetPhysicalDeviceProperties(), I can get other properties like DeviceName, VendorID of PhysicalDeviceProperties just fine, but the embedded Limits structure has all values set to 0.

I'm not sure if this is my local problem or it's just a bug?

{MaxImageDimension1D:0 MaxImageDimension2D:0 MaxImageDimension3D:0 MaxImageDimensionCube:0 MaxImageArrayLayers:0 MaxTexelBufferElements:0 MaxUniformBufferRange:0 MaxStorageBufferRange:0 MaxPushConstantsSize:0 MaxMemoryAllocationCount:0 MaxSamplerAllocationCount:0 BufferImageGranularity:0 SparseAddressSpaceSize:0 MaxBoundDescriptorSets:0 MaxPerStageDescriptorSamplers:0 MaxPerStageDescriptorUniformBuffers:0 MaxPerStageDescriptorStorageBuffers:0 MaxPerStageDescriptorSampledImages:0 MaxPerStageDescriptorStorageImages:0 MaxPerStageDescriptorInputAttachments:0 MaxPerStageResources:0 MaxDescriptorSetSamplers:0 MaxDescriptorSetUniformBuffers:0 MaxDescriptorSetUniformBuffersDynamic:0 MaxDescriptorSetStorageBuffers:0 MaxDescriptorSetStorageBuffersDynamic:0 MaxDescriptorSetSampledImages:0 MaxDescriptorSetStorageImages:0 MaxDescriptorSetInputAttachments:0 MaxVertexInputAttributes:0 MaxVertexInputBindings:0 MaxVertexInputAttributeOffset:0 MaxVertexInputBindingStride:0 MaxVertexOutputComponents:0 MaxTessellationGenerationLevel:0 MaxTessellationPatchSize:0 MaxTessellationControlPerVertexInputComponents:0 MaxTessellationControlPerVertexOutputComponents:0 MaxTessellationControlPerPatchOutputComponents:0 MaxTessellationControlTotalOutputComponents:0 MaxTessellationEvaluationInputComponents:0 MaxTessellationEvaluationOutputComponents:0 MaxGeometryShaderInvocations:0 MaxGeometryInputComponents:0 MaxGeometryOutputComponents:0 MaxGeometryOutputVertices:0 MaxGeometryTotalOutputComponents:0 MaxFragmentInputComponents:0 MaxFragmentOutputAttachments:0 MaxFragmentDualSrcAttachments:0 MaxFragmentCombinedOutputResources:0 MaxComputeSharedMemorySize:0 MaxComputeWorkGroupCount:[0 0 0] MaxComputeWorkGroupInvocations:0 MaxComputeWorkGroupSize:[0 0 0] SubPixelPrecisionBits:0 SubTexelPrecisionBits:0 MipmapPrecisionBits:0 MaxDrawIndexedIndexValue:0 MaxDrawIndirectCount:0 MaxSamplerLodBias:0 MaxSamplerAnisotropy:0 MaxViewports:0 MaxViewportDimensions:[0 0] ViewportBoundsRange:[0 0] ViewportSubPixelBits:0 MinMemoryMapAlignment:0 MinTexelBufferOffsetAlignment:0 MinUniformBufferOffsetAlignment:0 MinStorageBufferOffsetAlignment:0 MinTexelOffset:0 MaxTexelOffset:0 MinTexelGatherOffset:0 MaxTexelGatherOffset:0 MinInterpolationOffset:0 MaxInterpolationOffset:0 SubPixelInterpolationOffsetBits:0 MaxFramebufferWidth:0 MaxFramebufferHeight:0 MaxFramebufferLayers:0 FramebufferColorSampleCounts:0 FramebufferDepthSampleCounts:0 FramebufferStencilSampleCounts:0 FramebufferNoAttachmentsSampleCounts:0 MaxColorAttachments:0 SampledImageColorSampleCounts:0 SampledImageIntegerSampleCounts:0 SampledImageDepthSampleCounts:0 SampledImageStencilSampleCounts:0 StorageImageSampleCounts:0 MaxSampleMaskWords:0 TimestampComputeAndGraphics:0 TimestampPeriod:0 MaxClipDistances:0 MaxCullDistances:0 MaxCombinedClipAndCullDistances:0 DiscreteQueuePriorities:0 PointSizeRange:[0 0] LineWidthRange:[0 0] PointSizeGranularity:0 LineWidthGranularity:0 StrictLines:0 StandardSampleLocations:0 OptimalBufferCopyOffsetAlignment:0 OptimalBufferCopyRowPitchAlignment:0 NonCoherentAtomSize:0 ref7926795a:0x46f55728 allocs7926795a:<nil>}

splace commented 3 years ago

just checking, as another user who initially didn't get this, are you dereferencing?

    var deviceProperties vulkan.PhysicalDeviceProperties
    vulkan.GetPhysicalDeviceProperties(pdev, &deviceProperties)
    deviceProperties.Deref()
xlab commented 3 years ago

Yeah all structs that are mapping to C should be Defer'd which is a copying operation

mojzesh commented 3 years ago

@splace @xlab I'm pretty sure I'm doing that. I'm using Asche and it's doing that oob: https://github.com/vulkan-go/asche/blob/d4b318b67e07d52979747970be6463817ea6ed18/platform.go#L116

mojzesh commented 3 years ago

@splace @xlab Thanks guys for your help, I just looked at this again, and got it working now. I just realised that I need to also call Deref on the nested Limits struct separately So I've just done something like pasted below and it works now!:

var gpuProperties vk.PhysicalDeviceProperties
vk.GetPhysicalDeviceProperties(gpu, &gpuProperties)
gpuProperties.Deref()
limits := gpuProperties.Limits.Deref()
fmt.Println(fmt.Sprintf("%+v\n", limits))

Output: {MaxImageDimension1D:16384 MaxImageDimension2D:16384 MaxImageDimension3D:2048 MaxImageDimensionCube:16384 MaxImageArrayLayers:2048 MaxTexelBufferElements:67108864 MaxUniformBufferRange:65536 MaxStorageBufferRange:2147483648 MaxPushConstantsSize:4096 MaxMemoryAllocationCount:1073741824 MaxSamplerAllocationCount:1073741824 BufferImageGranularity:256 SparseAddressSpaceSize:0 MaxBoundDescriptorSets:8 MaxPerStageDescriptorSamplers:16 MaxPerStageDescriptorUniformBuffers:31 MaxPerStageDescriptorStorageBuffers:31 MaxPerStageDescriptorSampledImages:128 MaxPerStageDescriptorStorageImages:8 MaxPerStageDescriptorInputAttachments:128 MaxPerStageResources:159 MaxDescriptorSetSamplers:80 MaxDescriptorSetUniformBuffers:155 MaxDescriptorSetUniformBuffersDynamic:155 MaxDescriptorSetStorageBuffers:155 MaxDescriptorSetStorageBuffersDynamic:155 MaxDescriptorSetSampledImages:640 MaxDescriptorSetStorageImages:40 MaxDescriptorSetInputAttachments:640 MaxVertexInputAttributes:31 MaxVertexInputBindings:31 MaxVertexInputAttributeOffset:2047 MaxVertexInputBindingStride:2048 MaxVertexOutputComponents:124 MaxTessellationGenerationLevel:64 MaxTessellationPatchSize:32 MaxTessellationControlPerVertexInputComponents:124 MaxTessellationControlPerVertexOutputComponents:124 MaxTessellationControlPerPatchOutputComponents:120 MaxTessellationControlTotalOutputComponents:4088 MaxTessellationEvaluationInputComponents:124 MaxTessellationEvaluationOutputComponents:124 MaxGeometryShaderInvocations:0 MaxGeometryInputComponents:0 MaxGeometryOutputComponents:0 MaxGeometryOutputVertices:0 MaxGeometryTotalOutputComponents:0 MaxFragmentInputComponents:124 MaxFragmentOutputAttachments:8 MaxFragmentDualSrcAttachments:1 MaxFragmentCombinedOutputResources:159 MaxComputeSharedMemorySize:65536 MaxComputeWorkGroupCount:[1073741824 1073741824 1073741824] MaxComputeWorkGroupInvocations:1024 MaxComputeWorkGroupSize:[1024 1024 1024] SubPixelPrecisionBits:4 SubTexelPrecisionBits:4 MipmapPrecisionBits:4 MaxDrawIndexedIndexValue:4294967295 MaxDrawIndirectCount:1073741824 MaxSamplerLodBias:0 MaxSamplerAnisotropy:16 MaxViewports:16 MaxViewportDimensions:[16384 16384] ViewportBoundsRange:[-32768 32767] ViewportSubPixelBits:0 MinMemoryMapAlignment:256 MinTexelBufferOffsetAlignment:16 MinUniformBufferOffsetAlignment:256 MinStorageBufferOffsetAlignment:16 MinTexelOffset:-8 MaxTexelOffset:7 MinTexelGatherOffset:-8 MaxTexelGatherOffset:7 MinInterpolationOffset:-0.5 MaxInterpolationOffset:0.5 SubPixelInterpolationOffsetBits:4 MaxFramebufferWidth:16384 MaxFramebufferHeight:16384 MaxFramebufferLayers:2048 FramebufferColorSampleCounts:15 FramebufferDepthSampleCounts:15 FramebufferStencilSampleCounts:15 FramebufferNoAttachmentsSampleCounts:15 MaxColorAttachments:8 SampledImageColorSampleCounts:15 SampledImageIntegerSampleCounts:15 SampledImageDepthSampleCounts:15 SampledImageStencilSampleCounts:15 StorageImageSampleCounts:1 MaxSampleMaskWords:1 TimestampComputeAndGraphics:1 TimestampPeriod:1 MaxClipDistances:1073741824 MaxCullDistances:0 MaxCombinedClipAndCullDistances:1073741824 DiscreteQueuePriorities:2 PointSizeRange:[1 64] LineWidthRange:[1 1] PointSizeGranularity:1 LineWidthGranularity:1 StrictLines:1 StandardSampleLocations:1 OptimalBufferCopyOffsetAlignment:256 OptimalBufferCopyRowPitchAlignment:1 NonCoherentAtomSize:256 ref7926795a:0x5d45d88 allocs7926795a:<nil>}

I'm closing this issue...