Exemplo n.º 1
0
        /// <summary>
        /// Releases reference to all allocated D3D surfaces
        /// </summary>
        private void FreeSurfaces()
        {
            lock (m_instanceLock)
            {
                if (m_privateSurface != null)
                {
                    Marshal.ReleaseComObject(m_privateSurface);
                    m_privateSurface = null;
                }

                if (m_privateTexture != null)
                {
                    Marshal.ReleaseComObject(m_privateTexture);
                    m_privateTexture = null;
                }

                if (DxSurfaces != null)
                {
                    foreach (var ptr in DxSurfaces)
                    {
                        if (ptr != IntPtr.Zero)
                        {
                            /* Release COM reference */
                            Marshal.Release(ptr);
                        }
                    }
                }

                /* Make sure we uninitialize the pointer array
                 * so the rest of our code knows it is invalid */
                DxSurfaces = null;
            }
        }
Exemplo n.º 2
0
        internal static unsafe void DirectBlit(RenderBuffer buffer, ref Texture2D texture2d)
        {
            //TODO : Test if d3dt can be cached
            IDirect3DTexture9 d3dt = GetIUnknownObject <IDirect3DTexture9>(texture2d);
            //XE.Performance.Log("IDirect3DTexture9 Is "+(d3dt!=null ? d3dt.ToString():"null"));

            //D3DSURFACE_DESC desc=new D3DSURFACE_DESC();
            //Marshal.ThrowExceptionForHR(d3dt.GetLevelDesc(0, out desc));
            //XE.Performance.Log("LevelDesc Format "+desc.Format.ToString());
            //XE.Performance.Log("LevelDesc MultiSampleQuality "+desc.MultiSampleQuality.ToString());
            //XE.Performance.Log("LevelDesc MultiSampleType "+desc.MultiSampleType.ToString());
            //XE.Performance.Log("LevelDesc Pool "+desc.Pool.ToString());
            //XE.Performance.Log("LevelDesc Type "+desc.Type.ToString());
            //XE.Performance.Log("LevelDesc Usage "+desc.Usage.ToString());
            //XE.Performance.Log("LevelDesc Width "+desc.Width.ToString());
            //XE.Performance.Log("LevelDesc Height "+desc.Height.ToString());

            D3DLOCKED_RECT lockrect = new D3DLOCKED_RECT();
            RECT           rect     = new RECT();

            Marshal.ThrowExceptionForHR(d3dt.LockRect(0, out lockrect, rect, 0));
            //XE.Performance.Log("LockRect Pitch "+lockrect.Pitch.ToString());
            //XE.Performance.Log("LockRect pBits "+((uint)lockrect.pBits).ToString());

            buffer.CopyTo((IntPtr)(uint)(lockrect.pBits), lockrect.Pitch, 4, false);
            d3dt.UnlockRect(0);

            //Meve onto Dispose() if d3dt will be cached d3dt
            Marshal.ReleaseComObject(d3dt);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Releases reference to all allocated D3D surfaces
        /// </summary>
        private void FreeSurfaces()
        {
            lock (m_instanceLock)
            {
                if(m_privateSurface != null)
                {
                    Marshal.ReleaseComObject(m_privateSurface);
                    m_privateSurface = null;
                }

                if (m_privateTexture != null)
                {
                    Marshal.ReleaseComObject(m_privateTexture);
                    m_privateTexture = null;
                }

                if (DxSurfaces != null)
                {
                    foreach (var ptr in DxSurfaces)
                    {
                        if (ptr != IntPtr.Zero)
                        {
                            /* Release COM reference */
                            Marshal.Release(ptr);
                        }
                    }
                }

                /* Make sure we uninitialize the pointer array
                 * so the rest of our code knows it is invalid */
                DxSurfaces = null;
            }
        }