Beispiel #1
0
        public override Axiom.Media.PixelFormat GetNativeFormat(TextureType ttype, PixelFormat format, TextureUsage usage)
        {
            // Basic filtering
            var d3dPF = D3D9Helper.ConvertEnum(D3D9Helper.GetClosestSupported(format));

            // Calculate usage
            var d3dusage = D3D9.Usage.None;
            var pool     = D3D9.Pool.Managed;

            if ((usage & TextureUsage.RenderTarget) != 0)
            {
                d3dusage |= D3D9.Usage.RenderTarget;
                pool      = D3D9.Pool.Default;
            }
            if ((usage & TextureUsage.Dynamic) != 0)
            {
                d3dusage |= D3D9.Usage.Dynamic;
                pool      = D3D9.Pool.Default;
            }

            var curDevice = D3D9RenderSystem.ActiveD3D9Device;

            // Use D3DX to adjust pixel format
            switch (ttype)
            {
            case TextureType.OneD:
            case TextureType.TwoD:
                var tReqs = D3D9.Texture.CheckRequirements(curDevice, 0, 0, 0, d3dusage, D3D9Helper.ConvertEnum(format), pool);
                d3dPF = tReqs.Format;
                break;

            case TextureType.ThreeD:
                var volReqs = D3D9.VolumeTexture.CheckRequirements(curDevice, 0, 0, 0, 0, d3dusage,
                                                                   D3D9Helper.ConvertEnum(format), pool);
                d3dPF = volReqs.Format;
                break;

            case TextureType.CubeMap:
                var cubeReqs = D3D9.CubeTexture.CheckRequirements(curDevice, 0, 0, d3dusage, D3D9Helper.ConvertEnum(format),
                                                                  pool);
                d3dPF = cubeReqs.Format;
                break;
            }

            return(D3D9Helper.ConvertEnum(d3dPF));
        }
        private bool _checkVertexTextureFormats(D3D9RenderWindow renderWindow)
        {
            var anySupported = false;

            var bbSurf     = (D3D9.Surface[])renderWindow["DDBACKBUFFER"];
            var bbSurfDesc = bbSurf[0].Description;

            for (var pf = PixelFormat.L8; pf < PixelFormat.Count; ++pf)
            {
                var fmt = D3D9Helper.ConvertEnum(D3D9Helper.GetClosestSupported(pf));
                if (
                    !this._pD3D.CheckDeviceFormat(this._activeD3DDriver.AdapterNumber, D3D9.DeviceType.Hardware, bbSurfDesc.Format,
                                                  D3D9.Usage.QueryVertexTexture, D3D9.ResourceType.Texture, fmt))
                {
                    continue;
                }

                // cool, at least one supported
                anySupported = true;
                LogManager.Instance.Write("D3D9: Vertex texture format supported - {0}", PixelUtil.GetFormatName(pf));
            }

            return(anySupported);
        }