コード例 #1
0
		public D3D9RenderTexture( string name, D3D9HardwarePixelBuffer buffer, bool writeGamma, int fsaa )
			: base( buffer, 0 )
		{
			this.name = name;
			hwGamma = writeGamma;
			this.fsaa = fsaa;
		}
コード例 #2
0
ファイル: D3D9RenderTexture.cs プロジェクト: axiom3d/axiom
 public D3D9RenderTexture(string name, D3D9HardwarePixelBuffer buffer, bool writeGamma, int fsaa)
     : base(buffer, 0)
 {
     this.name = name;
     hwGamma   = writeGamma;
     this.fsaa = fsaa;
 }
コード例 #3
0
        public void LockDeviceAccess()
        {
            Contract.Requires(this._deviceAccessLockCount >= 0);
            this._deviceAccessLockCount++;
            if (this._deviceAccessLockCount == 1)
            {
#if AXIOM_THREAD_SUPPORT
                System.Threading.Monitor.Enter(_resourcesMutex);
#endif
                foreach (var it in this.Resources)
                {
                    it.LockDeviceAccess();
                }

                D3D9HardwarePixelBuffer.LockDeviceAccess();
            }
        }
コード例 #4
0
        public void UnlockDeviceAccess()
        {
            Contract.Requires(this._deviceAccessLockCount > 0);
            this._deviceAccessLockCount--;
            if (this._deviceAccessLockCount == 0)
            {
                // outermost recursive lock release, propagte unlock
                foreach (var it in this.Resources)
                {
                    it.UnlockDeviceAccess();
                }

                D3D9HardwarePixelBuffer.UnlockDeviceAccess();
#if AXIOM_THREAD_SUPPORT
                System.Threading.Monitor.Exit(_resourcesMutex);
#endif
            }
        }
コード例 #5
0
ファイル: D3D9Texture.cs プロジェクト: ryan-bunker/axiom3d
		private void _createSurfaceList( D3D9.Device d3d9Device, TextureResources textureResources )
		{
			Debug.Assert( textureResources != null );
			Debug.Assert( textureResources.BaseTexture != null );

			// Make sure number of mips is right
			mipmapCount = textureResources.BaseTexture.LevelCount - 1;

			// Need to know static / dynamic
			BufferUsage bufusage;
			if ( ( ( Usage & TextureUsage.Dynamic ) != 0 ) && this._dynamicTextures )
			{
				bufusage = BufferUsage.Dynamic;
			}
			else
			{
				bufusage = BufferUsage.Static;
			}

			if ( ( Usage & TextureUsage.RenderTarget ) != 0 )
			{
				bufusage = (BufferUsage)( (int)bufusage | (int)TextureUsage.RenderTarget );
			}

			var surfaceCount = FaceCount*( mipmapCount + 1 );
			var updateOldList = this._surfaceList.Count == surfaceCount;
			if ( !updateOldList )
			{
				// Create new list of surfaces
				_clearSurfaceList();
				for ( var face = 0; face < FaceCount; ++face )
				{
					for ( var mip = 0; mip <= MipmapCount; ++mip )
					{
						var buffer = new D3D9HardwarePixelBuffer( bufusage, this );
						this._surfaceList.Add( buffer );
					}
				}
			}

			switch ( TextureType )
			{
				case TextureType.OneD:
				case TextureType.TwoD:
					Debug.Assert( textureResources.NormalTexture != null );
					// For all mipmaps, store surfaces as HardwarePixelBuffer
					for ( var mip = 0; mip <= MipmapCount; ++mip )
					{
						var surface = textureResources.NormalTexture.GetSurfaceLevel( 0 );
						var currPixelBuffer = _getSurfaceAtLevel( 0, mip );

						if ( mip == 0 && requestedMipmapCount != 0 && ( usage & TextureUsage.AutoMipMap ) != 0 )
						{
							currPixelBuffer.SetMipmapping( true, mipmapsHardwareGenerated );
						}

						currPixelBuffer.Bind( d3d9Device, surface, textureResources.FSAASurface, this._hwGammaWriteSupported, fsaa, _name,
						                      textureResources.BaseTexture );

						// decrement reference count, the GetSurfaceLevel call increments this
						// this is safe because the pixel buffer keeps a reference as well
						//TODO
						//surface.Release();
					}
					break;

				case TextureType.CubeMap:
					Debug.Assert( textureResources.CubeTexture != null );

					// For all faces and mipmaps, store surfaces as HardwarePixelBuffer
					for ( var face = 0; face < 6; ++face )
					{
						for ( var mip = 0; mip <= MipmapCount; ++mip )
						{
							var surface = textureResources.CubeTexture.GetCubeMapSurface( (D3D9.CubeMapFace)face, mip );
							var currPixelBuffer = _getSurfaceAtLevel( face, mip );

							if ( mip == 0 && requestedMipmapCount != 0 && ( usage & TextureUsage.AutoMipMap ) != 0 )
							{
								currPixelBuffer.SetMipmapping( true, mipmapsHardwareGenerated );
							}

							currPixelBuffer.Bind( d3d9Device, surface, textureResources.FSAASurface, this._hwGammaWriteSupported, fsaa, _name,
							                      textureResources.BaseTexture );

							// decrement reference count, the GetSurfaceLevel call increments this
							// this is safe because the pixel buffer keeps a reference as well

							//TODO
							//surface.Release();
						}
					}
					break;

				case TextureType.ThreeD:
					Debug.Assert( textureResources.VolumeTexture != null );

					// For all mipmaps, store surfaces as HardwarePixelBuffer
					for ( var mip = 0; mip <= MipmapCount; ++mip )
					{
						var volume = textureResources.VolumeTexture.GetVolumeLevel( mip );
						var currPixelBuffer = _getSurfaceAtLevel( 0, mip );

						currPixelBuffer.Bind( d3d9Device, volume, textureResources.BaseTexture );

						if ( mip == 0 && requestedMipmapCount != 0 && ( usage & TextureUsage.AutoMipMap ) != 0 )
						{
							currPixelBuffer.SetMipmapping( true, mipmapsHardwareGenerated );
						}

						// decrement reference count, the GetSurfaceLevel call increments this
						// this is safe because the pixel buffer keeps a reference as well

						//TODO
						//volume.Release();
					}
					break;
			}
			;
		}