Skip to content

Commit

Permalink
[GL] Fix issue with texture targets and multisampling
Browse files Browse the repository at this point in the history
If a texture with samples > 1 is to be created with a format
that does not support multisampling, the effective texture
target was wrong.
  • Loading branch information
hyazinthh committed Dec 13, 2023
1 parent 6ebc049 commit e3c771d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Aardvark.Rendering.GL/Resources/Textures/Texture.fs
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,14 @@ module TextureCreationExtensions =
if Vec.anyGreater size x.MaxTextureSize then
failf $"cannot create 2D texture with size {size} (maximum is {x.MaxTextureSize})"

let samples =
if samples <= 1 then 1
else Image.validateSampleCount x ImageTarget.Texture2DMultisample format samples

let target =
if samples = 1 then TextureTarget.Texture2D
else TextureTarget.Texture2DMultisample

let samples =
Image.validateSampleCount x (unbox target) format samples

let h = GL.GenTexture()
GL.Check "could not create texture"

Expand Down Expand Up @@ -533,13 +534,14 @@ module TextureCreationExtensions =
if count > x.MaxTextureArrayLayers then
failf $"cannot create 2D array texture with {count} layers (maximum is {x.MaxTextureArrayLayers})"

let samples =
if samples <= 1 then 1
else Image.validateSampleCount x ImageTarget.Texture2DMultisampleArray format samples

let target =
if samples = 1 then TextureTarget.Texture2DArray
else TextureTarget.Texture2DMultisampleArray

let samples =
Image.validateSampleCount x (unbox target) format samples

let h = GL.GenTexture()
GL.Check "could not create texture"

Expand Down

0 comments on commit e3c771d

Please sign in to comment.