예제 #1
0
파일: D3D9Driver.cs 프로젝트: axiom3d/axiom
 public D3D9Driver(int adapterNumber, D3D9.Capabilities deviceCaps, D3D9.AdapterDetails adapterIdentifier,
                   D3D9.DisplayMode desktopDisplayMode)
     : base()
 {
     this._adapterNumber      = adapterNumber;
     this._d3D9DeviceCaps     = deviceCaps;
     this._adapterIdentifier  = adapterIdentifier;
     this._desktopDisplayMode = desktopDisplayMode;
     this._videoModeList      = null;
 }
예제 #2
0
    public static DxCapabilities RequestCapabilities(Capabilities deviceCapabilities, DisplayMode displayMode)
    {
      int maxAnisotropy = deviceCapabilities.MaxAnisotropy;
      bool supportsFiltering = MPDirect3D.Direct3D.CheckDeviceFormat(
          deviceCapabilities.AdapterOrdinal, deviceCapabilities.DeviceType, displayMode.Format,
          Usage.RenderTarget | Usage.QueryFilter, ResourceType.Texture, Format.A8R8G8B8);

      bool supportsAlphaBlend = MPDirect3D.Direct3D.CheckDeviceFormat(deviceCapabilities.AdapterOrdinal,
          deviceCapabilities.DeviceType, displayMode.Format, Usage.RenderTarget | Usage.QueryPostPixelShaderBlending,
          ResourceType.Surface, Format.A8R8G8B8);
      bool supportsShaders = deviceCapabilities.PixelShaderVersion.Major >= 2 && deviceCapabilities.VertexShaderVersion.Major >= 2;
      return new DxCapabilities(maxAnisotropy, supportsFiltering, supportsAlphaBlend, supportsShaders);
    }
예제 #3
0
 protected static string ToString(DisplayMode mode)
 {
   return string.Format("{0}x{1}@{2}", mode.Width, mode.Height, mode.RefreshRate);
 }
예제 #4
0
    /// <summary>
    /// Returns a settings object with best available fullscreen mode, according to 
    /// the <paramref name="doesRequireHardware"/> and <paramref name="doesRequireReference"/> constraints.  
    /// </summary>
    /// <param name="doesRequireHardware">The device requires hardware support.</param>
    /// <param name="doesRequireReference">The device requires the ref device.</param>
    /// <returns><c>true</c> if a mode is found, <c>false</c> otherwise.</returns>
    public bool FindBestFullscreenMode(bool doesRequireHardware, bool doesRequireReference)
    {
      D3DConfiguration result = new D3DConfiguration();

      // For fullscreen, default to first HAL DeviceCombo that supports the current desktop 
      // display mode, or any display mode if HAL is not compatible with the desktop mode, or 
      // non-HAL if no HAL is available
      DisplayMode bestAdapterDesktopDisplayMode = new DisplayMode();

      GraphicsAdapterInfo bestAdapterInfo = null;
      GraphicsDeviceInfo bestDeviceInfo = null;
      DeviceCombo bestDeviceCombo = null;

      foreach (GraphicsAdapterInfo adapterInfo in _enumerationSettings.AdapterInfoList)
      {
        //if (GUIGraphicsContext._useScreenSelector)
        //  adapterInfo = FindAdapterForScreen(GUI.Library.GUIGraphicsContext.currentScreen);

        DisplayMode adapterDesktopDisplayMode = MPDirect3D.Direct3D.Adapters[adapterInfo.AdapterOrdinal].CurrentDisplayMode;
        foreach (GraphicsDeviceInfo deviceInfo in adapterInfo.DeviceInfos)
        {
          if (doesRequireHardware && deviceInfo.DevType != DeviceType.Hardware)
            continue;
          if (doesRequireReference && deviceInfo.DevType != DeviceType.Reference)
            continue;

          foreach (DeviceCombo deviceCombo in deviceInfo.DeviceCombos)
          {
            if (deviceCombo.IsWindowed)
              continue;

            bool adapterMatchesBackBuffer = (deviceCombo.BackBufferFormat == deviceCombo.AdapterFormat);
            bool adapterMatchesDesktop = (deviceCombo.AdapterFormat == adapterDesktopDisplayMode.Format);

            // If we haven't found a compatible set yet, or if this set
            // is better (because it's a HAL, and/or because formats match better),
            // save it
            if (bestDeviceCombo == null ||
                bestDeviceCombo.DevType != DeviceType.Hardware && deviceInfo.DevType == DeviceType.Hardware ||
                bestDeviceCombo.DevType == DeviceType.Hardware &&
                bestDeviceCombo.AdapterFormat != adapterDesktopDisplayMode.Format && adapterMatchesDesktop ||
                bestDeviceCombo.DevType == DeviceType.Hardware && adapterMatchesDesktop && adapterMatchesBackBuffer)
            {
              bestAdapterDesktopDisplayMode = adapterDesktopDisplayMode;
              bestAdapterInfo = adapterInfo;
              bestDeviceInfo = deviceInfo;
              bestDeviceCombo = deviceCombo;
              if (deviceInfo.DevType == DeviceType.Hardware && adapterMatchesDesktop && adapterMatchesBackBuffer)
                // This fullscreen device combo looks great -- take it
                goto EndFullscreenDeviceComboSearch;
              // Otherwise keep looking for a better fullscreen device combo
            }
          }
        }
        //if (GUIGraphicsContext._useScreenSelector)
        //  break;// no need to loop again.. result would be the same
      }

    EndFullscreenDeviceComboSearch:
      if (bestDeviceCombo == null)
        return false;

      // Need to find a display mode on the best adapter that uses pBestDeviceCombo->AdapterFormat
      // and is as close to bestAdapterDesktopDisplayMode's res as possible
      foreach (DisplayMode displayMode in bestAdapterInfo.DisplayModes)
      {
        if (displayMode.Format != bestDeviceCombo.AdapterFormat)
          continue;
        if (displayMode.Width == bestAdapterDesktopDisplayMode.Width &&
            displayMode.Height == bestAdapterDesktopDisplayMode.Height &&
            displayMode.RefreshRate == bestAdapterDesktopDisplayMode.RefreshRate)
          _desktopDisplayMode = displayMode;
      }

      result.DisplayMode = bestAdapterDesktopDisplayMode;
      result.AdapterInfo = bestAdapterInfo;
      result.DeviceInfo = bestDeviceInfo;
      result.DeviceCombo = bestDeviceCombo;

      return true;
    }
 private Result GetDisplayMode(IntPtr devicePointer, uint swapChainIndex, DisplayMode mode)
 {
     throw new NotImplementedException();
 }
