1extern crate ash;
17
18pub type BufferType = ash::vk::Buffer;
19pub type ImageType = ash::vk::Image;
20pub type ImageSubresourceRangeType = ash::vk::ImageSubresourceRange;
21
22pub mod cmd;
23
24#[derive(Debug, Copy, Clone, PartialEq)]
26pub enum AccessType {
27 Nothing,
29
30 CommandBufferReadNVX,
32
33 IndirectBuffer,
35
36 IndexBuffer,
38
39 VertexBuffer,
41
42 VertexShaderReadUniformBuffer,
44
45 VertexShaderReadSampledImageOrUniformTexelBuffer,
47
48 VertexShaderReadOther,
50
51 TessellationControlShaderReadUniformBuffer,
53
54 TessellationControlShaderReadSampledImageOrUniformTexelBuffer,
56
57 TessellationControlShaderReadOther,
59
60 TessellationEvaluationShaderReadUniformBuffer,
62
63 TessellationEvaluationShaderReadSampledImageOrUniformTexelBuffer,
65
66 TessellationEvaluationShaderReadOther,
68
69 GeometryShaderReadUniformBuffer,
71
72 GeometryShaderReadSampledImageOrUniformTexelBuffer,
74
75 GeometryShaderReadOther,
77
78 FragmentShaderReadUniformBuffer,
80
81 FragmentShaderReadSampledImageOrUniformTexelBuffer,
83
84 FragmentShaderReadColorInputAttachment,
86
87 FragmentShaderReadDepthStencilInputAttachment,
89
90 FragmentShaderReadOther,
92
93 ColorAttachmentRead,
95
96 DepthStencilAttachmentRead,
98
99 ComputeShaderReadUniformBuffer,
101
102 ComputeShaderReadSampledImageOrUniformTexelBuffer,
104
105 ComputeShaderReadOther,
107
108 AnyShaderReadUniformBuffer,
110
111 AnyShaderReadUniformBufferOrVertexBuffer,
113
114 AnyShaderReadSampledImageOrUniformTexelBuffer,
116
117 AnyShaderReadOther,
119
120 TransferRead,
122
123 HostRead,
125
126 Present,
128
129 CommandBufferWriteNVX,
131
132 VertexShaderWrite,
134
135 TessellationControlShaderWrite,
137
138 TessellationEvaluationShaderWrite,
140
141 GeometryShaderWrite,
143
144 FragmentShaderWrite,
146
147 ColorAttachmentWrite,
149
150 DepthStencilAttachmentWrite,
152
153 DepthAttachmentWriteStencilReadOnly,
156
157 StencilAttachmentWriteDepthReadOnly,
160
161 ComputeShaderWrite,
163
164 AnyShaderWrite,
166
167 TransferWrite,
169
170 HostWrite,
172
173 ColorAttachmentReadWrite,
175
176 General,
178}
179
180impl Default for AccessType {
181 fn default() -> Self {
182 AccessType::Nothing
183 }
184}
185
186#[derive(Debug, Copy, Clone, PartialEq)]
191pub enum ImageLayout {
192 Optimal,
194
195 General,
197
198 GeneralAndPresentation,
202}
203
204impl Default for ImageLayout {
205 fn default() -> Self {
206 ImageLayout::Optimal
207 }
208}
209
210#[derive(Debug, Default, Clone)]
217pub struct GlobalBarrier<'a> {
218 pub previous_accesses: &'a [AccessType],
219 pub next_accesses: &'a [AccessType],
220}
221
222#[derive(Debug, Default, Clone)]
237pub struct BufferBarrier<'a> {
238 pub previous_accesses: &'a [AccessType],
239 pub next_accesses: &'a [AccessType],
240 pub src_queue_family_index: u32,
241 pub dst_queue_family_index: u32,
242 pub buffer: BufferType,
243 pub offset: usize,
244 pub size: usize,
245}
246
247#[derive(Debug, Default, Clone)]
274pub struct ImageBarrier<'a> {
275 pub previous_accesses: &'a [AccessType],
276 pub next_accesses: &'a [AccessType],
277 pub previous_layout: ImageLayout,
278 pub next_layout: ImageLayout,
279 pub discard_contents: bool,
280 pub src_queue_family_index: u32,
281 pub dst_queue_family_index: u32,
282 pub image: ImageType,
283 pub range: ImageSubresourceRangeType,
284}
285
286pub fn get_memory_barrier(
290 barrier: &GlobalBarrier,
291) -> (
292 ash::vk::PipelineStageFlags,
293 ash::vk::PipelineStageFlags,
294 ash::vk::MemoryBarrier,
295) {
296 let mut src_stages = ash::vk::PipelineStageFlags::empty();
297 let mut dst_stages = ash::vk::PipelineStageFlags::empty();
298
299 let mut memory_barrier = ash::vk::MemoryBarrier::default();
300
301 for previous_access in barrier.previous_accesses {
302 let previous_info = get_access_info(*previous_access);
303
304 src_stages |= previous_info.stage_mask;
305
306 if is_write_access(*previous_access) {
308 memory_barrier.src_access_mask |= previous_info.access_mask;
309 }
310 }
311
312 for next_access in barrier.next_accesses {
313 let next_info = get_access_info(*next_access);
314
315 dst_stages |= next_info.stage_mask;
316
317 if memory_barrier.src_access_mask != ash::vk::AccessFlags::empty() {
321 memory_barrier.dst_access_mask |= next_info.access_mask;
322 }
323 }
324
325 if src_stages == ash::vk::PipelineStageFlags::empty() {
327 src_stages = ash::vk::PipelineStageFlags::TOP_OF_PIPE;
328 }
329
330 if dst_stages == ash::vk::PipelineStageFlags::empty() {
331 dst_stages = ash::vk::PipelineStageFlags::BOTTOM_OF_PIPE;
332 }
333
334 (src_stages, dst_stages, memory_barrier)
335}
336
337pub fn get_buffer_memory_barrier(
341 barrier: &BufferBarrier,
342) -> (
343 ash::vk::PipelineStageFlags,
344 ash::vk::PipelineStageFlags,
345 ash::vk::BufferMemoryBarrier,
346) {
347 let mut src_stages = ash::vk::PipelineStageFlags::empty();
348 let mut dst_stages = ash::vk::PipelineStageFlags::empty();
349
350 let mut buffer_barrier = ash::vk::BufferMemoryBarrier {
351 src_queue_family_index: barrier.src_queue_family_index,
352 dst_queue_family_index: barrier.dst_queue_family_index,
353 buffer: barrier.buffer,
354 offset: barrier.offset as u64,
355 size: barrier.size as u64,
356 ..Default::default()
357 };
358
359 for previous_access in barrier.previous_accesses {
360 let previous_info = get_access_info(*previous_access);
361
362 src_stages |= previous_info.stage_mask;
363
364 if is_write_access(*previous_access) {
366 buffer_barrier.src_access_mask |= previous_info.access_mask;
367 }
368 }
369
370 for next_access in barrier.next_accesses {
371 let next_info = get_access_info(*next_access);
372
373 dst_stages |= next_info.stage_mask;
374
375 if buffer_barrier.src_access_mask != ash::vk::AccessFlags::empty() {
379 buffer_barrier.dst_access_mask |= next_info.access_mask;
380 }
381 }
382
383 if src_stages == ash::vk::PipelineStageFlags::empty() {
385 src_stages = ash::vk::PipelineStageFlags::TOP_OF_PIPE;
386 }
387
388 if dst_stages == ash::vk::PipelineStageFlags::empty() {
389 dst_stages = ash::vk::PipelineStageFlags::BOTTOM_OF_PIPE;
390 }
391
392 (src_stages, dst_stages, buffer_barrier)
393}
394
395pub fn get_image_memory_barrier(
399 barrier: &ImageBarrier,
400) -> (
401 ash::vk::PipelineStageFlags,
402 ash::vk::PipelineStageFlags,
403 ash::vk::ImageMemoryBarrier,
404) {
405 let mut src_stages = ash::vk::PipelineStageFlags::empty();
406 let mut dst_stages = ash::vk::PipelineStageFlags::empty();
407
408 let mut image_barrier = ash::vk::ImageMemoryBarrier {
409 src_queue_family_index: barrier.src_queue_family_index,
410 dst_queue_family_index: barrier.dst_queue_family_index,
411 image: barrier.image,
412 subresource_range: barrier.range,
413 ..Default::default()
414 };
415
416 for previous_access in barrier.previous_accesses {
417 let previous_info = get_access_info(*previous_access);
418
419 src_stages |= previous_info.stage_mask;
420
421 if is_write_access(*previous_access) {
423 image_barrier.src_access_mask |= previous_info.access_mask;
424 }
425
426 if barrier.discard_contents {
427 image_barrier.old_layout = ash::vk::ImageLayout::UNDEFINED;
428 } else {
429 let layout = match barrier.previous_layout {
430 ImageLayout::General => {
431 if *previous_access == AccessType::Present {
432 ash::vk::ImageLayout::PRESENT_SRC_KHR
433 } else {
434 ash::vk::ImageLayout::GENERAL
435 }
436 }
437 ImageLayout::Optimal => previous_info.image_layout,
438 ImageLayout::GeneralAndPresentation => {
439 unimplemented!()
440 }
442 };
443
444 image_barrier.old_layout = layout;
445 }
446 }
447
448 for next_access in barrier.next_accesses {
449 let next_info = get_access_info(*next_access);
450
451 dst_stages |= next_info.stage_mask;
452
453 if image_barrier.src_access_mask != ash::vk::AccessFlags::empty() {
457 image_barrier.dst_access_mask |= next_info.access_mask;
458 }
459
460 let layout = match barrier.next_layout {
461 ImageLayout::General => {
462 if *next_access == AccessType::Present {
463 ash::vk::ImageLayout::PRESENT_SRC_KHR
464 } else {
465 ash::vk::ImageLayout::GENERAL
466 }
467 }
468 ImageLayout::Optimal => next_info.image_layout,
469 ImageLayout::GeneralAndPresentation => {
470 unimplemented!()
471 }
473 };
474
475 image_barrier.new_layout = layout;
476 }
477
478 if src_stages == ash::vk::PipelineStageFlags::empty() {
480 src_stages = ash::vk::PipelineStageFlags::TOP_OF_PIPE;
481 }
482
483 if dst_stages == ash::vk::PipelineStageFlags::empty() {
484 dst_stages = ash::vk::PipelineStageFlags::BOTTOM_OF_PIPE;
485 }
486
487 (src_stages, dst_stages, image_barrier)
488}
489
490pub(crate) struct AccessInfo {
491 pub(crate) stage_mask: ash::vk::PipelineStageFlags,
492 pub(crate) access_mask: ash::vk::AccessFlags,
493 pub(crate) image_layout: ash::vk::ImageLayout,
494}
495
496pub(crate) fn get_access_info(access_type: AccessType) -> AccessInfo {
497 match access_type {
498 AccessType::Nothing => AccessInfo {
499 stage_mask: ash::vk::PipelineStageFlags::empty(),
500 access_mask: ash::vk::AccessFlags::empty(),
501 image_layout: ash::vk::ImageLayout::UNDEFINED,
502 },
503 AccessType::CommandBufferReadNVX => AccessInfo {
504 stage_mask: ash::vk::PipelineStageFlags::COMMAND_PROCESS_NVX,
505 access_mask: ash::vk::AccessFlags::COMMAND_PROCESS_READ_NVX,
506 image_layout: ash::vk::ImageLayout::UNDEFINED,
507 },
508 AccessType::IndirectBuffer => AccessInfo {
509 stage_mask: ash::vk::PipelineStageFlags::DRAW_INDIRECT,
510 access_mask: ash::vk::AccessFlags::INDIRECT_COMMAND_READ,
511 image_layout: ash::vk::ImageLayout::UNDEFINED,
512 },
513 AccessType::IndexBuffer => AccessInfo {
514 stage_mask: ash::vk::PipelineStageFlags::VERTEX_INPUT,
515 access_mask: ash::vk::AccessFlags::INDEX_READ,
516 image_layout: ash::vk::ImageLayout::UNDEFINED,
517 },
518 AccessType::VertexBuffer => AccessInfo {
519 stage_mask: ash::vk::PipelineStageFlags::VERTEX_INPUT,
520 access_mask: ash::vk::AccessFlags::VERTEX_ATTRIBUTE_READ,
521 image_layout: ash::vk::ImageLayout::UNDEFINED,
522 },
523 AccessType::VertexShaderReadUniformBuffer => AccessInfo {
524 stage_mask: ash::vk::PipelineStageFlags::VERTEX_SHADER,
525 access_mask: ash::vk::AccessFlags::SHADER_READ,
526 image_layout: ash::vk::ImageLayout::UNDEFINED,
527 },
528 AccessType::VertexShaderReadSampledImageOrUniformTexelBuffer => AccessInfo {
529 stage_mask: ash::vk::PipelineStageFlags::VERTEX_SHADER,
530 access_mask: ash::vk::AccessFlags::SHADER_READ,
531 image_layout: ash::vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
532 },
533 AccessType::VertexShaderReadOther => AccessInfo {
534 stage_mask: ash::vk::PipelineStageFlags::VERTEX_SHADER,
535 access_mask: ash::vk::AccessFlags::SHADER_READ,
536 image_layout: ash::vk::ImageLayout::GENERAL,
537 },
538 AccessType::TessellationControlShaderReadUniformBuffer => AccessInfo {
539 stage_mask: ash::vk::PipelineStageFlags::TESSELLATION_CONTROL_SHADER,
540 access_mask: ash::vk::AccessFlags::UNIFORM_READ,
541 image_layout: ash::vk::ImageLayout::UNDEFINED,
542 },
543 AccessType::TessellationControlShaderReadSampledImageOrUniformTexelBuffer => AccessInfo {
544 stage_mask: ash::vk::PipelineStageFlags::TESSELLATION_CONTROL_SHADER,
545 access_mask: ash::vk::AccessFlags::SHADER_READ,
546 image_layout: ash::vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
547 },
548 AccessType::TessellationControlShaderReadOther => AccessInfo {
549 stage_mask: ash::vk::PipelineStageFlags::TESSELLATION_CONTROL_SHADER,
550 access_mask: ash::vk::AccessFlags::SHADER_READ,
551 image_layout: ash::vk::ImageLayout::GENERAL,
552 },
553 AccessType::TessellationEvaluationShaderReadUniformBuffer => AccessInfo {
554 stage_mask: ash::vk::PipelineStageFlags::TESSELLATION_EVALUATION_SHADER,
555 access_mask: ash::vk::AccessFlags::UNIFORM_READ,
556 image_layout: ash::vk::ImageLayout::UNDEFINED,
557 },
558 AccessType::TessellationEvaluationShaderReadSampledImageOrUniformTexelBuffer => {
559 AccessInfo {
560 stage_mask: ash::vk::PipelineStageFlags::TESSELLATION_EVALUATION_SHADER,
561 access_mask: ash::vk::AccessFlags::SHADER_READ,
562 image_layout: ash::vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
563 }
564 }
565 AccessType::TessellationEvaluationShaderReadOther => AccessInfo {
566 stage_mask: ash::vk::PipelineStageFlags::TESSELLATION_EVALUATION_SHADER,
567 access_mask: ash::vk::AccessFlags::SHADER_READ,
568 image_layout: ash::vk::ImageLayout::GENERAL,
569 },
570 AccessType::GeometryShaderReadUniformBuffer => AccessInfo {
571 stage_mask: ash::vk::PipelineStageFlags::GEOMETRY_SHADER,
572 access_mask: ash::vk::AccessFlags::UNIFORM_READ,
573 image_layout: ash::vk::ImageLayout::UNDEFINED,
574 },
575 AccessType::GeometryShaderReadSampledImageOrUniformTexelBuffer => AccessInfo {
576 stage_mask: ash::vk::PipelineStageFlags::GEOMETRY_SHADER,
577 access_mask: ash::vk::AccessFlags::SHADER_READ,
578 image_layout: ash::vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
579 },
580 AccessType::GeometryShaderReadOther => AccessInfo {
581 stage_mask: ash::vk::PipelineStageFlags::GEOMETRY_SHADER,
582 access_mask: ash::vk::AccessFlags::SHADER_READ,
583 image_layout: ash::vk::ImageLayout::GENERAL,
584 },
585 AccessType::FragmentShaderReadUniformBuffer => AccessInfo {
586 stage_mask: ash::vk::PipelineStageFlags::FRAGMENT_SHADER,
587 access_mask: ash::vk::AccessFlags::UNIFORM_READ,
588 image_layout: ash::vk::ImageLayout::UNDEFINED,
589 },
590 AccessType::FragmentShaderReadSampledImageOrUniformTexelBuffer => AccessInfo {
591 stage_mask: ash::vk::PipelineStageFlags::FRAGMENT_SHADER,
592 access_mask: ash::vk::AccessFlags::SHADER_READ,
593 image_layout: ash::vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
594 },
595 AccessType::FragmentShaderReadColorInputAttachment => AccessInfo {
596 stage_mask: ash::vk::PipelineStageFlags::FRAGMENT_SHADER,
597 access_mask: ash::vk::AccessFlags::INPUT_ATTACHMENT_READ,
598 image_layout: ash::vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
599 },
600 AccessType::FragmentShaderReadDepthStencilInputAttachment => AccessInfo {
601 stage_mask: ash::vk::PipelineStageFlags::FRAGMENT_SHADER,
602 access_mask: ash::vk::AccessFlags::INPUT_ATTACHMENT_READ,
603 image_layout: ash::vk::ImageLayout::DEPTH_STENCIL_READ_ONLY_OPTIMAL,
604 },
605 AccessType::FragmentShaderReadOther => AccessInfo {
606 stage_mask: ash::vk::PipelineStageFlags::FRAGMENT_SHADER,
607 access_mask: ash::vk::AccessFlags::SHADER_READ,
608 image_layout: ash::vk::ImageLayout::GENERAL,
609 },
610 AccessType::ColorAttachmentRead => AccessInfo {
611 stage_mask: ash::vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
612 access_mask: ash::vk::AccessFlags::COLOR_ATTACHMENT_READ,
613 image_layout: ash::vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
614 },
615 AccessType::DepthStencilAttachmentRead => AccessInfo {
616 stage_mask: ash::vk::PipelineStageFlags::EARLY_FRAGMENT_TESTS
617 | ash::vk::PipelineStageFlags::LATE_FRAGMENT_TESTS,
618 access_mask: ash::vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ,
619 image_layout: ash::vk::ImageLayout::DEPTH_STENCIL_READ_ONLY_OPTIMAL,
620 },
621 AccessType::ComputeShaderReadUniformBuffer => AccessInfo {
622 stage_mask: ash::vk::PipelineStageFlags::COMPUTE_SHADER,
623 access_mask: ash::vk::AccessFlags::UNIFORM_READ,
624 image_layout: ash::vk::ImageLayout::UNDEFINED,
625 },
626 AccessType::ComputeShaderReadSampledImageOrUniformTexelBuffer => AccessInfo {
627 stage_mask: ash::vk::PipelineStageFlags::COMPUTE_SHADER,
628 access_mask: ash::vk::AccessFlags::SHADER_READ,
629 image_layout: ash::vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
630 },
631 AccessType::ComputeShaderReadOther => AccessInfo {
632 stage_mask: ash::vk::PipelineStageFlags::COMPUTE_SHADER,
633 access_mask: ash::vk::AccessFlags::SHADER_READ,
634 image_layout: ash::vk::ImageLayout::GENERAL,
635 },
636 AccessType::AnyShaderReadUniformBuffer => AccessInfo {
637 stage_mask: ash::vk::PipelineStageFlags::ALL_COMMANDS,
638 access_mask: ash::vk::AccessFlags::UNIFORM_READ,
639 image_layout: ash::vk::ImageLayout::UNDEFINED,
640 },
641 AccessType::AnyShaderReadUniformBufferOrVertexBuffer => AccessInfo {
642 stage_mask: ash::vk::PipelineStageFlags::ALL_COMMANDS,
643 access_mask: ash::vk::AccessFlags::UNIFORM_READ
644 | ash::vk::AccessFlags::VERTEX_ATTRIBUTE_READ,
645 image_layout: ash::vk::ImageLayout::UNDEFINED,
646 },
647 AccessType::AnyShaderReadSampledImageOrUniformTexelBuffer => AccessInfo {
648 stage_mask: ash::vk::PipelineStageFlags::ALL_COMMANDS,
649 access_mask: ash::vk::AccessFlags::SHADER_READ,
650 image_layout: ash::vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
651 },
652 AccessType::AnyShaderReadOther => AccessInfo {
653 stage_mask: ash::vk::PipelineStageFlags::ALL_COMMANDS,
654 access_mask: ash::vk::AccessFlags::SHADER_READ,
655 image_layout: ash::vk::ImageLayout::GENERAL,
656 },
657 AccessType::TransferRead => AccessInfo {
658 stage_mask: ash::vk::PipelineStageFlags::TRANSFER,
659 access_mask: ash::vk::AccessFlags::TRANSFER_READ,
660 image_layout: ash::vk::ImageLayout::TRANSFER_SRC_OPTIMAL,
661 },
662 AccessType::HostRead => AccessInfo {
663 stage_mask: ash::vk::PipelineStageFlags::HOST,
664 access_mask: ash::vk::AccessFlags::HOST_READ,
665 image_layout: ash::vk::ImageLayout::GENERAL,
666 },
667 AccessType::Present => AccessInfo {
668 stage_mask: ash::vk::PipelineStageFlags::empty(),
669 access_mask: ash::vk::AccessFlags::empty(),
670 image_layout: ash::vk::ImageLayout::PRESENT_SRC_KHR,
671 },
672 AccessType::CommandBufferWriteNVX => AccessInfo {
673 stage_mask: ash::vk::PipelineStageFlags::COMMAND_PROCESS_NVX,
674 access_mask: ash::vk::AccessFlags::COMMAND_PROCESS_WRITE_NVX,
675 image_layout: ash::vk::ImageLayout::UNDEFINED,
676 },
677 AccessType::VertexShaderWrite => AccessInfo {
678 stage_mask: ash::vk::PipelineStageFlags::VERTEX_SHADER,
679 access_mask: ash::vk::AccessFlags::SHADER_WRITE,
680 image_layout: ash::vk::ImageLayout::GENERAL,
681 },
682 AccessType::TessellationControlShaderWrite => AccessInfo {
683 stage_mask: ash::vk::PipelineStageFlags::TESSELLATION_CONTROL_SHADER,
684 access_mask: ash::vk::AccessFlags::SHADER_WRITE,
685 image_layout: ash::vk::ImageLayout::GENERAL,
686 },
687 AccessType::TessellationEvaluationShaderWrite => AccessInfo {
688 stage_mask: ash::vk::PipelineStageFlags::TESSELLATION_EVALUATION_SHADER,
689 access_mask: ash::vk::AccessFlags::SHADER_WRITE,
690 image_layout: ash::vk::ImageLayout::GENERAL,
691 },
692 AccessType::GeometryShaderWrite => AccessInfo {
693 stage_mask: ash::vk::PipelineStageFlags::GEOMETRY_SHADER,
694 access_mask: ash::vk::AccessFlags::SHADER_WRITE,
695 image_layout: ash::vk::ImageLayout::GENERAL,
696 },
697 AccessType::FragmentShaderWrite => AccessInfo {
698 stage_mask: ash::vk::PipelineStageFlags::FRAGMENT_SHADER,
699 access_mask: ash::vk::AccessFlags::SHADER_WRITE,
700 image_layout: ash::vk::ImageLayout::GENERAL,
701 },
702 AccessType::ColorAttachmentWrite => AccessInfo {
703 stage_mask: ash::vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
704 access_mask: ash::vk::AccessFlags::COLOR_ATTACHMENT_WRITE,
705 image_layout: ash::vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
706 },
707 AccessType::DepthStencilAttachmentWrite => AccessInfo {
708 stage_mask: ash::vk::PipelineStageFlags::EARLY_FRAGMENT_TESTS
709 | ash::vk::PipelineStageFlags::LATE_FRAGMENT_TESTS,
710 access_mask: ash::vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE,
711 image_layout: ash::vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
712 },
713 AccessType::DepthAttachmentWriteStencilReadOnly => AccessInfo {
714 stage_mask: ash::vk::PipelineStageFlags::EARLY_FRAGMENT_TESTS
715 | ash::vk::PipelineStageFlags::LATE_FRAGMENT_TESTS,
716 access_mask: ash::vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE
717 | ash::vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ,
718 image_layout: ash::vk::ImageLayout::DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL,
719 },
720 AccessType::StencilAttachmentWriteDepthReadOnly => AccessInfo {
721 stage_mask: ash::vk::PipelineStageFlags::EARLY_FRAGMENT_TESTS
722 | ash::vk::PipelineStageFlags::LATE_FRAGMENT_TESTS,
723 access_mask: ash::vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE
724 | ash::vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ,
725 image_layout: ash::vk::ImageLayout::DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL,
726 },
727 AccessType::ComputeShaderWrite => AccessInfo {
728 stage_mask: ash::vk::PipelineStageFlags::COMPUTE_SHADER,
729 access_mask: ash::vk::AccessFlags::SHADER_WRITE,
730 image_layout: ash::vk::ImageLayout::GENERAL,
731 },
732 AccessType::AnyShaderWrite => AccessInfo {
733 stage_mask: ash::vk::PipelineStageFlags::ALL_COMMANDS,
734 access_mask: ash::vk::AccessFlags::SHADER_WRITE,
735 image_layout: ash::vk::ImageLayout::GENERAL,
736 },
737 AccessType::TransferWrite => AccessInfo {
738 stage_mask: ash::vk::PipelineStageFlags::TRANSFER,
739 access_mask: ash::vk::AccessFlags::TRANSFER_WRITE,
740 image_layout: ash::vk::ImageLayout::TRANSFER_DST_OPTIMAL,
741 },
742 AccessType::HostWrite => AccessInfo {
743 stage_mask: ash::vk::PipelineStageFlags::HOST,
744 access_mask: ash::vk::AccessFlags::HOST_WRITE,
745 image_layout: ash::vk::ImageLayout::GENERAL,
746 },
747 AccessType::ColorAttachmentReadWrite => AccessInfo {
748 stage_mask: ash::vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
749 access_mask: ash::vk::AccessFlags::COLOR_ATTACHMENT_READ
750 | ash::vk::AccessFlags::COLOR_ATTACHMENT_WRITE,
751 image_layout: ash::vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
752 },
753 AccessType::General => AccessInfo {
754 stage_mask: ash::vk::PipelineStageFlags::ALL_COMMANDS,
755 access_mask: ash::vk::AccessFlags::MEMORY_READ | ash::vk::AccessFlags::MEMORY_WRITE,
756 image_layout: ash::vk::ImageLayout::GENERAL,
757 },
758 }
759}
760
761pub(crate) fn is_write_access(access_type: AccessType) -> bool {
762 match access_type {
763 AccessType::CommandBufferWriteNVX => true,
764 AccessType::VertexShaderWrite => true,
765 AccessType::TessellationControlShaderWrite => true,
766 AccessType::TessellationEvaluationShaderWrite => true,
767 AccessType::GeometryShaderWrite => true,
768 AccessType::FragmentShaderWrite => true,
769 AccessType::ColorAttachmentWrite => true,
770 AccessType::DepthStencilAttachmentWrite => true,
771 AccessType::DepthAttachmentWriteStencilReadOnly => true,
772 AccessType::StencilAttachmentWriteDepthReadOnly => true,
773 AccessType::ComputeShaderWrite => true,
774 AccessType::AnyShaderWrite => true,
775 AccessType::TransferWrite => true,
776 AccessType::HostWrite => true,
777 AccessType::ColorAttachmentReadWrite => true,
778 AccessType::General => true,
779 _ => false,
780 }
781}