コード例 #1
0
        /// <summary>
        ///		Default constructor.
        /// </summary>
        /// <param name="device">Reference to a Direct3D device.</param>
        public D3DHardwareOcclusionQuery(D3D.Device device)
        {
            this.device = device;

            // check if queries are supported
            isSupported = Root.Instance.RenderSystem.Caps.CheckCap(Capabilities.HardwareOcculusion);

            if (isSupported)
            {
                // attempt to create an occlusion query
                query = new D3D.Query(device, QueryType.Occlusion);
            }
        }
コード例 #2
0
        /// <summary>
        ///		Helper method to go through and interrogate hardware capabilities.
        /// </summary>
        private void InitCapabilities()
        {
            // get caps
            d3dCaps = device.DeviceCaps;

            // max active lights
            caps.MaxLights = d3dCaps.MaxActiveLights;

            D3D.Surface surface = device.DepthStencilSurface;
            D3D.SurfaceDescription surfaceDesc = surface.Description;
            surface.Dispose();

            if (surfaceDesc.Format == D3D.Format.D24S8 || surfaceDesc.Format == D3D.Format.D24X8) {
                caps.SetCap(Capabilities.StencilBuffer);
                // Actually, it's always 8-bit
                caps.StencilBufferBits = 8;
            }

            // Set number of texture units
            caps.TextureUnitCount = d3dCaps.MaxSimultaneousTextures;

            // some cards, oddly enough, do not support this
            if(d3dCaps.DeclTypes.SupportsUByte4) {
                caps.SetCap(Capabilities.VertexFormatUByte4);
            }

            // Anisotropy?
            if(d3dCaps.MaxAnisotropy > 1) {
                caps.SetCap(Capabilities.AnisotropicFiltering);
            }

            // Hardware mipmapping?
            if(d3dCaps.DriverCaps.CanAutoGenerateMipMap) {
                caps.SetCap(Capabilities.HardwareMipMaps);
            }

            // blending between stages is definately supported
            caps.SetCap(Capabilities.TextureBlending);
            caps.SetCap(Capabilities.MultiTexturing);

            // Dot3 bump mapping?
            if(d3dCaps.TextureOperationCaps.SupportsDotProduct3) {
                caps.SetCap(Capabilities.Dot3);
            }

            // Cube mapping?
            if(d3dCaps.TextureCaps.SupportsCubeMap) {
                caps.SetCap(Capabilities.CubeMapping);
            }

            // Texture Compression
            // We always support compression, D3DX will decompress if device does not support
            caps.SetCap(Capabilities.TextureCompression);
            caps.SetCap(Capabilities.TextureCompressionDXT);

            // D3D uses vertex buffers for everything
            caps.SetCap(Capabilities.VertexBuffer);

            // Scissor test
            if(d3dCaps.RasterCaps.SupportsScissorTest) {
                caps.SetCap(Capabilities.ScissorTest);
            }

            // 2 sided stencil
            if(d3dCaps.StencilCaps.SupportsTwoSided) {
                caps.SetCap(Capabilities.TwoSidedStencil);
            }

            // stencil wrap
            if(d3dCaps.StencilCaps.SupportsIncrement && d3dCaps.StencilCaps.SupportsDecrement) {
                caps.SetCap(Capabilities.StencilWrap);
            }

            // Hardware Occlusion
            try {
                D3D.Query test = new D3D.Query(device, QueryType.Occlusion);

                // if we made it this far, it is supported
                caps.SetCap(Capabilities.HardwareOcculusion);

                test.Dispose();
            }
            catch {
                // eat it, this is not supported
                // TODO: Isn't there a better way to check for D3D occlusion query support?
            }

            if(d3dCaps.MaxUserClipPlanes > 0) {
                caps.SetCap(Capabilities.UserClipPlanes);
            }

            CheckVertexProgramCaps();

            CheckFragmentProgramCaps();

            Driver driver = D3DHelper.GetDriverInfo();

            AdapterDetails details = D3D.Manager.Adapters[driver.AdapterNumber].Information;

            caps.DeviceName = details.Description;
            caps.DriverVersion = details.DriverVersion.ToString();

            try {
                //
                // use the dxdiag interface to get the actual size of video memory
                //
                Container container = new Container(false);
                container = container.GetContainer("DxDiag_DisplayDevices").Container;
                container = container.GetContainer(0).Container;

                Microsoft.DirectX.Diagnostics.PropertyData prop = container.GetProperty("szDisplayMemoryEnglish");
                string s = prop.Data as string;

                int numStartOffset = -1;
                for (int i = 0; i < s.Length; i++) {
                    char c = s[i];
                    if (char.IsDigit(s[i])) {
                        numStartOffset = i;
                        break;
                    }
                }

                if (numStartOffset >= 0) {
                    int numEndOffset;
                    for (numEndOffset = numStartOffset; numEndOffset < s.Length; numEndOffset++) {
                        if (!char.IsDigit(s[numEndOffset])) {
                            break;
                        }
                    }

                    string numString = s.Substring(numStartOffset, numEndOffset - numStartOffset);
                    //LogManager.Instance.Write("DXDiag memory size string returned: {0}", s);
                    //LogManager.Instance.Write("parsing memory size string: {0}", numString);

                    caps.VideoMemorySize = int.Parse(numString);
                    //LogManager.Instance.Write("Parsed memory size value is: {0}", caps.VideoMemorySize);

                } else {
                    // couldn't determine size
                    caps.VideoMemorySize = 0;
                }
            } catch (Exception) {
            #if FALSE_WARNING_IS_FIXED
                log.Warn("DXDiag unable to determine memory size.");
            #endif
                // couldn't determine size
                caps.VideoMemorySize = 0;
            }

            // Infinite projection?
            // We have no capability for this, so we have to base this on our
            // experience and reports from users
            // Non-vertex program capable hardware does not appear to support it
            if(caps.CheckCap(Capabilities.VertexPrograms)) {
                // GeForce4 Ti (and presumably GeForce3) does not
                // render infinite projection properly, even though it does in GL
                // So exclude all cards prior to the FX range from doing infinite

                // not nVidia or GeForceFX and above
                if(details.VendorId != 0x10DE || details.DeviceId >= 0x0301) {
                    caps.SetCap(Capabilities.InfiniteFarPlane);
                }
            }

            // TODO: Add the rest of the caps.
            caps.NumMultiRenderTargets = d3dCaps.NumberSimultaneousRts;

            // write hardware capabilities to registered log listeners
            caps.Log();
        }
コード例 #3
0
        /// <summary>
        ///		Default constructor.
        /// </summary>
        /// <param name="device">Reference to a Direct3D device.</param>
        public D3DHardwareOcclusionQuery(D3D.Device device)
        {
            this.device = device;

            // check if queries are supported
            isSupported = Root.Instance.RenderSystem.Caps.CheckCap(Capabilities.HardwareOcculusion);

            if(isSupported) {
                // attempt to create an occlusion query
                query = new D3D.Query(device, QueryType.Occlusion);
            }
        }
コード例 #4
0
 private bool Initialize(QueryManager manager)
 {
     d3dQuery = new D3d.Query(manager.Device.D3dDevice, D3d.QueryType.Occlusion);
     return(true);
 }