Пример #1
0
        public CAdapter(Adapter1 dxgiAdapter, int index)
        {
            this.dxgiAdapter = dxgiAdapter;
            this.index = index;

            AdapterDescription1 dxgiDesc = dxgiAdapter.Description1;
            desc = new AdapterDescription
            {
                Description = dxgiDesc.Description,
                VendorId = dxgiDesc.VendorId,
                DeviceId = dxgiDesc.DeviceId,
                SubSysId = dxgiDesc.SubsystemId,
                Revision = dxgiDesc.Revision,
                DedicatedVideoMemory = dxgiDesc.DedicatedVideoMemory,
                DedicatedSystemMemory = dxgiDesc.DedicatedSystemMemory,
                SharedSystemMemory = dxgiDesc.SharedSystemMemory,
                AdapterLuidHigh = (int)(dxgiDesc.Luid >> 32),
                AdapterLuidLow = (int)(dxgiDesc.Luid & 0x00000000FFFFFFFF),
                Flags = CtBeholder.AdapterFlags(dxgiDesc.Flags)
            };

            outputs = dxgiAdapter.Outputs.Select(o => new COutput(o)).ToArray();

            using (var d3dDevice = new Device(dxgiAdapter))
            {
                switch (d3dDevice.FeatureLevel)
                {
                    case FeatureLevel.Level_9_1: apiVersion = new ApiVersion(9, 1); break;
                    case FeatureLevel.Level_9_3: apiVersion = new ApiVersion(9, 3); break;
                    case FeatureLevel.Level_9_2: apiVersion = new ApiVersion(9, 2); break;
                    case FeatureLevel.Level_10_0: apiVersion = new ApiVersion(10, 0); break;
                    case FeatureLevel.Level_10_1: apiVersion = new ApiVersion(10, 1); break;
                    case FeatureLevel.Level_11_0: apiVersion = new ApiVersion(11, 0); break;
                    default: throw new ArgumentOutOfRangeException("d3dDevice.FeatureLevel");
                }

                restrictions = new AdapterRestrictions
                {
                    UniformBufferSlots = CommonShaderStage.ConstantBufferApiSlotCount,
                    SamplerSlots = CommonShaderStage.SamplerSlotCount,
                    ShaderResourceSlots = CommonShaderStage.InputResourceSlotCount,
                    UnorderedAccessResourceSlots = ComputeShaderStage.UnorderedAccessViewSlotCount,
                    MaxVertexStreams = InputAssemblerStage.VertexInputResourceSlotCount,
                    MaxVertexStreamElementCount = InputAssemblerStage.VertexInputStructureElementCount,
                    MaxStreamOutputTargets = 4,
                    MaxViewports = 16,
                    MaxRenderTargets = 8,
                    MaxThreadGroupsX = d3dDevice.FeatureLevel == FeatureLevel.Level_11_0 ? ComputeShaderStage.ThreadGroupMaximumX : 768,
                    MaxThreadGroupsY = d3dDevice.FeatureLevel == FeatureLevel.Level_11_0 ? ComputeShaderStage.ThreadGroupMaximumY : 768,
                    MaxThreadGroupsZ = d3dDevice.FeatureLevel == FeatureLevel.Level_11_0 ? ComputeShaderStage.ThreadGroupMaximumZ : 1,
                    MaxThreadGroupsTotal = d3dDevice.FeatureLevel == FeatureLevel.Level_11_0 ? ComputeShaderStage.ThreadGroupMaximumThreadsPerGroup : 768
                };

                var allFormats = ((ExplicitFormat[])Enum.GetValues(typeof(ExplicitFormat))).Select(x => (Format)x).ToArray();

                formatsSupport = allFormats.Select(d3dDevice.CheckFormatSupport).ToArray();
                formatInfos = allFormats.Where(f => f != 0).Select(CtBeholder.FormatInfo).ToArray();
                //depthStencilFormatInfos = allFormats.Where(f => (formatsSupport[(int)f] & DepthStencilSupportMask) != 0).Select(CtBeholder.DepthStencilFormatInfo).ToArray();
                vertexElementFormats = allFormats.Where(f => (formatsSupport[(int)f] & VertexElementSupportMask) != 0).Select(f => (ExplicitFormat)f).ToArray();

                multisampleQualityLevels = new int[allFormats.Length, MultisampleCountsToTry.Length];

                for (int i = 0; i < allFormats.Length; i++)
                    for (int j = 0; j < MultisampleCountsToTry.Length; j++)
                        multisampleQualityLevels[i, j] = d3dDevice.CheckMultisampleQualityLevels((Format)i, MultisampleCountsToTry[j]);
            }
            /*
            using (var writer = new System.IO.StreamWriter("Formats.txt"))
            {
                for (int i = 0; i < formatsSupport.Length; i++)
                {
                    writer.WriteLine(string.Format("{0, -30}:{1}", (Format)i, formatsSupport[i].ToString().Replace(", ", " | ")));
                }
            }*/
        }
