Skip to content

Commit

Permalink
[OpenGL] Improve multisample texture extension handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
mellinoe committed Apr 6, 2018
1 parent 9259626 commit f0b94a3
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 17 deletions.
38 changes: 38 additions & 0 deletions src/Veldrid.OpenGLBindings/OpenGLNative.cs
Expand Up @@ -896,6 +896,42 @@ public static void glTextureStorage1D(uint texture, uint levels, SizedInternalFo
GLboolean fixedsamplelocations)
=> p_glTextureStorage3DMultisample(texture, samples, internalformat, width, height, depth, fixedsamplelocations);

private delegate void glTexStorage2DMultisample_t(
TextureTarget target,
uint samples,
SizedInternalFormat internalformat,
uint width,
uint height,
GLboolean fixedsamplelocations);
private static glTexStorage2DMultisample_t p_glTexStorage2DMultisample;
public static void glTexStorage2DMultisample(
TextureTarget target,
uint samples,
SizedInternalFormat internalformat,
uint width,
uint height,
GLboolean fixedsamplelocations)
=> p_glTexStorage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations);

private delegate void glTexStorage3DMultisample_t(
TextureTarget target,
uint samples,
SizedInternalFormat internalformat,
uint width,
uint height,
uint depth,
GLboolean fixedsamplelocations);
private static glTexStorage3DMultisample_t p_glTexStorage3DMultisample;
public static void glTexStorage3DMultisample(
TextureTarget target,
uint samples,
SizedInternalFormat internalformat,
uint width,
uint height,
uint depth,
GLboolean fixedsamplelocations)
=> p_glTexStorage3DMultisample(target, samples, internalformat, width, height, depth, fixedsamplelocations);

private delegate void glTextureView_t(
uint texture,
TextureTarget target,
Expand Down Expand Up @@ -1385,6 +1421,8 @@ public static void LoadAllFunctions(IntPtr glContext, Func<string, IntPtr> getPr
LoadFunction("glTextureStorage3D", out p_glTextureStorage3D);
LoadFunction("glTextureStorage2DMultisample", out p_glTextureStorage2DMultisample);
LoadFunction("glTextureStorage3DMultisample", out p_glTextureStorage3DMultisample);
LoadFunction("glTexStorage2DMultisample", out p_glTexStorage2DMultisample);
LoadFunction("glTexStorage3DMultisample", out p_glTexStorage3DMultisample);
LoadFunction("glTextureView", out p_glTextureView);
LoadFunction("glMapBuffer", out p_glMapBuffer);
LoadFunction("glMapNamedBuffer", out p_glMapNamedBuffer);
Expand Down
64 changes: 47 additions & 17 deletions src/Veldrid/OpenGL/OpenGLTexture.cs
Expand Up @@ -292,16 +292,31 @@ private void CreateGLResources()
Width,
Height,
false);
CheckLastError();
}
else
{
glTexImage2DMultiSample(
TextureTarget.Texture2DMultisample,
FormatHelpers.GetSampleCountUInt32(SampleCount),
GLInternalFormat,
Width,
Height,
false);
if (_gd.Extensions.TextureStorage)
{
glTexStorage2DMultisample(
TextureTarget.Texture2DMultisample,
FormatHelpers.GetSampleCountUInt32(SampleCount),
OpenGLFormats.VdToGLSizedInternalFormat(Format, isDepthTex),
Width,
Height,
false);
CheckLastError();
}
else
{
glTexImage2DMultiSample(
TextureTarget.Texture2DMultisample,
FormatHelpers.GetSampleCountUInt32(SampleCount),
GLInternalFormat,
Width,
Height,
false);
}
CheckLastError();
}
}
Expand All @@ -315,20 +330,35 @@ private void CreateGLResources()
OpenGLFormats.VdToGLSizedInternalFormat(Format, isDepthTex),
Width,
Height,
Depth,
ArrayLayers,
false);
CheckLastError();
}
else
{
glTexImage3DMultisample(
TextureTarget.Texture2DMultisampleArray,
FormatHelpers.GetSampleCountUInt32(SampleCount),
GLInternalFormat,
Width,
Height,
ArrayLayers,
false);
CheckLastError();
if (_gd.Extensions.TextureStorage)
{
glTexStorage3DMultisample(
TextureTarget.Texture2DMultisampleArray,
FormatHelpers.GetSampleCountUInt32(SampleCount),
OpenGLFormats.VdToGLSizedInternalFormat(Format, isDepthTex),
Width,
Height,
ArrayLayers,
false);
}
else
{
glTexImage3DMultisample(
TextureTarget.Texture2DMultisampleArray,
FormatHelpers.GetSampleCountUInt32(SampleCount),
GLInternalFormat,
Width,
Height,
ArrayLayers,
false);
CheckLastError();
}
}
}
else if (TextureTarget == TextureTarget.TextureCubeMap)
Expand Down

0 comments on commit f0b94a3

Please sign in to comment.