Skip to content

Commit df65ec9

Browse files
committed
Setup manual mipmap support for color attachments.
1 parent 17dd4fe commit df65ec9

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

Nu/Nu/Vulkan/Vulkan.Texture.fs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ module Texture =
466466
/// The image view.
467467
member this.ImageView = this.Texture.ImageView
468468

469+
/// The image views for each mip level.
470+
member this.SubViews = this.Texture.SubViews
471+
469472
/// The sampler.
470473
member this.Sampler = this.Sampler_
471474

@@ -534,13 +537,20 @@ module Texture =
534537

535538
// determine mip levels
536539
let mipLevels =
537-
match attachmentMode with
538-
| AttachmentNone ->
539-
match mipmapMode with
540-
| MipmapNone -> 1
541-
| MipmapManual mips -> mips
542-
| MipmapAuto ->
543-
540+
match mipmapMode with
541+
| MipmapNone -> 1
542+
| MipmapManual mips ->
543+
match attachmentMode with
544+
| AttachmentNone
545+
| AttachmentColor _ ->
546+
if mips = 1 then Log.infoOnce "Only 1 mip level specified for texture so will be treated as un-mipmapped."
547+
mips
548+
| AttachmentDepth _ ->
549+
Log.infoOnce "Mipmaps not supported for depth texture."; 1
550+
| MipmapAuto ->
551+
match attachmentMode with
552+
| AttachmentNone ->
553+
544554
// check if hardware supports mipmap generation; this is done here to prevent unused (i.e. blank) mip levels
545555
// TODO: DJL: check for VkFormatFeatureFlags.BlitSrc/Dst as well.
546556
let mutable formatProperties = Unchecked.defaultof<VkFormatProperties>
@@ -550,11 +560,8 @@ module Texture =
550560
// calculate mip levels
551561
if mipGenSupport then max metadata.TextureWidth metadata.TextureHeight |> Math.Log2 |> floor |> inc |> int
552562
else Log.infoOnce "Graphics device does not support mipmap generation for some used image format(s)."; 1
553-
554-
| AttachmentColor _
555-
| AttachmentDepth _ ->
556-
if not mipmapMode.IsMipmapNone then Log.warn "Mipmaps not supported for attachment texture."
557-
1
563+
564+
| _ -> Log.infoOnce "Automatic mipmap generation not supported for attachment texture."; 1
558565

559566
// create textures
560567
let length = if attachmentMode.IsParallel then Constants.Vulkan.MaxFramesInFlight else 1
@@ -916,6 +923,12 @@ module Texture =
916923
| EagerTexture eagerTexture -> eagerTexture.TextureInternal.ImageView
917924
| LazyTexture lazyTexture -> lazyTexture.TextureInternal.ImageView
918925

926+
member this.SubViews =
927+
match this with
928+
| EmptyTexture -> TextureInternal.empty.SubViews
929+
| EagerTexture eagerTexture -> eagerTexture.TextureInternal.SubViews
930+
| LazyTexture lazyTexture -> lazyTexture.TextureInternal.SubViews
931+
919932
member this.Sampler =
920933
match this with
921934
| EmptyTexture -> TextureInternal.empty.Sampler

0 commit comments

Comments
 (0)