MakeDevice and Queue based on QueueIndex
(gp *GPU)
| 66 | |
| 67 | // MakeDevice and Queue based on QueueIndex |
| 68 | func (dv *Device) MakeDevice(gp *GPU) { |
| 69 | queueInfos := []vk.DeviceQueueCreateInfo{{ |
| 70 | SType: vk.StructureTypeDeviceQueueCreateInfo, |
| 71 | QueueFamilyIndex: dv.QueueIndex, |
| 72 | QueueCount: 1, |
| 73 | PQueuePriorities: []float32{1.0}, |
| 74 | }} |
| 75 | |
| 76 | feats := vk.PhysicalDeviceFeatures{ |
| 77 | SamplerAnisotropy: vk.True, // used in Sampler.Config |
| 78 | ShaderSampledImageArrayDynamicIndexing: vk.True, |
| 79 | ShaderUniformBufferArrayDynamicIndexing: vk.True, |
| 80 | ShaderStorageBufferArrayDynamicIndexing: vk.True, |
| 81 | } |
| 82 | gp.SetGPUOpts(&feats, gp.EnabledOpts) |
| 83 | |
| 84 | // log.Printf("features: %#v\n", feats) |
| 85 | |
| 86 | var device vk.Device |
| 87 | ret := vk.CreateDevice(gp.GPU, &vk.DeviceCreateInfo{ |
| 88 | SType: vk.StructureTypeDeviceCreateInfo, |
| 89 | QueueCreateInfoCount: uint32(len(queueInfos)), |
| 90 | PQueueCreateInfos: queueInfos, |
| 91 | EnabledExtensionCount: uint32(len(gp.DeviceExts)), |
| 92 | PpEnabledExtensionNames: gp.DeviceExts, |
| 93 | EnabledLayerCount: uint32(len(gp.ValidationLayers)), |
| 94 | PpEnabledLayerNames: gp.ValidationLayers, |
| 95 | PEnabledFeatures: []vk.PhysicalDeviceFeatures{feats}, |
| 96 | PNext: unsafe.Pointer(gp.DeviceFeaturesNeeded), |
| 97 | }, nil, &device) |
| 98 | IfPanic(NewError(ret)) |
| 99 | |
| 100 | /* note: not using this for PNext: |
| 101 | unsafe.Pointer(&vk.PhysicalDeviceShaderAtomicFloatFeatures{ |
| 102 | SType: vk.StructureTypePhysicalDeviceShaderAtomicFloatFeatures, |
| 103 | ShaderBufferFloat32AtomicAdd: vk.True, |
| 104 | }), |
| 105 | */ |
| 106 | |
| 107 | // _ = ret |
| 108 | dv.Device = device |
| 109 | |
| 110 | var queue vk.Queue |
| 111 | vk.GetDeviceQueue(dv.Device, dv.QueueIndex, 0, &queue) |
| 112 | dv.Queue = queue |
| 113 | } |
| 114 | |
| 115 | func (dv *Device) Destroy() { |
| 116 | if dv.Device == nil { |
no test coverage detected