コード例 #1
0
        internal static bool IsFormatSupported(OpenGLExtensions extensions, PixelFormat format, GraphicsBackend backend)
        {
            switch (format)
            {
            case PixelFormat.ETC2_R8_G8_B8_UNorm:
            case PixelFormat.ETC2_R8_G8_B8_A1_UNorm:
            case PixelFormat.ETC2_R8_G8_B8_A8_UNorm:
                return(extensions.GLESVersion(3, 0) || extensions.GLVersion(4, 3));

            case PixelFormat.BC1_Rgb_UNorm:
            case PixelFormat.BC1_Rgba_UNorm:
            case PixelFormat.BC2_UNorm:
            case PixelFormat.BC3_UNorm:
                return(extensions.IsExtensionSupported("GL_EXT_texture_compression_s3tc"));

            case PixelFormat.BC4_UNorm:
            case PixelFormat.BC4_SNorm:
            case PixelFormat.BC5_UNorm:
            case PixelFormat.BC5_SNorm:
                return(extensions.GLVersion(3, 0) || extensions.IsExtensionSupported("GL_ARB_texture_compression_rgtc"));

            case PixelFormat.BC7_UNorm:
                return(extensions.GLVersion(4, 2) || extensions.IsExtensionSupported("GL_ARB_texture_compression_bptc") ||
                       extensions.IsExtensionSupported("GL_EXT_texture_compression_bptc"));

            case PixelFormat.B8_G8_R8_A8_UNorm:
            case PixelFormat.B8_G8_R8_A8_UNorm_SRgb:
            case PixelFormat.R10_G10_B10_A2_UInt:
            case PixelFormat.R10_G10_B10_A2_UNorm:
                return(backend == GraphicsBackend.OpenGL);

            default:
                return(true);
            }
        }
コード例 #2
0
        public OpenGLTextureSamplerManager(OpenGLExtensions extensions)
        {
            _dsaAvailable = extensions.ARB_DirectStateAccess;
            int maxTextureUnits;

            glGetIntegerv(GetPName.MaxCombinedTextureImageUnits, &maxTextureUnits);
            CheckLastError();
            _maxTextureUnits     = Math.Max(maxTextureUnits, 8); // OpenGL spec indicates that implementations must support at least 8.
            _textureUnitTextures = new OpenGLTextureView[_maxTextureUnits];
            _textureUnitSamplers = new BoundSamplerStateInfo[_maxTextureUnits];
        }
コード例 #3
0
        public OpenGLGraphicsDevice(
            OpenGLPlatformInfo platformInfo,
            uint width,
            uint height,
            bool debugDevice)
        {
            _glContext     = platformInfo.OpenGLContextHandle;
            _makeCurrent   = platformInfo.MakeCurrent;
            _deleteContext = platformInfo.DeleteContext;
            _swapBuffers   = platformInfo.SwapBuffers;
            LoadAllFunctions(_glContext, platformInfo.GetProcAddress);

            ResourceFactory = new OpenGLResourceFactory(this);

            glGenVertexArrays(1, out _vao);
            CheckLastError();

            glBindVertexArray(_vao);
            CheckLastError();

            _swapchainFramebuffer = new OpenGLSwapchainFramebuffer(width, height);

            if (debugDevice)
            {
                EnableDebugCallback();
            }

            // Set miscellaneous initial states.
            glEnable(EnableCap.TextureCubeMapSeamless);
            CheckLastError();

            int extensionCount;

            glGetIntegerv(GetPName.NumExtensions, &extensionCount);
            CheckLastError();

            HashSet <string> extensions = new HashSet <string>();

            for (uint i = 0; i < extensionCount; i++)
            {
                byte *extensionNamePtr = glGetStringi(StringNameIndexed.Extensions, i);
                CheckLastError();
                if (extensionNamePtr != null)
                {
                    string extensionName = Util.GetString(extensionNamePtr);
                    extensions.Add(extensionName);
                }
            }

            _extensions      = new OpenGLExtensions(extensions);
            _commandExecutor = new OpenGLCommandExecutor(_extensions);

            PostContextCreated();
        }
コード例 #4
0
        internal static bool IsFormatSupported(OpenGLExtensions extensions, PixelFormat format)
        {
            switch (format)
            {
            case PixelFormat.ETC2_R8_G8_B8_UNorm:
            case PixelFormat.ETC2_R8_G8_B8_A1_UNorm:
            case PixelFormat.ETC2_R8_G8_B8_A8_UNorm:
                return(extensions.GLESVersion(3, 0) || extensions.GLVersion(4, 3));

            case PixelFormat.BC1_Rgb_UNorm:
            case PixelFormat.BC1_Rgba_UNorm:
            case PixelFormat.BC2_UNorm:
            case PixelFormat.BC3_UNorm:
                return(extensions.IsExtensionSupported("GL_EXT_texture_compression_s3tc"));

            default:
                return(true);
            }
        }
コード例 #5
0
 public OpenGLCommandExecutor(OpenGLExtensions extensions, StagingMemoryPool stagingMemoryPool)
 {
     _extensions            = extensions;
     _textureSamplerManager = new OpenGLTextureSamplerManager(extensions);
     _stagingMemoryPool     = stagingMemoryPool;
 }
コード例 #6
0
 public OpenGLCommandExecutor(OpenGLExtensions extensions)
 {
     _extensions            = extensions;
     _textureSamplerManager = new OpenGLTextureSamplerManager(extensions);
 }