-
Notifications
You must be signed in to change notification settings - Fork 4
/
context.go
610 lines (538 loc) · 18.7 KB
/
context.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
package asche
import (
"errors"
vk "github.com/vulkan-go/vulkan"
)
type Context interface {
// SetOnPrepare sets callback that will be invoked to initialize and prepare application's vulkan state
// upon context prepare step. onCreate could create textures and pipelines,
// descriptor layouts and render passes.
SetOnPrepare(onPrepare func() error)
// SetOnCleanup sets callback that will be invoked to cleanup application's vulkan state
// upon context prepare step. onCreate could destroy textures and pipelines,
// descriptor layouts and render passes.
SetOnCleanup(onCleanup func() error)
// SetOnInvalidate sets callback that will be invoked when context has been invalidated,
// the application must update its state and prepare the corresponding swapchain image to be presented.
// onInvalidate could compute new vertex and color data in swapchain image resource buffers.
SetOnInvalidate(onInvalidate func(imageIdx int) error)
// Device gets the Vulkan device assigned to the context.
Device() vk.Device
// Platform gets the current platform.
Platform() Platform
// CommandBuffer gets a command buffer currently active.
CommandBuffer() vk.CommandBuffer
// SwapchainDimensions gets the current swapchain dimensions, including pixel format.
SwapchainDimensions() *SwapchainDimensions
// SwapchainImageResources exposes the swapchain initialized image resources.
SwapchainImageResources() []*SwapchainImageResources
// AcquireNextImage
AcquireNextImage() (imageIndex int, outdated bool, err error)
// PresentImage
PresentImage(imageIdx int) (outdated bool, err error)
}
type context struct {
platform Platform
device vk.Device
onPrepare func() error
onCleanup func() error
onInvalidate func(imageIdx int) error
cmd vk.CommandBuffer
cmdPool vk.CommandPool
presentCmdPool vk.CommandPool
swapchain vk.Swapchain
swapchainDimensions *SwapchainDimensions
swapchainImageResources []*SwapchainImageResources
frameLag int
imageAcquiredSemaphores []vk.Semaphore
drawCompleteSemaphores []vk.Semaphore
imageOwnershipSemaphores []vk.Semaphore
frameIndex int
}
func (c *context) preparePresent() {
// Create semaphores to synchronize acquiring presentable buffers before
// rendering and waiting for drawing to be complete before presenting
semaphoreCreateInfo := &vk.SemaphoreCreateInfo{
SType: vk.StructureTypeSemaphoreCreateInfo,
}
c.imageAcquiredSemaphores = make([]vk.Semaphore, c.frameLag)
c.drawCompleteSemaphores = make([]vk.Semaphore, c.frameLag)
c.imageOwnershipSemaphores = make([]vk.Semaphore, c.frameLag)
for i := 0; i < c.frameLag; i++ {
ret := vk.CreateSemaphore(c.device, semaphoreCreateInfo, nil, &c.imageAcquiredSemaphores[i])
orPanic(NewError(ret))
ret = vk.CreateSemaphore(c.device, semaphoreCreateInfo, nil, &c.drawCompleteSemaphores[i])
orPanic(NewError(ret))
if c.platform.HasSeparatePresentQueue() {
ret = vk.CreateSemaphore(c.device, semaphoreCreateInfo, nil, &c.imageOwnershipSemaphores[i])
orPanic(NewError(ret))
}
}
}
func (c *context) destroy() {
func() (err error) {
checkErr(&err)
if c.onCleanup != nil {
err = c.onCleanup()
}
return
}()
for i := 0; i < c.frameLag; i++ {
vk.DestroySemaphore(c.device, c.imageAcquiredSemaphores[i], nil)
vk.DestroySemaphore(c.device, c.drawCompleteSemaphores[i], nil)
if c.platform.HasSeparatePresentQueue() {
vk.DestroySemaphore(c.device, c.imageOwnershipSemaphores[i], nil)
}
}
for i := 0; i < len(c.swapchainImageResources); i++ {
c.swapchainImageResources[i].Destroy(c.device, c.cmdPool)
}
c.swapchainImageResources = nil
if c.swapchain != vk.NullSwapchain {
vk.DestroySwapchain(c.device, c.swapchain, nil)
c.swapchain = vk.NullSwapchain
}
vk.DestroyCommandPool(c.device, c.cmdPool, nil)
if c.platform.HasSeparatePresentQueue() {
vk.DestroyCommandPool(c.device, c.presentCmdPool, nil)
}
c.platform = nil
}
func (c *context) Device() vk.Device {
return c.device
}
func (c *context) Platform() Platform {
return c.platform
}
func (c *context) CommandBuffer() vk.CommandBuffer {
return c.cmd
}
func (c *context) SwapchainDimensions() *SwapchainDimensions {
return c.swapchainDimensions
}
func (c *context) SwapchainImageResources() []*SwapchainImageResources {
return c.swapchainImageResources
}
func (c *context) SetOnPrepare(onPrepare func() error) {
c.onPrepare = onPrepare
}
func (c *context) SetOnCleanup(onCleanup func() error) {
c.onCleanup = onCleanup
}
func (c *context) SetOnInvalidate(onInvalidate func(imageIdx int) error) {
c.onInvalidate = onInvalidate
}
func (c *context) prepare(needCleanup bool) {
vk.DeviceWaitIdle(c.device)
if needCleanup {
if c.onCleanup != nil {
orPanic(c.onCleanup())
}
vk.DestroyCommandPool(c.device, c.cmdPool, nil)
if c.platform.HasSeparatePresentQueue() {
vk.DestroyCommandPool(c.device, c.presentCmdPool, nil)
}
}
var cmdPool vk.CommandPool
ret := vk.CreateCommandPool(c.device, &vk.CommandPoolCreateInfo{
SType: vk.StructureTypeCommandPoolCreateInfo,
QueueFamilyIndex: c.platform.GraphicsQueueFamilyIndex(),
}, nil, &cmdPool)
orPanic(NewError(ret))
c.cmdPool = cmdPool
var cmd = make([]vk.CommandBuffer, 1)
ret = vk.AllocateCommandBuffers(c.device, &vk.CommandBufferAllocateInfo{
SType: vk.StructureTypeCommandBufferAllocateInfo,
CommandPool: c.cmdPool,
Level: vk.CommandBufferLevelPrimary,
CommandBufferCount: 1,
}, cmd)
orPanic(NewError(ret))
c.cmd = cmd[0]
ret = vk.BeginCommandBuffer(c.cmd, &vk.CommandBufferBeginInfo{
SType: vk.StructureTypeCommandBufferBeginInfo,
})
orPanic(NewError(ret))
for i := 0; i < len(c.swapchainImageResources); i++ {
var cmd = make([]vk.CommandBuffer, 1)
vk.AllocateCommandBuffers(c.device, &vk.CommandBufferAllocateInfo{
SType: vk.StructureTypeCommandBufferAllocateInfo,
CommandPool: c.cmdPool,
Level: vk.CommandBufferLevelPrimary,
CommandBufferCount: 1,
}, cmd)
orPanic(NewError(ret))
c.swapchainImageResources[i].cmd = cmd[0]
}
if c.platform.HasSeparatePresentQueue() {
var cmdPool vk.CommandPool
ret = vk.CreateCommandPool(c.device, &vk.CommandPoolCreateInfo{
SType: vk.StructureTypeCommandPoolCreateInfo,
QueueFamilyIndex: c.platform.PresentQueueFamilyIndex(),
}, nil, &cmdPool)
orPanic(NewError(ret))
c.presentCmdPool = cmdPool
for i := 0; i < len(c.swapchainImageResources); i++ {
var cmd = make([]vk.CommandBuffer, 1)
ret = vk.AllocateCommandBuffers(c.device, &vk.CommandBufferAllocateInfo{
SType: vk.StructureTypeCommandBufferAllocateInfo,
CommandPool: c.presentCmdPool,
Level: vk.CommandBufferLevelPrimary,
CommandBufferCount: 1,
}, cmd)
orPanic(NewError(ret))
c.swapchainImageResources[i].graphicsToPresentCmd = cmd[0]
c.swapchainImageResources[i].SetImageOwnership(
c.platform.GraphicsQueueFamilyIndex(), c.platform.PresentQueueFamilyIndex())
}
}
for i := 0; i < len(c.swapchainImageResources); i++ {
var view vk.ImageView
ret = vk.CreateImageView(c.device, &vk.ImageViewCreateInfo{
SType: vk.StructureTypeImageViewCreateInfo,
Format: c.swapchainDimensions.Format,
Components: vk.ComponentMapping{
R: vk.ComponentSwizzleR,
G: vk.ComponentSwizzleG,
B: vk.ComponentSwizzleB,
A: vk.ComponentSwizzleA,
},
SubresourceRange: vk.ImageSubresourceRange{
AspectMask: vk.ImageAspectFlags(vk.ImageAspectColorBit),
LevelCount: 1,
LayerCount: 1,
},
ViewType: vk.ImageViewType2d,
Image: c.swapchainImageResources[i].image,
}, nil, &view)
orPanic(NewError(ret))
c.swapchainImageResources[i].view = view
}
if c.onPrepare != nil {
orPanic(c.onPrepare())
}
c.flushInitCmd()
}
func (c *context) flushInitCmd() {
if c.cmd == nil {
return
}
ret := vk.EndCommandBuffer(c.cmd)
orPanic(NewError(ret))
var fence vk.Fence
ret = vk.CreateFence(c.device, &vk.FenceCreateInfo{
SType: vk.StructureTypeFenceCreateInfo,
}, nil, &fence)
orPanic(NewError(ret))
cmdBufs := []vk.CommandBuffer{c.cmd}
ret = vk.QueueSubmit(c.platform.GraphicsQueue(), 1, []vk.SubmitInfo{{
SType: vk.StructureTypeSubmitInfo,
CommandBufferCount: 1,
PCommandBuffers: cmdBufs,
}}, fence)
orPanic(NewError(ret))
ret = vk.WaitForFences(c.device, 1, []vk.Fence{fence}, vk.True, vk.MaxUint64)
orPanic(NewError(ret))
vk.FreeCommandBuffers(c.device, c.cmdPool, 1, cmdBufs)
vk.DestroyFence(c.device, fence, nil)
c.cmd = nil
}
func (c *context) prepareSwapchain(gpu vk.PhysicalDevice, surface vk.Surface, dimensions *SwapchainDimensions) {
// Read surface capabilities
var surfaceCapabilities vk.SurfaceCapabilities
ret := vk.GetPhysicalDeviceSurfaceCapabilities(gpu, surface, &surfaceCapabilities)
orPanic(NewError(ret))
surfaceCapabilities.Deref()
// Get available surface pixel formats
var formatCount uint32
vk.GetPhysicalDeviceSurfaceFormats(gpu, surface, &formatCount, nil)
formats := make([]vk.SurfaceFormat, formatCount)
vk.GetPhysicalDeviceSurfaceFormats(gpu, surface, &formatCount, formats)
// Select a proper surface format
var format vk.SurfaceFormat
if formatCount == 1 {
formats[0].Deref()
if formats[0].Format == vk.FormatUndefined {
format = formats[0]
format.Format = dimensions.Format
} else {
format = formats[0]
}
} else if formatCount == 0 {
orPanic(errors.New("vulkan error: surface has no pixel formats"))
} else {
formats[0].Deref()
// select the first one available
format = formats[0]
}
// Setup swapchain parameters
var swapchainSize vk.Extent2D
surfaceCapabilities.CurrentExtent.Deref()
if surfaceCapabilities.CurrentExtent.Width == vk.MaxUint32 {
swapchainSize.Width = dimensions.Width
swapchainSize.Height = dimensions.Height
} else {
swapchainSize = surfaceCapabilities.CurrentExtent
}
// The FIFO present mode is guaranteed by the spec to be supported
// and to have no tearing. It's a great default present mode to use.
swapchainPresentMode := vk.PresentModeFifo
// Determine the number of VkImage's to use in the swapchain.
// Ideally, we desire to own 1 image at a time, the rest of the images can either be rendered to and/or
// being queued up for display.
desiredSwapchainImages := surfaceCapabilities.MinImageCount + 1
if surfaceCapabilities.MaxImageCount > 0 && desiredSwapchainImages > surfaceCapabilities.MaxImageCount {
// Application must settle for fewer images than desired.
desiredSwapchainImages = surfaceCapabilities.MaxImageCount
}
// Figure out a suitable surface transform.
var preTransform vk.SurfaceTransformFlagBits
requiredTransforms := vk.SurfaceTransformIdentityBit
supportedTransforms := surfaceCapabilities.SupportedTransforms
if vk.SurfaceTransformFlagBits(supportedTransforms)&requiredTransforms != 0 {
preTransform = requiredTransforms
} else {
preTransform = surfaceCapabilities.CurrentTransform
}
// Find a supported composite alpha mode - one of these is guaranteed to be set
compositeAlpha := vk.CompositeAlphaOpaqueBit
compositeAlphaFlags := []vk.CompositeAlphaFlagBits{
vk.CompositeAlphaOpaqueBit,
vk.CompositeAlphaPreMultipliedBit,
vk.CompositeAlphaPostMultipliedBit,
vk.CompositeAlphaInheritBit,
}
for i := 0; i < len(compositeAlphaFlags); i++ {
alphaFlags := vk.CompositeAlphaFlags(compositeAlphaFlags[i])
flagSupported := surfaceCapabilities.SupportedCompositeAlpha&alphaFlags != 0
if flagSupported {
compositeAlpha = compositeAlphaFlags[i]
break
}
}
// Create a swapchain
var swapchain vk.Swapchain
oldSwapchain := c.swapchain
ret = vk.CreateSwapchain(c.device, &vk.SwapchainCreateInfo{
SType: vk.StructureTypeSwapchainCreateInfo,
Surface: surface,
MinImageCount: desiredSwapchainImages, // 1 - 3?
ImageFormat: format.Format,
ImageColorSpace: format.ColorSpace,
ImageExtent: vk.Extent2D{
Width: swapchainSize.Width,
Height: swapchainSize.Height,
},
ImageUsage: vk.ImageUsageFlags(vk.ImageUsageColorAttachmentBit),
PreTransform: preTransform,
CompositeAlpha: compositeAlpha,
ImageArrayLayers: 1,
ImageSharingMode: vk.SharingModeExclusive,
PresentMode: swapchainPresentMode,
OldSwapchain: oldSwapchain,
Clipped: vk.True,
}, nil, &swapchain)
orPanic(NewError(ret))
if oldSwapchain != vk.NullSwapchain {
vk.DestroySwapchain(c.device, oldSwapchain, nil)
}
c.swapchain = swapchain
c.swapchainDimensions = &SwapchainDimensions{
Width: swapchainSize.Width,
Height: swapchainSize.Height,
Format: format.Format,
}
var imageCount uint32
ret = vk.GetSwapchainImages(c.device, c.swapchain, &imageCount, nil)
orPanic(NewError(ret))
swapchainImages := make([]vk.Image, imageCount)
ret = vk.GetSwapchainImages(c.device, c.swapchain, &imageCount, swapchainImages)
orPanic(NewError(ret))
for i := 0; i < len(c.swapchainImageResources); i++ {
c.swapchainImageResources[i].Destroy(c.device, c.cmdPool)
}
c.swapchainImageResources = make([]*SwapchainImageResources, 0, imageCount)
for i := 0; i < len(swapchainImages); i++ {
c.swapchainImageResources = append(c.swapchainImageResources, &SwapchainImageResources{
image: swapchainImages[i],
})
}
}
func (c *context) AcquireNextImage() (imageIndex int, outdated bool, err error) {
defer checkErr(&err)
// Get the index of the next available swapchain image
var idx uint32
ret := vk.AcquireNextImage(c.device, c.swapchain, vk.MaxUint64,
c.imageAcquiredSemaphores[c.frameIndex], vk.NullFence, &idx)
imageIndex = int(idx)
if c.onInvalidate != nil {
orPanic(c.onInvalidate(imageIndex))
}
switch ret {
case vk.ErrorOutOfDate:
c.frameIndex++
c.frameIndex = c.frameIndex % c.frameLag
c.prepareSwapchain(c.platform.PhysicalDevice(),
c.platform.Surface(), c.SwapchainDimensions())
c.prepare(true)
outdated = true
return
case vk.Suboptimal, vk.Success:
default:
orPanic(NewError(ret))
}
graphicsQueue := c.platform.GraphicsQueue()
var nullFence vk.Fence
ret = vk.QueueSubmit(graphicsQueue, 1, []vk.SubmitInfo{{
SType: vk.StructureTypeSubmitInfo,
PWaitDstStageMask: []vk.PipelineStageFlags{
vk.PipelineStageFlags(vk.PipelineStageColorAttachmentOutputBit),
},
WaitSemaphoreCount: 1,
PWaitSemaphores: []vk.Semaphore{
c.imageAcquiredSemaphores[c.frameIndex],
},
CommandBufferCount: 1,
PCommandBuffers: []vk.CommandBuffer{
c.swapchainImageResources[idx].cmd,
},
SignalSemaphoreCount: 1,
PSignalSemaphores: []vk.Semaphore{
c.drawCompleteSemaphores[c.frameIndex],
},
}}, nullFence)
orPanic(NewError(ret))
if c.platform.HasSeparatePresentQueue() {
presentQueue := c.platform.PresentQueue()
var nullFence vk.Fence
ret = vk.QueueSubmit(presentQueue, 1, []vk.SubmitInfo{{
SType: vk.StructureTypeSubmitInfo,
PWaitDstStageMask: []vk.PipelineStageFlags{
vk.PipelineStageFlags(vk.PipelineStageColorAttachmentOutputBit),
},
WaitSemaphoreCount: 1,
PWaitSemaphores: []vk.Semaphore{
c.imageAcquiredSemaphores[c.frameIndex],
},
CommandBufferCount: 1,
PCommandBuffers: []vk.CommandBuffer{
c.swapchainImageResources[idx].graphicsToPresentCmd,
},
SignalSemaphoreCount: 1,
PSignalSemaphores: []vk.Semaphore{
c.imageOwnershipSemaphores[c.frameIndex],
},
}}, nullFence)
orPanic(NewError(ret))
}
return
}
func (c *context) PresentImage(imageIdx int) (outdated bool, err error) {
// If we are using separate queues we have to wait for image ownership,
// otherwise wait for draw complete.
var semaphore vk.Semaphore
if c.platform.HasSeparatePresentQueue() {
semaphore = c.imageOwnershipSemaphores[c.frameIndex]
} else {
semaphore = c.drawCompleteSemaphores[c.frameIndex]
}
presentQueue := c.platform.PresentQueue()
ret := vk.QueuePresent(presentQueue, &vk.PresentInfo{
SType: vk.StructureTypePresentInfo,
WaitSemaphoreCount: 1,
PWaitSemaphores: []vk.Semaphore{semaphore},
SwapchainCount: 1,
PSwapchains: []vk.Swapchain{c.swapchain},
PImageIndices: []uint32{uint32(imageIdx)},
})
c.frameIndex++
c.frameIndex = c.frameIndex % c.frameLag
switch ret {
case vk.ErrorOutOfDate:
outdated = true
return
case vk.Suboptimal, vk.Success:
return
default:
err = NewError(ret)
return
}
}
type SwapchainImageResources struct {
image vk.Image
cmd vk.CommandBuffer
graphicsToPresentCmd vk.CommandBuffer
view vk.ImageView
framebuffer vk.Framebuffer
descriptorSet vk.DescriptorSet
uniformBuffer vk.Buffer
uniformMemory vk.DeviceMemory
}
func (s *SwapchainImageResources) Destroy(dev vk.Device, cmdPool ...vk.CommandPool) {
vk.DestroyFramebuffer(dev, s.framebuffer, nil)
vk.DestroyImageView(dev, s.view, nil)
if len(cmdPool) > 0 {
vk.FreeCommandBuffers(dev, cmdPool[0], 1, []vk.CommandBuffer{
s.cmd,
})
}
vk.DestroyBuffer(dev, s.uniformBuffer, nil)
vk.FreeMemory(dev, s.uniformMemory, nil)
}
func (s *SwapchainImageResources) SetImageOwnership(graphicsQueueFamilyIndex, presentQueueFamilyIndex uint32) {
ret := vk.BeginCommandBuffer(s.graphicsToPresentCmd, &vk.CommandBufferBeginInfo{
SType: vk.StructureTypeCommandBufferBeginInfo,
Flags: vk.CommandBufferUsageFlags(vk.CommandBufferUsageSimultaneousUseBit),
})
orPanic(NewError(ret))
vk.CmdPipelineBarrier(s.graphicsToPresentCmd,
vk.PipelineStageFlags(vk.PipelineStageColorAttachmentOutputBit),
vk.PipelineStageFlags(vk.PipelineStageColorAttachmentOutputBit),
0, 0, nil, 0, nil, 1, []vk.ImageMemoryBarrier{{
SType: vk.StructureTypeImageMemoryBarrier,
DstAccessMask: vk.AccessFlags(vk.AccessColorAttachmentWriteBit),
OldLayout: vk.ImageLayoutPresentSrc,
NewLayout: vk.ImageLayoutPresentSrc,
SrcQueueFamilyIndex: graphicsQueueFamilyIndex,
DstQueueFamilyIndex: presentQueueFamilyIndex,
Image: s.image,
SubresourceRange: vk.ImageSubresourceRange{
AspectMask: vk.ImageAspectFlags(vk.ImageAspectColorBit),
LevelCount: 1,
LayerCount: 1,
},
}})
ret = vk.EndCommandBuffer(s.graphicsToPresentCmd)
orPanic(NewError(ret))
}
func (s *SwapchainImageResources) SetUniformBuffer(buffer vk.Buffer, mem vk.DeviceMemory) {
s.uniformBuffer = buffer
s.uniformMemory = mem
}
func (s *SwapchainImageResources) Framebuffer() vk.Framebuffer {
return s.framebuffer
}
func (s *SwapchainImageResources) SetFramebuffer(fb vk.Framebuffer) {
s.framebuffer = fb
}
func (s *SwapchainImageResources) UniformBuffer() vk.Buffer {
return s.uniformBuffer
}
func (s *SwapchainImageResources) UniformMemory() vk.DeviceMemory {
return s.uniformMemory
}
func (s *SwapchainImageResources) CommandBuffer() vk.CommandBuffer {
return s.cmd
}
func (s *SwapchainImageResources) Image() vk.Image {
return s.image
}
func (s *SwapchainImageResources) View() vk.ImageView {
return s.view
}
func (s *SwapchainImageResources) DescriptorSet() vk.DescriptorSet {
return s.descriptorSet
}
func (s *SwapchainImageResources) SetDescriptorSet(set vk.DescriptorSet) {
s.descriptorSet = set
}