/// <summary> /// Detect which internal formats are allowed as RTT Also detect what combinations of stencil and depth are allowed with this internal format. /// </summary> private void DetectFBOFormats() { // Try all formats, and report which ones work as target int fb = 0, tid = 0; All target = All.Texture2D; for ( int x = 0; x < (int) Media.PixelFormat.Count; x++ ) { LogManager.Instance.Write( "[GLES] [DEBUG] testing PixelFormat : {0}", (Media.PixelFormat) x ); this._props[ x ] = new FormatProperties(); this._props[ x ].Modes = new List<FormatProperties.Mode>(); this._props[ x ].IsValid = false; // Fetch GL format token All fmt = GLESPixelUtil.GetClosestGLInternalFormat( (Media.PixelFormat) x ); LogManager.Instance.Write( "[GLES] [DEBUG] fmt={0}", fmt ); if ( fmt == All.Zero && x != 0 ) { continue; } // No test for compressed formats if ( PixelUtil.IsCompressed( (Media.PixelFormat) x ) ) { continue; } // Create and attach framebuffer OpenGLOES.GenRenderbuffers( 1, ref fb ); GLESConfig.GlCheckError( this ); OpenGLOES.BindFramebuffer( All.FramebufferOes, fb ); GLESConfig.GlCheckError( this ); if ( fmt != All.Zero ) { // Create and attach texture OpenGL.GenTextures( 1, ref tid ); GLESConfig.GlCheckError( this ); OpenGL.BindTexture( target, tid ); GLESConfig.GlCheckError( this ); // Set some default parameters OpenGL.TexParameterx( target, All.TextureMinFilter, (int) All.LinearMipmapNearest ); GLESConfig.GlCheckError( this ); OpenGL.TexParameterx( target, All.TextureMagFilter, (int) All.Nearest ); GLESConfig.GlCheckError( this ); OpenGL.TexParameterx( target, All.TextureWrapS, (int) All.ClampToEdge ); GLESConfig.GlCheckError( this ); OpenGL.TexParameterx( target, All.TextureWrapT, (int) All.ClampToEdge ); GLESConfig.GlCheckError( this ); OpenGL.TexImage2D( target, 0, (int) fmt, ProbeSize, ProbeSize, 0, fmt, All.UnsignedByte, IntPtr.Zero ); GLESConfig.GlCheckError( this ); OpenGLOES.FramebufferTexture2D( All.FramebufferOes, All.ColorAttachment0Oes, target, tid, 0 ); GLESConfig.GlCheckError( this ); } // Check status All status = OpenGLOES.CheckFramebufferStatus( All.FramebufferOes ); GLESConfig.GlCheckError( this ); LogManager.Instance.Write( "[GLES] [DEBUG] status={0}", status ); // Ignore status in case of fmt==GL_NONE, because no implementation will accept // a buffer without *any* attachment. Buffers with only stencil and depth attachment // might still be supported, so we must continue probing. if ( fmt == 0 || status == All.FramebufferCompleteOes ) { this._props[ x ].IsValid = true; var str = new StringBuilder(); str.Append( "FBO " + PixelUtil.GetFormatName( (Media.PixelFormat) x ) + " depth/stencil support: " ); // For each depth/stencil formats for ( int depth = 0; depth < DepthFormats.Length; ++depth ) { if ( DepthFormats[ depth ] != All.Depth24Stencil8Oes ) { // General depth/stencil combination for ( int stencil = 0; stencil < StencilFormats.Length; ++stencil ) { if ( TryFormat( DepthFormats[ depth ], StencilFormats[ stencil ] ) ) { /// Add mode to allowed modes str.Append( "D" + DepthBits[ depth ] + "S" + StencilBits[ stencil ] + " " ); var mode = new FormatProperties.Mode(); mode.Depth = depth; mode.Stencil = stencil; this._props[ x ].Modes.Add( mode ); } } //end for stencil } //end if else { // Packed depth/stencil format if ( TryPacketFormat( DepthFormats[ depth ] ) ) { /// Add mode to allowed modes str.Append( "Packed-D" + DepthBits[ depth ] + "S8" + " " ); var mode = new FormatProperties.Mode(); mode.Depth = depth; mode.Stencil = 0; //unused this._props[ x ].Modes.Add( mode ); } } } //end for depth LogManager.Instance.Write( str.ToString() ); } //end if // Delete texture and framebuffer #if AXIOM_PLATFORM_IPHONE // The screen buffer is 1 on iPhone OpenGLOES.BindFramebuffer(All.FramebufferOes, 1); #else OpenGLOES.BindFramebuffer( All.FramebufferOes, 0 ); #endif GLESConfig.GlCheckError( this ); OpenGLOES.DeleteFramebuffers( 1, ref fb ); GLESConfig.GlCheckError( this ); if ( fmt != 0 ) { OpenGL.DeleteTextures( 1, ref tid ); } } //end for pixelformat count string fmtstring = string.Empty; for ( int x = 0; x < (int) Media.PixelFormat.Count; x++ ) { if ( this._props[ x ].IsValid ) { fmtstring += PixelUtil.GetFormatName( (Media.PixelFormat) x ); } } LogManager.Instance.Write( "[GLES] : Valid FBO targets " + fmtstring ); }
/// <summary> /// Detect which internal formats are allowed as RTT Also detect what combinations of stencil and depth are allowed with this internal format. /// </summary> private void DetectFBOFormats() { // Try all formats, and report which ones work as target int fb = 0, tid = 0; All target = All.Texture2D; for (int x = 0; x < (int)Media.PixelFormat.Count; x++) { LogManager.Instance.Write("[GLES] [DEBUG] testing PixelFormat : {0}", (Media.PixelFormat)x); this._props[x] = new FormatProperties(); this._props[x].Modes = new List <FormatProperties.Mode>(); this._props[x].IsValid = false; // Fetch GL format token All fmt = GLESPixelUtil.GetClosestGLInternalFormat((Media.PixelFormat)x); LogManager.Instance.Write("[GLES] [DEBUG] fmt={0}", fmt); if (fmt == All.Zero && x != 0) { continue; } // No test for compressed formats if (PixelUtil.IsCompressed((Media.PixelFormat)x)) { continue; } // Create and attach framebuffer OpenGLOES.GenRenderbuffers(1, ref fb); GLESConfig.GlCheckError(this); OpenGLOES.BindFramebuffer(All.FramebufferOes, fb); GLESConfig.GlCheckError(this); if (fmt != All.Zero) { // Create and attach texture OpenGL.GenTextures(1, ref tid); GLESConfig.GlCheckError(this); OpenGL.BindTexture(target, tid); GLESConfig.GlCheckError(this); // Set some default parameters OpenGL.TexParameterx(target, All.TextureMinFilter, (int)All.LinearMipmapNearest); GLESConfig.GlCheckError(this); OpenGL.TexParameterx(target, All.TextureMagFilter, (int)All.Nearest); GLESConfig.GlCheckError(this); OpenGL.TexParameterx(target, All.TextureWrapS, (int)All.ClampToEdge); GLESConfig.GlCheckError(this); OpenGL.TexParameterx(target, All.TextureWrapT, (int)All.ClampToEdge); GLESConfig.GlCheckError(this); OpenGL.TexImage2D(target, 0, (int)fmt, ProbeSize, ProbeSize, 0, fmt, All.UnsignedByte, IntPtr.Zero); GLESConfig.GlCheckError(this); OpenGLOES.FramebufferTexture2D(All.FramebufferOes, All.ColorAttachment0Oes, target, tid, 0); GLESConfig.GlCheckError(this); } // Check status All status = OpenGLOES.CheckFramebufferStatus(All.FramebufferOes); GLESConfig.GlCheckError(this); LogManager.Instance.Write("[GLES] [DEBUG] status={0}", status); // Ignore status in case of fmt==GL_NONE, because no implementation will accept // a buffer without *any* attachment. Buffers with only stencil and depth attachment // might still be supported, so we must continue probing. if (fmt == 0 || status == All.FramebufferCompleteOes) { this._props[x].IsValid = true; var str = new StringBuilder(); str.Append("FBO " + PixelUtil.GetFormatName((Media.PixelFormat)x) + " depth/stencil support: "); // For each depth/stencil formats for (int depth = 0; depth < DepthFormats.Length; ++depth) { if (DepthFormats[depth] != All.Depth24Stencil8Oes) { // General depth/stencil combination for (int stencil = 0; stencil < StencilFormats.Length; ++stencil) { if (TryFormat(DepthFormats[depth], StencilFormats[stencil])) { /// Add mode to allowed modes str.Append("D" + DepthBits[depth] + "S" + StencilBits[stencil] + " "); var mode = new FormatProperties.Mode(); mode.Depth = depth; mode.Stencil = stencil; this._props[x].Modes.Add(mode); } } //end for stencil } //end if else { // Packed depth/stencil format if (TryPacketFormat(DepthFormats[depth])) { /// Add mode to allowed modes str.Append("Packed-D" + DepthBits[depth] + "S8" + " "); var mode = new FormatProperties.Mode(); mode.Depth = depth; mode.Stencil = 0; //unused this._props[x].Modes.Add(mode); } } } //end for depth LogManager.Instance.Write(str.ToString()); } //end if // Delete texture and framebuffer #if AXIOM_PLATFORM_IPHONE // The screen buffer is 1 on iPhone OpenGLOES.BindFramebuffer(All.FramebufferOes, 1); #else OpenGLOES.BindFramebuffer(All.FramebufferOes, 0); #endif GLESConfig.GlCheckError(this); OpenGLOES.DeleteFramebuffers(1, ref fb); GLESConfig.GlCheckError(this); if (fmt != 0) { OpenGL.DeleteTextures(1, ref tid); } } //end for pixelformat count string fmtstring = string.Empty; for (int x = 0; x < (int)Media.PixelFormat.Count; x++) { if (this._props[x].IsValid) { fmtstring += PixelUtil.GetFormatName((Media.PixelFormat)x); } } LogManager.Instance.Write("[GLES] : Valid FBO targets " + fmtstring); }
/// <summary> /// Detect which internal formats are allowed as RTT Also detect what combinations of stencil and depth are allowed with this interal format. /// </summary> private void DetectFBOFormats() { //Try all formats, and report which ones work as target int fb = 0, tid = 0; GLenum target = GLenum.Texture2D; for (int x = 0; x < (int)PixelFormat.Count; x++) { this.props[x].Valid = false; //Fetch gl format token var fmt = GLES2PixelUtil.GetGLInternalFormat((PixelFormat)x); if ((fmt == GLenum.None) && (x != 0)) { continue; } //No test for compressed formats if (PixelUtil.IsCompressed((PixelFormat)x)) { continue; } //Create and attach framebuffer GL.GenFramebuffers(1, ref fb); GL.BindFramebuffer(GLenum.Framebuffer, fb); if (fmt != GLenum.None) { //Create and attach texture GL.GenTextures(1, ref tid); GL.BindTexture(target, tid); //Set some default parameters GL.TexParameter(target, GLenum.TextureMinFilter, (int)GLenum.Nearest); GL.TexParameter(target, GLenum.TextureMagFilter, (int)GLenum.Nearest); GL.TexParameter(target, GLenum.TextureWrapS, (int)GLenum.ClampToEdge); GL.TexParameter(target, GLenum.TextureWrapT, (int)GLenum.ClampToEdge); GL.TexImage2D(target, 0, (int)fmt, PROBE_SIZE, PROBE_SIZE, 0, fmt, GLES2PixelUtil.GetGLOriginDataType((PixelFormat)x), IntPtr.Zero); GL.FramebufferTexture2D(GLenum.Framebuffer, GLenum.ColorAttachment0, target, tid, 0); } //Check status GLenum status = GL.CheckFramebufferStatus(GLenum.Framebuffer); // Ignore status in case of fmt==GL_NONE, because no implementation will accept // a buffer without *any* attachment. Buffers with only stencil and depth attachment // might still be supported, so we must continue probing. if (fmt == GLenum.None || status == GLenum.FramebufferComplete) { this.props[x].Valid = true; var sb = new StringBuilder(); sb.Append("FBO " + PixelUtil.GetFormatName((PixelFormat)x) + " depth/stencil support: "); //For each depth/stencil formats for (int depth = 0; depth < DepthFormatCount; depth++) { if (depthFormats[depth] != GLenum.Depth24Stencil8Oes) { //General depth/stencil combination for (int stencil = 0; stencil < StencilFormatCount; stencil++) { if (this.TryFormat(depthFormats[depth], stencilFormats[stencil])) { //Add mode to allowed modes sb.Append("D" + depthBits[depth] + "S" + stencilBits[stencil] + " "); var mode = new FormatProperties.Mode(); mode.Depth = depth; mode.Stencil = stencil; this.props[x].Modes.Add(mode); } } } else { //Packed depth/stencil format if (this.TryPackedFormat(depthFormats[depth])) { //Add mode to allowed modes sb.Append("Packed-D" + depthBits[depth] + "S" + 8 + " "); var mode = new FormatProperties.Mode(); mode.Depth = depth; mode.Stencil = 0; //unuse this.props[x].Modes.Add(mode); } } } Core.LogManager.Instance.Write(sb.ToString()); } //Delte texture and framebuffer GL.BindFramebuffer(GLenum.Framebuffer, 0); GL.DeleteFramebuffers(1, ref fb); if (fmt != GLenum.None) { GL.DeleteTextures(1, ref tid); } } // Clear any errors GLES2Config.GlClearError(); string fmtstring = string.Empty; for (int x = 0; x < (int)PixelFormat.Count; x++) { if (this.props[x].Valid) { fmtstring += PixelUtil.GetFormatName((PixelFormat)x) + " "; } Core.LogManager.Instance.Write("[GLES2] : Valid FBO targets " + fmtstring); } }
/// <summary> /// Detect which internal formats are allowed as RTT Also detect what combinations of stencil and depth are allowed with this interal format. /// </summary> private void DetectFBOFormats() { //Try all formats, and report which ones work as target int fb = 0, tid = 0; GLenum target = GLenum.Texture2D; for ( int x = 0; x < (int) PixelFormat.Count; x++ ) { this.props[ x ].Valid = false; //Fetch gl format token var fmt = GLES2PixelUtil.GetGLInternalFormat( (PixelFormat) x ); if ( ( fmt == GLenum.None ) && ( x != 0 ) ) { continue; } //No test for compressed formats if ( PixelUtil.IsCompressed( (PixelFormat) x ) ) { continue; } //Create and attach framebuffer GL.GenFramebuffers( 1, ref fb ); GL.BindFramebuffer( GLenum.Framebuffer, fb ); if ( fmt != GLenum.None ) { //Create and attach texture GL.GenTextures( 1, ref tid ); GL.BindTexture( target, tid ); //Set some default parameters GL.TexParameter( target, GLenum.TextureMinFilter, (int) GLenum.Nearest ); GL.TexParameter( target, GLenum.TextureMagFilter, (int) GLenum.Nearest ); GL.TexParameter( target, GLenum.TextureWrapS, (int) GLenum.ClampToEdge ); GL.TexParameter( target, GLenum.TextureWrapT, (int) GLenum.ClampToEdge ); GL.TexImage2D( target, 0, (int) fmt, PROBE_SIZE, PROBE_SIZE, 0, fmt, GLES2PixelUtil.GetGLOriginDataType( (PixelFormat) x ), IntPtr.Zero ); GL.FramebufferTexture2D( GLenum.Framebuffer, GLenum.ColorAttachment0, target, tid, 0 ); } //Check status GLenum status = GL.CheckFramebufferStatus( GLenum.Framebuffer ); // Ignore status in case of fmt==GL_NONE, because no implementation will accept // a buffer without *any* attachment. Buffers with only stencil and depth attachment // might still be supported, so we must continue probing. if ( fmt == GLenum.None || status == GLenum.FramebufferComplete ) { this.props[ x ].Valid = true; var sb = new StringBuilder(); sb.Append( "FBO " + PixelUtil.GetFormatName( (PixelFormat) x ) + " depth/stencil support: " ); //For each depth/stencil formats for ( int depth = 0; depth < DepthFormatCount; depth++ ) { if ( depthFormats[ depth ] != GLenum.Depth24Stencil8Oes ) { //General depth/stencil combination for ( int stencil = 0; stencil < StencilFormatCount; stencil++ ) { if ( this.TryFormat( depthFormats[ depth ], stencilFormats[ stencil ] ) ) { //Add mode to allowed modes sb.Append( "D" + depthBits[ depth ] + "S" + stencilBits[ stencil ] + " " ); var mode = new FormatProperties.Mode(); mode.Depth = depth; mode.Stencil = stencil; this.props[ x ].Modes.Add( mode ); } } } else { //Packed depth/stencil format if ( this.TryPackedFormat( depthFormats[ depth ] ) ) { //Add mode to allowed modes sb.Append( "Packed-D" + depthBits[ depth ] + "S" + 8 + " " ); var mode = new FormatProperties.Mode(); mode.Depth = depth; mode.Stencil = 0; //unuse this.props[ x ].Modes.Add( mode ); } } } Core.LogManager.Instance.Write( sb.ToString() ); } //Delte texture and framebuffer GL.BindFramebuffer( GLenum.Framebuffer, 0 ); GL.DeleteFramebuffers( 1, ref fb ); if ( fmt != GLenum.None ) { GL.DeleteTextures( 1, ref tid ); } } // Clear any errors GLES2Config.GlClearError(); string fmtstring = string.Empty; for ( int x = 0; x < (int) PixelFormat.Count; x++ ) { if ( this.props[ x ].Valid ) { fmtstring += PixelUtil.GetFormatName( (PixelFormat) x ) + " "; } Core.LogManager.Instance.Write( "[GLES2] : Valid FBO targets " + fmtstring ); } }