Пример #2
0
 public void GetDescription(out AdapterDescription bAdapterDesc)
 {
     bAdapterDesc = desc;
 }
Пример #3
0
 public void GetDescription(out AdapterDescription desc)
 {
     desc = adapterDesc;
 }
Пример #4
0
        public CAdapter()
        {
            var tempWindow = new GameWindow();
            GraphicsMode bestMode = tempWindow.Context.GraphicsMode;
            var tempContext = new Context(tempWindow.Context);
            var implementation = tempContext.Implementation;
            apiVersion = new ApiVersion((byte)implementation.MajorVersion, (byte)implementation.MinorVersion);
            restrictions = new AdapterRestrictions
            {
                UniformBufferSlots = tempContext.Implementation.MaxUniformBufferBindings,
                SamplerSlots = tempContext.Implementation.MaxCombinedTextureImageUnits, // todo Make those separate
                ShaderResourceSlots = tempContext.Implementation.MaxCombinedTextureImageUnits,
                UnorderedAccessResourceSlots = 0, // todo Set it
                MaxVertexStreams = tempContext.Implementation.MaxVertexAttributes,
                MaxVertexStreamElementCount = 16, // todo: set it
                MaxStreamOutputTargets = tempContext.Implementation.MaxTransformFeedbackSeparateComponents, // todo: make sure
                MaxViewports = tempContext.Implementation.MaxViewports,
                MaxRenderTargets = tempContext.Implementation.MaxColorAttachments,
                MaxThreadGroupsX = 0, // todo: set it,
                MaxThreadGroupsY = 0, // todo: set it,
                MaxThreadGroupsZ = 0,  // todo: set it
                MaxThreadGroupsTotal = 0
            };

            adapterDesc = new AdapterDescription
            {
                Description = GL.GetString(StringName.Renderer),
                VendorId = 0,
                DeviceId = 0,
                SubSysId = 0,
                Revision = 0,
                DedicatedVideoMemory = 0,
                DedicatedSystemMemory = 0,
                SharedSystemMemory = 0,
                AdapterLuidHigh = 0,
                AdapterLuidLow = 0,
                Flags = AdapterFlags.None
            };

            tempWindow.Dispose();

            outputs = GetAvailableDisplays().Select((d, i) => new COutput(d, i)).ToArray();

            //foreach (var format in DisplayColorFormats)
            //{
            //    var expectedColorFormat = CtObjectGL.ColorFormat(format);
            //
            //    tempWindow = new GameWindow(1, 1, new GraphicsMode(expectedColorFormat, bestMode.Depth, bestMode.Stencil));
            //    var actualColorFormat = tempWindow.Context.GraphicsMode.ColorFormat;
            //    tempWindow.Dispose();
            //
            //    if (expectedColorFormat.Red == actualColorFormat.Red &&
            //        expectedColorFormat.Green == actualColorFormat.Green &&
            //        expectedColorFormat.Blue == actualColorFormat.Blue &&
            //        expectedColorFormat.Alpha == actualColorFormat.Alpha)
            //    {
            //        supportedDisplayFormats.Add(format);
            //    }
            //}
        }
Пример #5
0
 void IAdapter.GetDescription(out AdapterDescription desc)
 {
     desc = adapterDesc;
 }
Пример #6
0
        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);
        }