コード例 #1
0
 public void SetData(long Key, long Size, IntPtr HostAddress)
 {
     if (Cache.TryGetValue(Key, out OGLStreamBuffer Buffer))
     {
         Buffer.SetData(Size, HostAddress);
     }
 }
コード例 #2
0
        public void SetData(long Key, long Size, IntPtr HostAddress)
        {
            if (!Cache.TryGetValue(Key, out OGLStreamBuffer Buffer))
            {
                throw new InvalidOperationException();
            }

            Buffer.SetData(Size, HostAddress);
        }
コード例 #3
0
        public bool TryGetImage(long Key, out ImageHandler CachedImage)
        {
            if (TextureCache.TryGetValue(Key, out CachedImage))
            {
                return(true);
            }

            CachedImage = null;

            return(false);
        }
コード例 #4
0
        public bool TryGetImage(long Key, out GalImage Image)
        {
            if (TextureCache.TryGetValue(Key, out ImageHandler CachedImage))
            {
                Image = CachedImage.Image;

                return(true);
            }

            Image = default(GalImage);

            return(false);
        }
コード例 #5
0
        public bool TryGetCachedTexture(long Key, long DataSize, out GalTexture Texture)
        {
            if (TextureCache.TryGetSize(Key, out long Size) && Size == DataSize)
            {
                if (TextureCache.TryGetValue(Key, out TCE CachedTexture))
                {
                    Texture = CachedTexture.Texture;

                    return(true);
                }
            }

            Texture = default(GalTexture);

            return(false);
        }
コード例 #6
0
        public void DrawElements(long IboKey, int First, int VertexBase, GalPrimitiveType PrimType)
        {
            if (!IboCache.TryGetValue(IboKey, out int IboHandle))
            {
                return;
            }

            PrimitiveType Mode = OGLEnumConverter.GetPrimitiveType(PrimType);

            GL.BindVertexArray(VaoHandle);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, IboHandle);

            First <<= IndexBuffer.ElemSizeLog2;

            if (VertexBase != 0)
            {
                IntPtr Indices = new IntPtr(First);

                GL.DrawElementsBaseVertex(Mode, IndexBuffer.Count, IndexBuffer.Type, Indices, VertexBase);
            }
            else
            {
                GL.DrawElements(Mode, IndexBuffer.Count, IndexBuffer.Type, First);
            }
        }
コード例 #7
0
        public void SetVertexArray(int Stride, long VboKey, GalVertexAttrib[] Attribs)
        {
            if (!VboCache.TryGetValue(VboKey, out int VboHandle))
            {
                return;
            }

            if (VaoHandle == 0)
            {
                VaoHandle = GL.GenVertexArray();
            }

            GL.BindVertexArray(VaoHandle);

            foreach (GalVertexAttrib Attrib in Attribs)
            {
                GL.EnableVertexAttribArray(Attrib.Index);

                GL.BindBuffer(BufferTarget.ArrayBuffer, VboHandle);

                bool Unsigned =
                    Attrib.Type == GalVertexAttribType.Unorm ||
                    Attrib.Type == GalVertexAttribType.Uint ||
                    Attrib.Type == GalVertexAttribType.Uscaled;

                bool Normalize =
                    Attrib.Type == GalVertexAttribType.Snorm ||
                    Attrib.Type == GalVertexAttribType.Unorm;

                VertexAttribPointerType Type = 0;

                if (Attrib.Type == GalVertexAttribType.Float)
                {
                    Type = VertexAttribPointerType.Float;
                }
                else
                {
                    Type = AttribTypes[Attrib.Size] + (Unsigned ? 1 : 0);
                }

                int Size   = AttribElements[Attrib.Size];
                int Offset = Attrib.Offset;

                if (Attrib.Type == GalVertexAttribType.Sint ||
                    Attrib.Type == GalVertexAttribType.Uint)
                {
                    IntPtr Pointer = new IntPtr(Offset);

                    VertexAttribIntegerType IType = (VertexAttribIntegerType)Type;

                    GL.VertexAttribIPointer(Attrib.Index, Size, IType, Stride, Pointer);
                }
                else
                {
                    GL.VertexAttribPointer(Attrib.Index, Size, Type, Normalize, Stride, Offset);
                }
            }
        }
コード例 #8
0
        public void DrawElements(long IboKey, int First, GalPrimitiveType PrimType)
        {
            if (!IboCache.TryGetValue(IboKey, out int IboHandle))
            {
                return;
            }

            PrimitiveType Mode = OGLEnumConverter.GetPrimitiveType(PrimType);

            GL.BindVertexArray(VaoHandle);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, IboHandle);

            GL.DrawElements(Mode, IndexBuffer.Count, IndexBuffer.Type, First);
        }
コード例 #9
0
ファイル: OGLRasterizer.cs プロジェクト: pinguicodes/Ryujinx
 public bool TryGetVbo(long VboKey, out int VboHandle)
 {
     return(VboCache.TryGetValue(VboKey, out VboHandle));
 }