Exemplo n.º 1
0
 public GLSLGraphicsPipelineCompilier(
     IGLShaderModuleEntrypoint shaderModule,
     IGLGraphicsPipelineEntrypoint program,
     IGLUniformBlockEntrypoint uniformBlocks,
     IGLErrorHandler errHandler,
     IGLUniformBlockNameParser parser
     )
 {
     mShaderModuleEntrypoint = shaderModule;
     mProgramEntrypoint      = program;
     mErrHandler             = errHandler;
     mUniformBlocks          = uniformBlocks;
     mParser = parser;
 }
Exemplo n.º 2
0
        internal static int LinkShaders(IGLGraphicsPipelineEntrypoint entrypoint, IGLErrorHandler errHandler, int[] shaders)
        {
            int retVal = entrypoint.CreateProgram();

            foreach (var shader in shaders)
            {
                entrypoint.AttachShaderToProgram(retVal, shader);
                //GL.AttachShader (retVal, shader);
            }
            entrypoint.CompileProgram(retVal);

            bool isCompiled = entrypoint.IsCompiled(retVal);
            //int linkStatus = 0;
            //GL.GetProgram(retVal,GetProgramParameterName.LinkStatus, out linkStatus);
            // return (linkStatus == (int)All.True)

            //int glinfoLogLength = 0;
            //GL.GetProgram(retVal, GetProgramParameterName.InfoLogLength, out glinfoLogLength);
            // return (glinfoLogLength > 1)

            bool hasMessages = entrypoint.HasCompilerMessages(retVal);

            if (hasMessages)
            {
                string buffer = entrypoint.GetCompilerMessages(retVal);

                // GL.GetProgramInfoLog(retVal);
                if (!isCompiled)
                {
                    errHandler.Trace("Shader Linking failed with the following errors:");
                }
                else
                {
                    errHandler.Trace("Shader Linking succeeded, with following warnings/messages:\n");
                }

                errHandler.Trace(buffer);
            }

            if (!isCompiled)
            {
                //		        #ifndef POSIX
                //		            assert(!"Shader failed linking, here's an assert to break you in the debugger.");
                //		        #endif
                entrypoint.DeleteProgram(retVal);
                retVal = 0;
            }

            return(retVal);
        }
Exemplo n.º 3
0
        public AndroidGLFramebufferHelper(IGLExtensionLookup lookup, IGLErrorHandler errHandler)
        {
            mErrHandler = errHandler;
            // eglGetProcAddress doesn't guarantied returning NULL if the entry point doesn't exist. The returned address *should* be the same for all invalid entry point
            var invalidFuncPtr = EGLGetProcAddress("InvalidFunctionName");

            if (lookup.HasExtension("GL_EXT_discard_framebuffer"))
            {
                var glDiscardFramebufferEXTPtr = EGLGetProcAddress("glDiscardFramebufferEXT");
                if (glDiscardFramebufferEXTPtr != invalidFuncPtr)
                {
                    this.GLInvalidateFramebuffer       = Marshal.GetDelegateForFunctionPointer <GLInvalidateFramebufferDelegate>(glDiscardFramebufferEXTPtr);
                    this.SupportsInvalidateFramebuffer = true;
                }
            }
            if (lookup.HasExtension("GL_EXT_multisampled_render_to_texture"))
            {
                var glRenderbufferStorageMultisampleEXTPtr  = EGLGetProcAddress("glRenderbufferStorageMultisampleEXT");
                var glFramebufferTexture2DMultisampleEXTPtr = EGLGetProcAddress("glFramebufferTexture2DMultisampleEXT");
                if (glRenderbufferStorageMultisampleEXTPtr != invalidFuncPtr && glFramebufferTexture2DMultisampleEXTPtr != invalidFuncPtr)
                {
                    this.GLRenderbufferStorageMultisample  = Marshal.GetDelegateForFunctionPointer <GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleEXTPtr);
                    this.GLFramebufferTexture2DMultisample = Marshal.GetDelegateForFunctionPointer <GLFramebufferTexture2DMultisampleDelegate>(glFramebufferTexture2DMultisampleEXTPtr);
                }
            }
            else if (lookup.HasExtension("GL_IMG_multisampled_render_to_texture"))
            {
                var glRenderbufferStorageMultisampleIMGPtr  = EGLGetProcAddress("glRenderbufferStorageMultisampleIMG");
                var glFramebufferTexture2DMultisampleIMGPtr = EGLGetProcAddress("glFramebufferTexture2DMultisampleIMG");
                if (glRenderbufferStorageMultisampleIMGPtr != invalidFuncPtr && glFramebufferTexture2DMultisampleIMGPtr != invalidFuncPtr)
                {
                    this.GLRenderbufferStorageMultisample  = Marshal.GetDelegateForFunctionPointer <GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleIMGPtr);
                    this.GLFramebufferTexture2DMultisample = Marshal.GetDelegateForFunctionPointer <GLFramebufferTexture2DMultisampleDelegate>(glFramebufferTexture2DMultisampleIMGPtr);
                }
            }
            else if (lookup.HasExtension("GL_NV_framebuffer_multisample"))
            {
                var glRenderbufferStorageMultisampleNVPtr = EGLGetProcAddress("glRenderbufferStorageMultisampleNV");
                var glBlitFramebufferNVPtr = EGLGetProcAddress("glBlitFramebufferNV");
                if (glRenderbufferStorageMultisampleNVPtr != invalidFuncPtr && glBlitFramebufferNVPtr != invalidFuncPtr)
                {
                    this.GLRenderbufferStorageMultisample = Marshal.GetDelegateForFunctionPointer <GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleNVPtr);
                    this.GLBlitFramebuffer  = Marshal.GetDelegateForFunctionPointer <GLBlitFramebufferDelegate>(glBlitFramebufferNVPtr);
                    this.AllReadFramebuffer = AllReadFramebufferNV;
                    this.AllDrawFramebuffer = AllDrawFramebufferNV;
                }
            }

            this.SupportsBlitFramebuffer = this.GLBlitFramebuffer != null;
        }