예제 #6
0
 private static void AdaptTargetFrameRateToDisplayMode(DisplayMode displayMode)
 {
   SetFrameRate(displayMode.RefreshRate);
 }
예제 #7
0
 private static void LogScreenMode(DisplayMode mode)
 {
   ServiceRegistration.Get<ILogger>().Info("GraphicsDevice: DirectX initialized {0}x{1} (format: {2} {3} Hz)", Width,
       Height, mode.Format, TargetFrameRate);
 }
예제 #8
0
		/// <summary>
		///	Accepts a existing Direct3D.DisplayMode object.
		/// </summary>
		public D3D9VideoMode( D3D.DisplayMode videoMode )
		{
			this.modeNum = ++modeCount;
			this.displayMode = videoMode;
		}
예제 #9
0
		public D3D9VideoMode()
		{
			this.modeNum = ++modeCount;
			this.displayMode = new D3D.DisplayMode();
		}
예제 #10
0
파일: CAdapter.cs 프로젝트: Zulkir/Beholder
        public CAdapter(Direct3D direct3D, AdapterInformation adapterInfo)
        {
            this.direct3D = direct3D;
            this.adapterInfo = adapterInfo;
            desctopDisplayMode = adapterInfo.CurrentDisplayMode;
            caps = adapterInfo.GetCaps(DeviceType.Hardware);
            index = adapterInfo.Adapter;
            var shaderModel = System.Math.Min(caps.VertexShaderVersion.Major, caps.PixelShaderVersion.Major);
            apiVersion = new ApiVersion(9, (byte)shaderModel);
            var details = adapterInfo.Details;
            restrictions = new AdapterRestrictions
            {
                UniformBufferSlots = 256,
                SamplerSlots = caps.MaxSimultaneousTextures,
                ShaderResourceSlots = caps.MaxSimultaneousTextures,
                UnorderedAccessResourceSlots = 0,
                MaxVertexStreams = caps.MaxStreams,
                MaxVertexStreamElementCount = caps.MaxStreamStride / (4 * sizeof(float)),
                MaxStreamOutputTargets = 0,
                MaxViewports = 1,
                MaxRenderTargets = caps.SimultaneousRTCount,
                MaxThreadGroupsX = 0,
                MaxThreadGroupsY = 0,
                MaxThreadGroupsZ = 0,
                MaxThreadGroupsTotal = 0,
            };

            adapterDesc = new AdapterDescription
            {
                Description = details.Description,
                VendorId = details.VendorId,
                DeviceId = details.DeviceId,
                SubSysId = details.SubsystemId,
                Revision = details.Revision,
                DedicatedVideoMemory = 0,
                DedicatedSystemMemory = 0,
                SharedSystemMemory = 0,
                AdapterLuidHigh = 0,
                AdapterLuidLow = 0,
                Flags = AdapterFlags.None
            };

            outputDesc = new OutputDescription
            {
                DeviceName = details.DeviceName,
                DesctopCoordinates = new Math.Rectangle(),
                AttachedToDesctop = false,
                Rotation = ModeRotation.Unspecified,
                MonitorHandle = adapterInfo.Monitor
            };

            outputs = new[] { this };

            formatSupports = ((Format[])Enum.GetValues(typeof(Format))).ToDictionary(f => f, GetFormatSupport);
        }
예제 #11
0
 /// <summary>
 ///	Accepts a existing Direct3D.DisplayMode object.
 /// </summary>
 public D3D9VideoMode(D3D.DisplayMode videoMode)
 {
     this.modeNum     = ++modeCount;
     this.displayMode = videoMode;
 }
예제 #12
0
 public D3D9VideoMode()
 {
     this.modeNum     = ++modeCount;
     this.displayMode = new D3D.DisplayMode();
 }