Browse Source

GL: implement ANGLE_stencil_texturing and WEBGL_stencil_texturing.

pull/638/head
Vladimír Vondruš 2 years ago
parent
commit
59f3747cb9
  1. 4
      doc/opengl-support.dox
  2. 10
      src/Magnum/GL/AbstractTexture.cpp
  3. 2
      src/Magnum/GL/AbstractTexture.h
  4. 9
      src/Magnum/GL/CubeMapTexture.h
  5. 2
      src/Magnum/GL/GL.h
  6. 2
      src/Magnum/GL/Sampler.cpp
  7. 13
      src/Magnum/GL/Sampler.h
  8. 13
      src/Magnum/GL/Test/CubeMapTextureGLTest.cpp
  9. 13
      src/Magnum/GL/Test/TextureArrayGLTest.cpp
  10. 22
      src/Magnum/GL/Test/TextureGLTest.cpp
  11. 9
      src/Magnum/GL/Texture.h
  12. 9
      src/Magnum/GL/TextureArray.h

4
doc/opengl-support.dox

@ -454,7 +454,7 @@ Extension | Status
@m_class{m-doc-external} [ANGLE_base_vertex_base_instance](https://chromium.googlesource.com/angle/angle/+/master/extensions/ANGLE_base_vertex_base_instance.txt) (unlisted) | done
@m_class{m-doc-external} [ANGLE_provoking_vertex](https://chromium.googlesource.com/angle/angle/+/main/extensions/ANGLE_provoking_vertex.txt) (unlisted) | done
@m_class{m-doc-external} [ANGLE_polygon_mode](https://chromium.googlesource.com/angle/angle/+/HEAD/extensions/ANGLE_polygon_mode.txt) (unlisted) | done
@m_class{m-doc-external} [ANGLE_stencil_texturing](https://chromium.googlesource.com/angle/angle/+/HEAD/extensions/ANGLE_stencil_texturing.txt) (unlisted) | |
@m_class{m-doc-external} [ANGLE_stencil_texturing](https://chromium.googlesource.com/angle/angle/+/HEAD/extensions/ANGLE_stencil_texturing.txt) (unlisted) | done
@gl_extension{APPLE,texture_format_BGRA8888} | done
@gl_extension{APPLE,clip_distance} | done
@gl_extension{ARM,shader_framebuffer_fetch} | missing renderer setup and limit query
@ -597,7 +597,7 @@ Extension | Status
@webgl_extension{WEBGL,provoking_vertex} | missing support in Emscripten
@webgl_extension{WEBGL,polygon_mode} | missing support in Emscripten
@webgl_extension{WEBGL,blend_func_extended} | |
@webgl_extension{WEBGL,stencil_texturing} | |
@webgl_extension{WEBGL,stencil_texturing} | done
@section opengl-unsupported Unsupported OpenGL features

10
src/Magnum/GL/AbstractTexture.cpp

@ -498,9 +498,15 @@ void AbstractTexture::setCompareFunction(const SamplerCompareFunction function)
}
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::setDepthStencilMode(const SamplerDepthStencilMode mode) {
Context::current().state().texture.parameteriImplementation(*this, GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode));
Context::current().state().texture.parameteriImplementation(*this,
#ifndef MAGNUM_TARGET_WEBGL
GL_DEPTH_STENCIL_TEXTURE_MODE
#else
GL_DEPTH_STENCIL_TEXTURE_MODE_ANGLE
#endif
, GLenum(mode));
}
#endif

2
src/Magnum/GL/AbstractTexture.h

@ -488,7 +488,7 @@ class MAGNUM_GL_EXPORT AbstractTexture: public AbstractObject {
void setCompareMode(SamplerCompareMode mode);
void setCompareFunction(SamplerCompareFunction function);
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES2
void setDepthStencilMode(SamplerDepthStencilMode mode);
#endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))

9
src/Magnum/GL/CubeMapTexture.h

@ -541,16 +541,17 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
}
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES2
/**
* @brief @copybrief Texture::setDepthStencilMode()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setDepthStencilMode() for more information.
* @requires_gl43 Extension @gl_extension{ARB,stencil_texturing}
* @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0
* and older.
* @requires_gles Stencil texturing is not available in WebGL.
* @requires_gles31 Extension @m_class{m-doc-external} [ANGLE_stencil_texturing](https://chromium.googlesource.com/angle/angle/+/HEAD/extensions/ANGLE_stencil_texturing.txt)
* in OpenGL ES 3.0.
* @requires_webgl_extension WebGL 2.0 and extension
* @webgl_extension{WEBGL,stencil_texturing}
*/
CubeMapTexture& setDepthStencilMode(SamplerDepthStencilMode mode) {
AbstractTexture::setDepthStencilMode(mode);

2
src/Magnum/GL/GL.h

@ -150,7 +150,7 @@ enum class SamplerCompareMode: GLenum;
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
enum class SamplerCompareFunction: GLenum;
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES2
enum class SamplerDepthStencilMode: GLenum;
#endif

2
src/Magnum/GL/Sampler.cpp

@ -219,7 +219,7 @@ Debug& operator<<(Debug& debug, const SamplerCompareFunction value) {
}
#endif
#ifndef MAGNUM_TARGET_GLES
#ifndef MAGNUM_TARGET_GLES2
Debug& operator<<(Debug& debug, const SamplerDepthStencilMode value) {
debug << "GL::SamplerDepthStencilMode" << Debug::nospace;

13
src/Magnum/GL/Sampler.h

@ -303,23 +303,28 @@ enum class SamplerCompareFunction: GLenum {
MAGNUM_GL_EXPORT Debug& operator<<(Debug& debug, SamplerCompareFunction value);
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES2
/**
@brief Texture sampler depth/stencil mode
@see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()"
@m_enum_values_as_keywords
@requires_gl43 Extension @gl_extension{ARB,stencil_texturing}
@requires_gles31 Stencil texturing is not available in OpenGL ES 3.0
and older.
@requires_gles Stencil texturing is not available in WebGL.
@requires_gles31 Extension @m_class{m-doc-external} [ANGLE_stencil_texturing](https://chromium.googlesource.com/angle/angle/+/HEAD/extensions/ANGLE_stencil_texturing.txt)
in OpenGL ES 3.0.
@requires_webgl_extension WebGL 2.0 and extension
@webgl_extension{WEBGL,stencil_texturing}
*/
enum class SamplerDepthStencilMode: GLenum {
/** Sample depth component */
DepthComponent = GL_DEPTH_COMPONENT,
/** Sample stencil index (as unsigned integer texture) */
#ifndef MAGNUM_TARGET_WEBGL
StencilIndex = GL_STENCIL_INDEX
#else
StencilIndex = GL_STENCIL_INDEX_ANGLE
#endif
};
/** @debugoperatorenum{SamplerDepthStencilMode} */

13
src/Magnum/GL/Test/CubeMapTextureGLTest.cpp

@ -82,6 +82,8 @@ struct CubeMapTextureGLTest: OpenGLTester {
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void samplingBorderInteger();
#endif
#ifndef MAGNUM_TARGET_GLES2
void samplingDepthStencilMode();
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
@ -351,6 +353,8 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
&CubeMapTextureGLTest::samplingBorderInteger,
#endif
#ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::samplingDepthStencilMode,
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
@ -688,14 +692,19 @@ void CubeMapTextureGLTest::samplingBorderInteger() {
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
#ifndef MAGNUM_TARGET_GLES2
void CubeMapTextureGLTest::samplingDepthStencilMode() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::stencil_texturing>())
CORRADE_SKIP(Extensions::ARB::stencil_texturing::string() << "is not supported.");
#elif !defined(MAGNUM_TARGET_WEBGL)
if(!Context::current().isVersionSupported(Version::GLES310) && !Context::current().isExtensionSupported<Extensions::ANGLE::stencil_texturing>())
CORRADE_SKIP("Neither OpenGL ES 3.1 nor" << Extensions::ANGLE::stencil_texturing::string() << "is supported.");
#else
if(!Context::current().isVersionSupported(Version::GLES310))
CORRADE_SKIP("OpenGL ES 3.1 not supported.");
if(!Context::current().isExtensionSupported<Extensions::WEBGL::stencil_texturing>())
CORRADE_SKIP(Extensions::WEBGL::stencil_texturing::string() << "is not supported.");
#endif
CubeMapTexture texture;

13
src/Magnum/GL/Test/TextureArrayGLTest.cpp

@ -112,9 +112,7 @@ struct TextureArrayGLTest: OpenGLTester {
#ifndef MAGNUM_TARGET_GLES
void samplingDepthStencilMode1D();
#endif
#ifndef MAGNUM_TARGET_WEBGL
void samplingDepthStencilMode2D();
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
void samplingBorder2D();
#endif
@ -356,9 +354,7 @@ TextureArrayGLTest::TextureArrayGLTest() {
#ifndef MAGNUM_TARGET_GLES
&TextureArrayGLTest::samplingDepthStencilMode1D,
#endif
#ifndef MAGNUM_TARGET_WEBGL
&TextureArrayGLTest::samplingDepthStencilMode2D,
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
&TextureArrayGLTest::samplingBorder2D,
#endif
@ -879,16 +875,18 @@ void TextureArrayGLTest::samplingBorderInteger2D() {
}
#endif
#ifndef MAGNUM_TARGET_WEBGL
void TextureArrayGLTest::samplingDepthStencilMode2D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::EXT::texture_array>())
CORRADE_SKIP(Extensions::EXT::texture_array::string() << "is not supported.");
if(!Context::current().isExtensionSupported<Extensions::ARB::stencil_texturing>())
CORRADE_SKIP(Extensions::ARB::stencil_texturing::string() << "is not supported.");
#elif !defined(MAGNUM_TARGET_WEBGL)
if(!Context::current().isVersionSupported(Version::GLES310) && !Context::current().isExtensionSupported<Extensions::ANGLE::stencil_texturing>())
CORRADE_SKIP("Neither OpenGL ES 3.1 nor" << Extensions::ANGLE::stencil_texturing::string() << "is supported.");
#else
if(!Context::current().isVersionSupported(Version::GLES310))
CORRADE_SKIP("OpenGL ES 3.1 is not supported.");
if(!Context::current().isExtensionSupported<Extensions::WEBGL::stencil_texturing>())
CORRADE_SKIP(Extensions::WEBGL::stencil_texturing::string() << "is not supported.");
#endif
Texture2DArray texture;
@ -896,7 +894,6 @@ void TextureArrayGLTest::samplingDepthStencilMode2D() {
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
void TextureArrayGLTest::samplingBorder2D() {

22
src/Magnum/GL/Test/TextureGLTest.cpp

@ -140,7 +140,7 @@ struct TextureGLTest: OpenGLTester {
#ifndef MAGNUM_TARGET_GLES
void samplingDepthStencilMode1D();
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES2
void samplingDepthStencilMode2D();
void samplingDepthStencilMode3D();
#endif
@ -542,7 +542,7 @@ TextureGLTest::TextureGLTest() {
#ifndef MAGNUM_TARGET_GLES
&TextureGLTest::samplingDepthStencilMode1D,
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES2
&TextureGLTest::samplingDepthStencilMode2D,
&TextureGLTest::samplingDepthStencilMode3D,
#endif
@ -1197,14 +1197,19 @@ void TextureGLTest::samplingBorderInteger2D() {
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
#ifndef MAGNUM_TARGET_GLES2
void TextureGLTest::samplingDepthStencilMode2D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::stencil_texturing>())
CORRADE_SKIP(Extensions::ARB::stencil_texturing::string() << "is not supported.");
#elif !defined(MAGNUM_TARGET_WEBGL)
if(!Context::current().isVersionSupported(Version::GLES310) && !Context::current().isExtensionSupported<Extensions::ANGLE::stencil_texturing>())
CORRADE_SKIP("Neither OpenGL ES 3.1 nor" << Extensions::ANGLE::stencil_texturing::string() << "is supported.");
#else
if(!Context::current().isVersionSupported(Version::GLES310))
CORRADE_SKIP("OpenGL ES 3.1 is not supported.");
if(!Context::current().isExtensionSupported<Extensions::WEBGL::stencil_texturing>())
CORRADE_SKIP(Extensions::WEBGL::stencil_texturing::string() << "is not supported.");
#endif
Texture2D texture;
@ -1326,14 +1331,19 @@ void TextureGLTest::samplingBorderInteger3D() {
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
#ifndef MAGNUM_TARGET_GLES2
void TextureGLTest::samplingDepthStencilMode3D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::stencil_texturing>())
CORRADE_SKIP(Extensions::ARB::stencil_texturing::string() << "is not supported.");
#elif !defined(MAGNUM_TARGET_WEBGL)
if(!Context::current().isVersionSupported(Version::GLES310) && !Context::current().isExtensionSupported<Extensions::ANGLE::stencil_texturing>())
CORRADE_SKIP("Neither OpenGL ES 3.1 nor" << Extensions::ANGLE::stencil_texturing::string() << "is supported.");
#else
if(!Context::current().isVersionSupported(Version::GLES310))
CORRADE_SKIP("OpenGL ES 3.1 is not supported.");
if(!Context::current().isExtensionSupported<Extensions::WEBGL::stencil_texturing>())
CORRADE_SKIP(Extensions::WEBGL::stencil_texturing::string() << "is not supported.");
#endif
Texture3D texture;

9
src/Magnum/GL/Texture.h

@ -771,7 +771,7 @@ Texture: public AbstractTexture {
}
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES2
/**
* @brief Set depth/stencil texture mode
* @return Reference to self (for method chaining)
@ -786,9 +786,10 @@ Texture: public AbstractTexture {
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{DEPTH_STENCIL_TEXTURE_MODE}
* @requires_gl43 Extension @gl_extension{ARB,stencil_texturing}
* @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0
* and older.
* @requires_gles Stencil texturing is not available in WebGL.
* @requires_gles31 Extension @m_class{m-doc-external} [ANGLE_stencil_texturing](https://chromium.googlesource.com/angle/angle/+/HEAD/extensions/ANGLE_stencil_texturing.txt)
* in OpenGL ES 3.0.
* @requires_webgl_extension WebGL 2.0 and extension
* @webgl_extension{WEBGL,stencil_texturing}
*/
Texture<dimensions>& setDepthStencilMode(SamplerDepthStencilMode mode) {
AbstractTexture::setDepthStencilMode(mode);

9
src/Magnum/GL/TextureArray.h

@ -558,22 +558,21 @@ TextureArray: public AbstractTexture {
return *this;
}
#ifndef MAGNUM_TARGET_WEBGL
/**
* @brief @copybrief Texture::setDepthStencilMode()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setDepthStencilMode() for more information.
* @requires_gl43 Extension @gl_extension{ARB,stencil_texturing}
* @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0
* and older.
* @requires_gles Stencil texturing is not available in WebGL.
* @requires_gles31 Extension @m_class{m-doc-external} [ANGLE_stencil_texturing](https://chromium.googlesource.com/angle/angle/+/HEAD/extensions/ANGLE_stencil_texturing.txt)
* in OpenGL ES 3.0.
* @requires_webgl_extension WebGL 2.0 and extension
* @webgl_extension{WEBGL,stencil_texturing}
*/
TextureArray<dimensions>& setDepthStencilMode(SamplerDepthStencilMode mode) {
AbstractTexture::setDepthStencilMode(mode);
return *this;
}
#endif
/**
* @brief @copybrief Texture::setStorage()

Loading…
Cancel
Save