Exemplo n.º 4
0
        public GLDeviceMemory(MgMemoryAllocateInfo pAllocateInfo, IGLErrorHandler errHandler)
        {
            mErrHandler   = errHandler;
            mBufferType   = (GLMemoryBufferType)pAllocateInfo.MemoryTypeIndex;
            mIsHostCached = (mBufferType == GLMemoryBufferType.INDIRECT || mBufferType == GLMemoryBufferType.IMAGE);

            if (pAllocateInfo.AllocationSize > (ulong)int.MaxValue)
            {
                throw new ArgumentOutOfRangeException("pAllocateInfo.AllocationSize > int.MaxValue");
            }

            mBufferSize = (int)pAllocateInfo.AllocationSize;

            if (mBufferType != GLMemoryBufferType.IMAGE)
            {
                mBufferTarget = GetBufferTarget(mBufferType);
            }

            if (mIsHostCached || pAllocateInfo.MemoryTypeIndex == (uint)GLMemoryBufferType.IMAGE)
            {
                mHandle = Marshal.AllocHGlobal(mBufferSize);
            }
            else
            {
                if (mBufferTarget.HasValue)
                {
                    var buffers = new uint[1];
                    // ARB_direct_state_access
                    // Allows buffer objects to be initialised without binding them
                    GL.CreateBuffers(1, buffers);

                    mErrHandler.LogGLError("GL.CreateBuffers");
                    mBufferId = buffers[0];

                    // TODO : update flags based on buffer request
                    BufferStorageFlags flags = BufferStorageFlags.MapWriteBit | BufferStorageFlags.MapPersistentBit | BufferStorageFlags.MapCoherentBit;
                    GL.NamedBufferStorage(mBufferId, mBufferSize, IntPtr.Zero, flags);
                    mErrHandler.LogGLError("GL.NamedBufferStorage");

                    //					BufferAccessMask rangeFlags = BufferAccessMask.MapWriteBit | BufferAccessMask.MapPersistentBit | BufferAccessMask.MapCoherentBit;
                    //					Handle = GL.MapNamedBufferRange (buffers[0], (IntPtr)0, BufferSize, rangeFlags);
                }
            }
        }
Exemplo n.º 5
0
 public GLCmdStateRenderer(
     IGLCmdBlendEntrypoint blend,
     IGLCmdStencilEntrypoint stencil,
     IGLCmdRasterizationEntrypoint raster,
     IGLCmdDepthEntrypoint depth,
     IGLNextCmdShaderProgramCache cache,
     IGLCmdScissorsEntrypoint scissor,
     IGLCmdDrawEntrypoint render,
     IGLCmdClearEntrypoint clear,
     IGLErrorHandler errHandler
     )
 {
     mCache      = cache;
     mBlend      = blend;
     mStencil    = stencil;
     mRaster     = raster;
     mDepth      = depth;
     mScissor    = scissor;
     mRender     = render;
     mClear      = clear;
     mErrHandler = errHandler;
 }
Exemplo n.º 6
0
 public FullGLFramebufferHelperEXT(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
     this.SupportsBlitFramebuffer       = true;
     this.SupportsInvalidateFramebuffer = false;
 }
Exemplo n.º 7
0
 public Es20GLFramebufferHelperSelector(IGLFramebufferSupport capabilities, IGLErrorHandler errHandler)
 {
     mErrHandler   = errHandler;
     mCapabilities = capabilities;
 }
Exemplo n.º 8
0
 public FullGLShaderModuleEntrypoint(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
 }
Exemplo n.º 9
0
 public Es20GLFramebufferHelperSelector(IGLFramebufferSupport capabilities, IGLExtensionLookup lookup, IGLErrorHandler errHandler)
 {
     mCapabilities = capabilities;
     mLookup       = lookup;
     mErrHandler   = errHandler;
 }
Exemplo n.º 10
0
 public FullGLUniformBlockEntrypoint(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
 }
Exemplo n.º 11
0
 public Es20GLFramebufferHelper(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
     this.SupportsBlitFramebuffer = this.GLBlitFramebuffer != null;
 }
Exemplo n.º 12
0
 public FullGLDeviceMemoryEntrypoint(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
 }
Exemplo n.º 13
0
 public FullGLSamplerEntrypoint(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
 }
Exemplo n.º 14
0
 public FullGLDeviceImageViewEntrypoint(IGLErrorHandler errHandler, IGLImageFormatEntrypoint imgFormat)
 {
     mErrHandler = errHandler;
     mImgFormat  = imgFormat;
 }
Exemplo n.º 15
0
 public FullGLCmdScissorsEntrypoint(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
 }
Exemplo n.º 16
0
 public FullGLCmdRasterizationEntrypoint(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
 }
Exemplo n.º 17
0
 public FullGLImageDescriptorEntrypoint(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
 }
Exemplo n.º 18
0
 public FullGLCmdVBOEntrypoint(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
 }
Exemplo n.º 19
0
 public FullGLGraphicsPipelineEntrypoint(IGLErrorHandler errHandler)
 {
     mErrHandler = errHandler;
 }