Exemplo n.º 1
0
        public static bool CheckAdapterMeetsRequirements(int adapter, GraphicsDeviceRequirements requirements)
        {
            // check formats against device type
            foreach (Format format in requirements.RenderTargetFormats)
            {
                if (!Manager.CheckDeviceType(adapter, requirements.DeviceType, requirements.DisplayFormat,
                                             format, requirements.Windowed))
                {
                    return(false);
                }
            }
            // multisample
            if (!Manager.CheckDeviceMultiSampleType(adapter, requirements.DeviceType, requirements.RenderTargetFormats[0],
                                                    requirements.Windowed, requirements.MultiSample))
            {
                return(false);
            }
            // depthstencil formats
            foreach (DepthFormat format in requirements.DepthFormats)
            {
                if (!Manager.CheckDepthStencilMatch(adapter, requirements.DeviceType, requirements.DisplayFormat,
                                                    requirements.RenderTargetFormats[0], format))
                {
                    return(false);
                }
            }

            // rts
            Caps caps = Manager.GetDeviceCaps(0, requirements.DeviceType);

            if (caps.NumberSimultaneousRts < requirements.NumRenderTargets)
            {
                return(false);
            }

            // shaders
            if (requirements.PixelShader != null && requirements.PixelShader.CompareTo(caps.PixelShaderVersion) > 0)
            {
                return(false);
            }
            if (requirements.VertexShader != null && requirements.VertexShader.CompareTo(caps.VertexShaderVersion) > 0)
            {
                return(false);
            }

            if (requirements.Pure && !caps.DeviceCaps.SupportsPureDevice)
            {
                return(false);
            }
            if (requirements.HardwareTnL && !caps.DeviceCaps.SupportsHardwareTransformAndLight)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private static GraphicsDeviceRequirements CheckReqs(int adapter, GraphicsDeviceRequirements minReqs,
                                                            GraphicsDeviceRequirements maxReqs)
        {
            DeviceType devType = minReqs.DeviceType;

            if (Manager.CheckDeviceType(adapter, maxReqs.DeviceType, minReqs.DisplayFormat,
                                        minReqs.RenderTargetFormats[0], maxReqs.Windowed))
            {
                devType = maxReqs.DeviceType;
            }

            Format[] rtFormats = minReqs.RenderTargetFormats;
            bool     useMax    = true;

            foreach (Format format in maxReqs.RenderTargetFormats)
            {
                if (!Manager.CheckDeviceType(adapter, devType, minReqs.DisplayFormat,
                                             format, minReqs.Windowed))
                {
                    useMax = false;
                    break;
                }
            }
            if (useMax)
            {
                rtFormats = maxReqs.RenderTargetFormats;
            }

            MultiSampleType ms = minReqs.MultiSample;

            if (Manager.CheckDeviceMultiSampleType(adapter, devType, rtFormats[0],
                                                   minReqs.Windowed, maxReqs.MultiSample))
            {
                ms = maxReqs.MultiSample;
            }

            Caps caps = Manager.GetDeviceCaps(adapter, devType);
            bool pure = minReqs.Pure;

            if (maxReqs.Pure && caps.DeviceCaps.SupportsPureDevice)
            {
                pure = true;
            }
            bool tnl = minReqs.HardwareTnL;

            if (maxReqs.HardwareTnL && caps.DeviceCaps.SupportsHardwareTransformAndLight)
            {
                tnl = true;
            }

            return(new GraphicsDeviceRequirements(ms, devType, rtFormats, minReqs.NumRenderTargets,
                                                  minReqs.Windowed, minReqs.DepthFormats, pure, tnl));
        }
Exemplo n.º 3
0
        public RequirementsCompatibility CheckCapabilities(GraphicsDeviceRequirements reqs)
        {
            RequirementsCompatibility rComp = new RequirementsCompatibility();

            // check shaders
            //Version buildZero = new Version();
            rComp.PS = !(reqs.PixelShader != null && reqs.PixelShader.CompareTo(pShaderVersion) > 0);
            rComp.VS = !(reqs.VertexShader != null && reqs.VertexShader.CompareTo(vShaderVersion) > 0);

            rComp.Mark();

            return(rComp);
        }
Exemplo n.º 4
0
        public CommonDeviceInterface(int adapter, GraphicsDeviceRequirements baseReq, /*GraphicsDeviceRequirements minReq,*/
                                     string base_path)
        {
            this.adapter = adapter;
            outCaps      = GraphicsDeviceCaps.GetAdapterCaps(adapter, baseReq.DeviceType, baseReq.DisplayFormat);
            //minSettings = GraphicsDeviceSettings.CreateFromRequirements(baseReq, outCaps, minReq);
            rzManager = new ResourceManager();
            rzManager.AddSet(new ResourceSet(GlobalResources));

            log = new DirectFileLog(base_path + "general.log");

            rzLoader = new RzLoader();
            rzLoader.RegisterContentLoader(new ImageContentLoader());
        }
Exemplo n.º 5
0
        public OutputCapsCompatibility CheckCompatibility(GraphicsDeviceRequirements req)
        {
            // TODO: Check we only have stuff we need in the setup process and that it works
            OutputCapsCompatibility comp = new OutputCapsCompatibility();

            comp.supportDeviceType   = Manager.CheckDeviceType(adapter, req.DeviceType, req.DisplayFormat, req.DisplayFormat, req.Windowed);
            comp.supportDeviceFormat = true;// Manager.CheckDeviceFormat(adapter, req.DeviceType, req.DeviceFormat, Usage.RenderTarget, ResourceType.Surface, DepthFormat.D16);
            comp.supportDepthFormat  = Manager.CheckDepthStencilMatch(adapter, req.DeviceType, req.DisplayFormat, req.DisplayFormat, req.DepthFormats[0]);

            comp.fullMatch = comp.supportDepthFormat && comp.supportDeviceFormat &&
                             comp.supportDeviceType && HardwareTnL == req.HardwareTnL &&
                             req.MultiSample <= antialiasCaps.MaxSupported;

            return(comp);
        }
Exemplo n.º 6
0
        public static GraphicsDeviceSettings CreateOutputDescription(int adapter,
                                                                     GraphicsDeviceRequirements minReqs,
                                                                     GraphicsDeviceRequirements maxReqs)
        {
            GraphicsDeviceRequirements requirements = CheckReqs(adapter, minReqs, maxReqs);

            CreateFlags cFlags;

            if (requirements.Pure)
            {
                cFlags = CreateFlags.PureDevice;
            }
            else if (requirements.HardwareTnL)
            {
                cFlags = CreateFlags.HardwareVertexProcessing;
            }
            else
            {
                cFlags = CreateFlags.SoftwareVertexProcessing;
            }
            return(new GraphicsDeviceSettings(adapter, requirements.Windowed, requirements.DeviceType,
                                              requirements.RenderTargetFormats[0], requirements.MultiSample,
                                              requirements.DepthFormats[0], cFlags));
        }
Exemplo n.º 7
0
        public static GraphicsDeviceSettings CreateFromRequirements(GraphicsDeviceRequirements requirements,
                                                                    GraphicsDeviceCaps caps,
                                                                    GraphicsDeviceRequirements fallbacks,
                                                                    out bool fullyMatchReq)
        {
            if (caps == null)
            {
                caps = GraphicsDeviceCaps.GetDefaultAdapterCaps(requirements);
            }

            GraphicsDeviceSettings settings = new GraphicsDeviceSettings();

            settings.adapter = caps.Adapter;

            Type type = typeof(GraphicsDeviceSettings);

            GraphicsDeviceCaps.OutputCapsCompatibility reqComp      = caps.CheckCompatibility(requirements);
            GraphicsDeviceCaps.OutputCapsCompatibility fallbackComp = caps.CheckCompatibility(fallbacks);

            fullyMatchReq = reqComp.FullMatch;

            // check reqs against caps
            if (reqComp.SupportDeviceType)
            {
                settings.devType = requirements.DeviceType;
            }
            else if (fallbackComp.SupportDeviceType)
            {
                settings.devType = fallbacks.DeviceType;
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("DeviceType"),
                                                  requirements.DeviceType, null);
            }

            if (reqComp.SupportDeviceFormat)
            {
                settings.devFormat = requirements.DisplayFormat;
            }
            else if (fallbackComp.SupportDeviceFormat)
            {
                settings.devFormat = fallbacks.DisplayFormat;
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("DeviceFormat"),
                                                  requirements.DisplayFormat, null);
            }

            if (reqComp.SupportDepthFormat)
            {
                settings.depthFormat = requirements.DepthFormats[0];
            }
            else if (fallbackComp.SupportDepthFormat)
            {
                settings.depthFormat = fallbacks.DepthFormats[0];
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("DepthFormat"),
                                                  requirements.DepthFormats[0], null);
            }

            if (caps.HardwareTnL && requirements.HardwareTnL)
            {
                settings.createFlags = CreateFlags.HardwareVertexProcessing;
            }
            else if (!requirements.HardwareTnL)
            {
                settings.createFlags = CreateFlags.SoftwareVertexProcessing;
            }
            else if (!fallbacks.HardwareTnL)
            {
                settings.createFlags = CreateFlags.SoftwareVertexProcessing;
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("CreateFlags"),
                                                  requirements.HardwareTnL, null);
            }

            if (requirements.MultiSample <= caps.AntiAliasing.MaxSupported)
            {
                settings.multisample = requirements.MultiSample;
            }
            else if (fallbacks.MultiSample <= caps.AntiAliasing.MaxSupported)
            {
                settings.multisample = fallbacks.MultiSample;
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("AntiAliasing"),
                                                  requirements.MultiSample, caps.AntiAliasing.MaxSupported);
            }

            return(settings);
        }
Exemplo n.º 8
0
 public static GraphicsDeviceCaps GetDefaultAdapterCaps(GraphicsDeviceRequirements req)
 {
     return(GetAdapterCaps(Manager.Adapters.Default.Adapter, req.DeviceType, req.DisplayFormat));
 }