当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.GraphicsDevice类代码示例

本文整理汇总了C#中SiliconStudio.Xenko.Graphics.GraphicsDevice的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice类的具体用法?C# GraphicsDevice怎么用?C# GraphicsDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GraphicsDevice类属于SiliconStudio.Xenko.Graphics命名空间,在下文中一共展示了GraphicsDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SwapChainGraphicsPresenter

        public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
        {
            gameWindow = (iPhoneOSGameView)Description.DeviceWindowHandle.NativeHandle;
            device.InitDefaultRenderTarget(presentationParameters);

            backBuffer = Texture.New2D(device, Description.BackBufferWidth, Description.BackBufferHeight, presentationParameters.BackBufferFormat, TextureFlags.RenderTarget | TextureFlags.ShaderResource);
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:7,代码来源:SwapChainGraphicsPresenter.iOS.cs

示例2: CreateDebugPrimitive

        public override MeshDraw CreateDebugPrimitive(GraphicsDevice device)
        {
            if (cachedDebugPrimitive != null) return cachedDebugPrimitive;

            var verts = new VertexPositionNormalTexture[pointsList.Count];
            for (var i = 0; i < pointsList.Count; i++)
            {
                verts[i].Position = pointsList[i];
                verts[i].TextureCoordinate = Vector2.Zero;
                verts[i].Normal = Vector3.Zero;
            }

            var intIndices = indicesList.Select(x => (int)x).ToArray();

            ////calculate basic normals
            ////todo verify, winding order might be wrong?
            for (var i = 0; i < indicesList.Count; i += 3)
            {
                var i1 = intIndices[i];
                var i2 = intIndices[i + 1];
                var i3 = intIndices[i + 2];
                var a = verts[i1];
                var b = verts[i2];
                var c = verts[i3];
                var n = Vector3.Cross((b.Position - a.Position), (c.Position - a.Position));
                n.Normalize();
                verts[i1].Normal = verts[i2].Normal = verts[i3].Normal = n;
            }

            var meshData = new GeometricMeshData<VertexPositionNormalTexture>(verts, intIndices, false);

            cachedDebugPrimitive = new GeometricPrimitive(device, meshData).ToMeshDraw();

            return cachedDebugPrimitive;
        }
开发者ID:psowinski,项目名称:xenko,代码行数:35,代码来源:ConvexHullColliderShape.cs

示例3: DepthStencilState

        private DepthStencilState(GraphicsDevice device, DepthStencilStateDescription depthStencilStateDescription)
            : base(device)
        {
            Description = depthStencilStateDescription;

            depthFunction = Description.DepthBufferFunction.ToOpenGLDepthFunction();
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:7,代码来源:DepthStencilState.OpenGL.cs

示例4: DescriptorPool

        private DescriptorPool(GraphicsDevice graphicsDevice, DescriptorTypeCount[] counts) : base(graphicsDevice)
        {
            // For now, we put everything together so let's compute total count
            foreach (var count in counts)
            {
                if (count.Type == EffectParameterClass.Sampler)
                    SamplerCount += count.Count;
                else
                    SrvCount += count.Count;
            }

            if (SrvCount > 0)
            {
                SrvHeap = graphicsDevice.NativeDevice.CreateDescriptorHeap(new DescriptorHeapDescription
                {
                    DescriptorCount = SrvCount,
                    Flags = DescriptorHeapFlags.None,
                    Type = DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView,
                });
            }

            if (SamplerCount > 0)
            {
                SamplerHeap = graphicsDevice.NativeDevice.CreateDescriptorHeap(new DescriptorHeapDescription
                {
                    DescriptorCount = SamplerCount,
                    Flags = DescriptorHeapFlags.None,
                    Type = DescriptorHeapType.Sampler,
                });
            }
        }
开发者ID:cg123,项目名称:xenko,代码行数:31,代码来源:DescriptorPool.Direct3D12.cs

示例5: DescriptorSet

        private DescriptorSet(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc)
        {
            if (pool.SrvOffset + desc.SrvCount > pool.SrvCount || pool.SamplerOffset + desc.SamplerCount > pool.SamplerCount)
            {
                // Eearly exit if OOM, IsValid should return false (TODO: different mechanism?)
                Device = null;
                BindingOffsets = null;
                Description = null;
                SrvStart = new CpuDescriptorHandle();
                SamplerStart = new CpuDescriptorHandle();
                return;
            }

            Device = graphicsDevice;
            BindingOffsets = desc.BindingOffsets;
            Description = desc;

            // Store start CpuDescriptorHandle
            SrvStart = desc.SrvCount > 0 ? (pool.SrvStart + graphicsDevice.SrvHandleIncrementSize * pool.SrvOffset) : new CpuDescriptorHandle();
            SamplerStart = desc.SamplerCount > 0 ? (pool.SamplerStart + graphicsDevice.SamplerHandleIncrementSize * pool.SamplerOffset) : new CpuDescriptorHandle();

            // Allocation is done, bump offsets
            // TODO D3D12 thread safety?
            pool.SrvOffset += desc.SrvCount;
            pool.SamplerOffset += desc.SamplerCount;
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:26,代码来源:DescriptorSet.Direct3D12.cs

示例6: UpdateShaders

        /// <summary>
        /// Polls the shader generator if the shader code has changed and has to be reloaded
        /// </summary>
        /// <param name="graphicsDevice">The current <see cref="GraphicsDevice"/></param>
        private void UpdateShaders(GraphicsDevice graphicsDevice)
        {
            // TODO Part of the graphics improvement XK-3052
            // Don't do this every frame, we have to propagate changes better
            if (--shadersUpdateCounter > 0)
                return;
            shadersUpdateCounter = 10;

            if (ComputeColor != null)
            {
                if (ComputeColor.HasChanged)
                {
                    var shaderGeneratorContext = new ShaderGeneratorContext(graphicsDevice)
                    {
                        Parameters = Parameters,
                        ColorSpace = graphicsDevice.ColorSpace
                    };

                    shaderSource = ComputeColor.GenerateShaderSource(shaderGeneratorContext, new MaterialComputeColorKeys(ParticleBaseKeys.EmissiveMap, ParticleBaseKeys.EmissiveValue, Color.White));

                    if (Parameters.Get(ParticleBaseKeys.BaseColor)?.Equals(shaderSource) ?? false)
                    {
                        shaderSource = Parameters.Get(ParticleBaseKeys.BaseColor);
                    }
                    else
                    {
                        Parameters.Set(ParticleBaseKeys.BaseColor, shaderSource);
                    }

                    HasVertexLayoutChanged = true;
                }
            }
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:37,代码来源:ParticleMaterialComputeColor.cs

示例7: EffectParameterUpdaterLayout

        public EffectParameterUpdaterLayout(GraphicsDevice graphicsDevice, Effect effect, DescriptorSetLayoutBuilder[] layouts)
        {
            Layouts = layouts;

            // Process constant buffers
            ResourceGroupLayouts = new ResourceGroupLayout[layouts.Length];
            for (int layoutIndex = 0; layoutIndex < layouts.Length; layoutIndex++)
            {
                var layout = layouts[layoutIndex];
                if (layout == null)
                    continue;

                ParameterCollectionLayout.ProcessResources(layout);

                EffectConstantBufferDescription cbuffer = null;

                for (int entryIndex = 0; entryIndex < layout.Entries.Count; ++entryIndex)
                {
                    var layoutEntry = layout.Entries[entryIndex];
                    if (layoutEntry.Class == EffectParameterClass.ConstantBuffer)
                    {
                        // For now we assume first cbuffer will be the main one
                        if (cbuffer == null)
                        {
                            cbuffer = effect.Bytecode.Reflection.ConstantBuffers.First(x => x.Name == layoutEntry.Key.Name);
                            ParameterCollectionLayout.ProcessConstantBuffer(cbuffer);
                        }
                    }
                }

                var resourceGroupDescription = new ResourceGroupDescription(layout, cbuffer);

                ResourceGroupLayouts[layoutIndex] = ResourceGroupLayout.New(graphicsDevice, resourceGroupDescription, effect.Bytecode);
            }
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:35,代码来源:EffectParameterUpdaterLayout.cs

示例8: DepthStencilState

        /// <summary>
        /// Initializes a new instance of the <see cref="DepthStencilState"/> class.
        /// </summary>
        /// <param name="depthEnable">if set to <c>true</c> [depth enable].</param>
        /// <param name="depthWriteEnable">if set to <c>true</c> [depth write enable].</param>
        /// <param name="name">The name.</param>
        private DepthStencilState(GraphicsDevice device, DepthStencilStateDescription depthStencilStateDescription)
            : base(device)
        {
            Description = depthStencilStateDescription;

            CreateNativeDeviceChild();
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:13,代码来源:DepthStencilState.Direct3D.cs

示例9: DepthStencilBuffer

        internal DepthStencilBuffer(GraphicsDevice device, Texture2D depthTexture, bool isReadOnly) : base(device)
        {
            DescriptionInternal = depthTexture.Description;
            depthTexture.AddReferenceInternal();
            Texture = depthTexture;

            resourceId = Texture.ResourceId;

            if (Description.Format == PixelFormat.D24_UNorm_S8_UInt ||
                Description.Format == PixelFormat.D32_Float_S8X24_UInt)
            {
                IsDepthBuffer = true;
                IsStencilBuffer = true;
            }
            else if (Description.Format == PixelFormat.D32_Float || 
                     Description.Format == PixelFormat.D16_UNorm)
            {
                IsDepthBuffer = true;
                IsStencilBuffer = false;
            }
            else 
                throw new NotSupportedException("The provided depth stencil format is currently not supported"); // implement composition for other formats


#if !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            if (isReadOnly)
            {
                if (device.versionMajor < 4)
                {
                    needReadOnlySynchronization = true;
                    throw new NotImplementedException();
                }
            }
#endif
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:35,代码来源:DepthStencilBuffer.OpenGL.cs

示例10: BlendState

        internal BlendState(GraphicsDevice device, BlendStateDescription blendStateDescription) : base(device)
        {
            Description = blendStateDescription;

            for (int i = 1; i < Description.RenderTargets.Length; ++i)
            {
                if (Description.RenderTargets[i].BlendEnable || Description.RenderTargets[i].ColorWriteChannels != ColorWriteChannels.All)
                    throw new NotSupportedException();
            }

            blendEnable = Description.RenderTargets[0].BlendEnable;

            blendEquationModeColor = ToOpenGL(Description.RenderTargets[0].ColorBlendFunction);
            blendEquationModeAlpha = ToOpenGL(Description.RenderTargets[0].AlphaBlendFunction);
            blendFactorSrcColor = ToOpenGL(Description.RenderTargets[0].ColorSourceBlend);
            blendFactorSrcAlpha = ToOpenGL(Description.RenderTargets[0].AlphaSourceBlend);
            blendFactorDestColor = (BlendingFactorDest)ToOpenGL(Description.RenderTargets[0].ColorDestinationBlend);
            blendFactorDestAlpha = (BlendingFactorDest)ToOpenGL(Description.RenderTargets[0].AlphaDestinationBlend);
            EnabledColors[0] = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Red  ) != 0;
            EnabledColors[1] = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Green) != 0;
            EnabledColors[2] = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Blue ) != 0;
            EnabledColors[3] = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Alpha) != 0;

            blendEquationHash = (uint)Description.RenderTargets[0].ColorBlendFunction
                             | ((uint)Description.RenderTargets[0].AlphaBlendFunction << 8);

            blendFuncHash = (uint)Description.RenderTargets[0].ColorSourceBlend
                         | ((uint)Description.RenderTargets[0].AlphaSourceBlend << 8)
                         | ((uint)Description.RenderTargets[0].ColorDestinationBlend << 16)
                         | ((uint)Description.RenderTargets[0].AlphaDestinationBlend << 24);
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:31,代码来源:BlendState.OpenGL.cs

示例11: SceneRenderer

        public SceneRenderer(GameSettingsAsset gameSettings)
        {
            if (gameSettings == null) throw new ArgumentNullException(nameof(gameSettings));

            // Initialize services
            Services = new ServiceRegistry();
            ContentManager = new ContentManager(Services);

            var renderingSettings = gameSettings.Get<RenderingSettings>();
            GraphicsDevice = GraphicsDevice.New(DeviceCreationFlags.None, new[] { renderingSettings.DefaultGraphicsProfile });

            var graphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);
            EffectSystem = new EffectSystem(Services);
            GraphicsContext = new GraphicsContext(GraphicsDevice);
            Services.AddService(typeof(GraphicsContext), GraphicsContext);

            SceneSystem = new SceneSystem(Services);

            // Create game systems
            GameSystems = new GameSystemCollection(Services);
            GameSystems.Add(new GameFontSystem(Services));
            GameSystems.Add(new UISystem(Services));
            GameSystems.Add(EffectSystem);
            GameSystems.Add(SceneSystem);
            GameSystems.Initialize();

            // Fake presenter
            // TODO GRAPHICS REFACTOR: This is needed be for render stage setup
            GraphicsDevice.Presenter = new RenderTargetGraphicsPresenter(GraphicsDevice,
                Texture.New2D(GraphicsDevice, renderingSettings.DefaultBackBufferWidth, renderingSettings.DefaultBackBufferHeight,
                    renderingSettings.ColorSpace == ColorSpace.Linear ? PixelFormat.R8G8B8A8_UNorm_SRgb : PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget),
                PixelFormat.D24_UNorm_S8_UInt);

            SceneSystem.MainRenderFrame = RenderFrame.FromTexture(GraphicsDevice.Presenter.BackBuffer, GraphicsDevice.Presenter.DepthStencilBuffer);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:35,代码来源:SceneRenderer.cs

示例12: Compile

        public void Compile(GraphicsDevice graphicsDevice, EffectDescriptorSetReflection descriptorSetLayouts, EffectBytecode effectBytecode)
        {
            resourceGroupBindings = new ResourceGroupBinding[descriptorSetLayouts.Layouts.Count];
            for (int setIndex = 0; setIndex < descriptorSetLayouts.Layouts.Count; setIndex++)
            {
                var layout = descriptorSetLayouts.Layouts[setIndex].Layout;
                if (layout == null)
                {
                    resourceGroupBindings[setIndex] = new ResourceGroupBinding { ConstantBufferSlot = -1 };
                    continue;
                }

                var resourceGroupBinding = new ResourceGroupBinding();

                for (int resourceIndex = 0; resourceIndex < layout.Entries.Count; resourceIndex++)
                {
                    var layoutEntry = layout.Entries[resourceIndex];

                    if (layoutEntry.Class == EffectParameterClass.ConstantBuffer)
                    {
                        var constantBuffer = effectBytecode.Reflection.ConstantBuffers.First(x => x.Name == layoutEntry.Key.Name);
                        resourceGroupBinding.ConstantBufferSlot = resourceIndex;
                        resourceGroupBinding.ConstantBufferPreallocated = Buffer.Constant.New(graphicsDevice, constantBuffer.Size);
                    }
                }

                resourceGroupBindings[setIndex] = resourceGroupBinding;
            }
        }
开发者ID:cg123,项目名称:xenko,代码行数:29,代码来源:ResourceGroupBufferUploader.cs

示例13: EffectProgram

 private EffectProgram(GraphicsDevice device, EffectBytecode bytecode)
     : base(device)
 {
     effectBytecode = bytecode;
     Reflection = effectBytecode.Reflection;
     CreateShaders();
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:7,代码来源:EffectProgram.Direct3D.cs

示例14: LightShadowProcessorDefaultBudget

 public LightShadowProcessorDefaultBudget(GraphicsDevice device, bool manageShadows)
     : base(device, manageShadows)
 {
     // Fixed budget of textures
     AddShadowMapTexture(new ShadowMapTexture(GraphicsDevice, LightShadowMapFilterType.Nearest, 2048), LightShadowMapFilterType.Nearest);
     AddShadowMapTexture(new ShadowMapTexture(GraphicsDevice, LightShadowMapFilterType.Variance, 2048), LightShadowMapFilterType.Variance);
 }
开发者ID:cg123,项目名称:xenko,代码行数:7,代码来源:LightShadowProcessorDefaultBudget.cs

示例15: BlendStateFactory

        /// <summary>
        /// Initializes a new instance of the <see cref="BlendStateFactory"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        internal BlendStateFactory(GraphicsDevice device)
        {
            var blendDescription = new BlendStateDescription(Blend.One, Blend.Zero);
            blendDescription.SetDefaults();
            Default = BlendState.New(device, blendDescription).DisposeBy(device);
            Default.Name = "Default";

            Additive = BlendState.New(device, new BlendStateDescription(Blend.SourceAlpha, Blend.One)).DisposeBy(device);
            Additive.Name = "Additive";

            AlphaBlend = BlendState.New(device, new BlendStateDescription(Blend.One, Blend.InverseSourceAlpha)).DisposeBy(device);
            AlphaBlend.Name = "AlphaBlend";

            NonPremultiplied = BlendState.New(device, new BlendStateDescription(Blend.SourceAlpha, Blend.InverseSourceAlpha)).DisposeBy(device);
            NonPremultiplied.Name = "NonPremultiplied";

            Opaque = BlendState.New(device, new BlendStateDescription(Blend.One, Blend.Zero)).DisposeBy(device);
            Opaque.Name = "Opaque";

            var colorDisabledDescription = new BlendStateDescription();
            colorDisabledDescription.SetDefaults();
            colorDisabledDescription.RenderTargets[0].ColorWriteChannels = ColorWriteChannels.None;
            ColorDisabled = BlendState.New(device, colorDisabledDescription).DisposeBy(device);
            ColorDisabled.Name = "ColorDisabled";
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:29,代码来源:BlendStateFactory.cs


注:本文中的SiliconStudio.Xenko.Graphics.GraphicsDevice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。