示例#1
0
        private static void ConvertDepthFormat(GraphicsDevice graphicsDevice, PixelFormat requestedFormat, out RenderbufferStorage depthFormat, out RenderbufferStorage stencilFormat)
        {
            // Default: non-separate depth/stencil
            stencilFormat = 0;

            switch (requestedFormat)
            {
            case PixelFormat.D16_UNorm:
                depthFormat = RenderbufferStorage.DepthComponent16;
                break;

#if !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            case PixelFormat.D24_UNorm_S8_UInt:
                depthFormat = RenderbufferStorage.Depth24Stencil8;
                break;

            case PixelFormat.D32_Float:
                depthFormat = RenderbufferStorage.DepthComponent32;
                break;

            case PixelFormat.D32_Float_S8X24_UInt:
                depthFormat = RenderbufferStorage.Depth32fStencil8;
                break;
#else
            case PixelFormat.D24_UNorm_S8_UInt:
                if (graphicsDevice.HasPackedDepthStencilExtension)
                {
                    depthFormat = RenderbufferStorage.Depth24Stencil8;
                }
                else
                {
                    depthFormat   = graphicsDevice.HasDepth24 ? RenderbufferStorage.DepthComponent24 : RenderbufferStorage.DepthComponent16;
                    stencilFormat = RenderbufferStorage.StencilIndex8;
                }
                break;

            case PixelFormat.D32_Float:
                if (graphicsDevice.IsOpenGLES2)
                {
                    throw new NotSupportedException("Only 16 bits depth buffer or 24-8 bits depth-stencil buffer is supported on OpenGLES2");
                }
                depthFormat = RenderbufferInternalFormat.DepthComponent32f;
                break;

            case PixelFormat.D32_Float_S8X24_UInt:
                if (graphicsDevice.IsOpenGLES2)
                {
                    throw new NotSupportedException("Only 16 bits depth buffer or 24-8 bits depth-stencil buffer is supported on OpenGLES2");
                }
                // no need to check graphicsDevice.HasPackedDepthStencilExtension since supported 32F depth means OpenGL ES 3, so packing is available.
                depthFormat = RenderbufferInternalFormat.Depth32fStencil8;
                break;
#endif
            default:
                throw new NotImplementedException();
            }
        }
示例#2
0
        private static void ConvertDepthFormat(GraphicsDevice graphicsDevice, PixelFormat requestedFormat, out RenderbufferStorage depthFormat, out RenderbufferStorage stencilFormat)
        {
            // Default: non-separate depth/stencil
            stencilFormat = 0;

            switch (requestedFormat)
            {
                case PixelFormat.D16_UNorm:
                    depthFormat = RenderbufferStorage.DepthComponent16;
                    break;
#if !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                case PixelFormat.D24_UNorm_S8_UInt:
                    depthFormat = RenderbufferStorage.Depth24Stencil8;
                    break;
                case PixelFormat.D32_Float:
                    depthFormat = RenderbufferStorage.DepthComponent32;
                    break;
                case PixelFormat.D32_Float_S8X24_UInt:
                    depthFormat = RenderbufferStorage.Depth32fStencil8;
                    break;
#else
                case PixelFormat.D24_UNorm_S8_UInt:
                    if (graphicsDevice.HasPackedDepthStencilExtension)
                    {
                        depthFormat = RenderbufferStorage.Depth24Stencil8;
                    }
                    else
                    {
                        depthFormat = graphicsDevice.HasDepth24 ? RenderbufferStorage.DepthComponent24 : RenderbufferStorage.DepthComponent16;
                        stencilFormat = RenderbufferStorage.StencilIndex8;
                    }
                    break;
                case PixelFormat.D32_Float:
                    if (graphicsDevice.IsOpenGLES2)
                        throw new NotSupportedException("Only 16 bits depth buffer or 24-8 bits depth-stencil buffer is supported on OpenGLES2");
#if SILICONSTUDIO_PLATFORM_MONO_MOBILE
                    depthFormat = RenderbufferInternalFormat.DepthComponent32F;
#else
                    depthFormat = RenderbufferInternalFormat.DepthComponent32f;
#endif
                    break;
                case PixelFormat.D32_Float_S8X24_UInt:
                    if (graphicsDevice.IsOpenGLES2)
                        throw new NotSupportedException("Only 16 bits depth buffer or 24-8 bits depth-stencil buffer is supported on OpenGLES2");
                    // no need to check graphicsDevice.HasPackedDepthStencilExtension since supported 32F depth means OpenGL ES 3, so packing is available.
#if SILICONSTUDIO_PLATFORM_MONO_MOBILE
                    depthFormat = RenderbufferInternalFormat.Depth32FStencil8;
#else
                    depthFormat = RenderbufferInternalFormat.Depth32fStencil8;
#endif
                    break;
#endif
                default:
                    throw new NotImplementedException();
            }
        }
示例#3
0
        private static void ConvertDepthFormat(GraphicsDevice graphicsDevice, PixelFormat requestedFormat, out RenderbufferStorage depthFormat)
        {
            switch (requestedFormat)
            {
            case PixelFormat.D16_UNorm:
                depthFormat = RenderbufferStorage.DepthComponent16;
                break;

#if !STRIDE_GRAPHICS_API_OPENGLES
            case PixelFormat.D24_UNorm_S8_UInt:
                depthFormat = RenderbufferStorage.Depth24Stencil8;
                break;

            case PixelFormat.D32_Float:
                depthFormat = RenderbufferStorage.DepthComponent32;
                break;

            case PixelFormat.D32_Float_S8X24_UInt:
                depthFormat = RenderbufferStorage.Depth32fStencil8;
                break;
#else
            case PixelFormat.D24_UNorm_S8_UInt:
                depthFormat = RenderbufferStorage.Depth24Stencil8;
                break;

            case PixelFormat.D32_Float:
                depthFormat = RenderbufferInternalFormat.DepthComponent32f;
                break;

            case PixelFormat.D32_Float_S8X24_UInt:
                depthFormat = RenderbufferInternalFormat.Depth32fStencil8;
                break;
#endif
            default:
                throw new NotImplementedException();
            }
        }