• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Graphics.GraphicsDevice类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: FromFileData

        /// <summary>
        /// Creates a texture from an image file data (png, dds, ...).
        /// </summary>
        /// <param name="graphicsDevice">The graphics device in which to create the texture</param>
        /// <param name="data">The image file data</param>
        /// <returns>The texture</returns>
        public static Texture FromFileData(GraphicsDevice graphicsDevice, byte[] data)
        {
            Texture result;

            var loadAsSRgb = graphicsDevice.ColorSpace == ColorSpace.Linear;

            using (var imageStream = new MemoryStream(data))
            {
                using (var image = Image.Load(imageStream, loadAsSRgb))
                {
                    result = Texture.New(graphicsDevice, image);
                }
            }

            result.Reload = graphicsResource =>
            {
                using (var imageStream = new MemoryStream(data))
                {
                    using (var image = Image.Load(imageStream, loadAsSRgb))
                    {
                        ((Texture)graphicsResource).Recreate(image.ToDataBox());
                    }
                }
            };

            return result;
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:33,代码来源:Texture.Extensions.cs


示例17: Shader

        private Shader(GraphicsDevice device, ShaderStage shaderStage, byte[] shaderStageBytecode)
            : base(device)
        {
            this.stage = shaderStage;

            var shaderStageGl = ConvertShaderStage(shaderStage);

            // Decode shader StageBytecode
            var binarySerializationReader = new BinarySerializationReader(new MemoryStream(shaderStageBytecode));
            var shaderBytecodeData = new OpenGLShaderBytecodeData();
            shaderBytecodeData.Serialize(binarySerializationReader, ArchiveMode.Deserialize);

            using (GraphicsDevice.UseOpenGLCreationContext())
            {
                resourceId = GL.CreateShader(shaderStageGl);

                if (shaderBytecodeData.IsBinary)
                {
                    GL.ShaderBinary(1, ref resourceId, (BinaryFormat)shaderBytecodeData.BinaryFormat, shaderBytecodeData.Binary, shaderBytecodeData.Binary.Length);
                }
                else
                {
                    GL.ShaderSource(resourceId, shaderBytecodeData.Source);
                    GL.CompileShader(resourceId);

                    var log = GL.GetShaderInfoLog(resourceId);

                    int compileStatus;
                    GL.GetShader(resourceId, ShaderParameter.CompileStatus, out compileStatus);

                    if (compileStatus != 1)
                        throw new InvalidOperationException(string.Format("Error while compiling GLSL shader: {0}", log));
                }
            }
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:35,代码来源:Shader.OpenGL.cs


示例18: New

        public static EffectDescriptorSetReflection New(GraphicsDevice graphicsDevice, EffectBytecode effectBytecode, List<string> effectDescriptorSetSlots, string defaultSetSlot)
        {
            // Find resource groups
            // TODO: We should precompute most of that at compile time in BytecodeReflection
            // just waiting for format to be more stable
            var descriptorSetLayouts = new EffectDescriptorSetReflection { DefaultSetSlot = defaultSetSlot };
            foreach (var effectDescriptorSetSlot in effectDescriptorSetSlots)
            {
                // Find all resources related to this slot name
                // NOTE: Ordering is mirrored by GLSL layout in Vulkan
                var descriptorSetLayoutBuilder = new DescriptorSetLayoutBuilder();
                bool hasBindings = false;
                foreach (var resourceBinding in effectBytecode.Reflection.ResourceBindings
                    .Where(x => x.ResourceGroup == effectDescriptorSetSlot || (effectDescriptorSetSlot == defaultSetSlot && (x.ResourceGroup == null || x.ResourceGroup == "Globals")))
                    .GroupBy(x => new { Key = x.KeyInfo.Key, Class = x.Class, Type = x.Type, SlotCount = x.SlotCount, LogicalGroup = x.LogicalGroup })
                    .OrderBy(x => x.Key.Class == EffectParameterClass.ConstantBuffer ? 0 : 1)) // Note: Putting cbuffer first for now
                {
                    SamplerState samplerState = null;
                    if (resourceBinding.Key.Class == EffectParameterClass.Sampler)
                    {
                        var matchingSamplerState = effectBytecode.Reflection.SamplerStates.FirstOrDefault(x => x.Key == resourceBinding.Key.Key);
                        if (matchingSamplerState != null)
                            samplerState = SamplerState.New(graphicsDevice, matchingSamplerState.Description);
                    }
                    hasBindings = true;

                    descriptorSetLayoutBuilder.AddBinding(resourceBinding.Key.Key, resourceBinding.Key.LogicalGroup, resourceBinding.Key.Class, resourceBinding.Key.Type, resourceBinding.Key.SlotCount, samplerState);
                }

                descriptorSetLayouts.AddLayout(effectDescriptorSetSlot, hasBindings ? descriptorSetLayoutBuilder : null);
            }

            return descriptorSetLayouts;
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:34,代码来源:EffectDescriptorSetReflection.cs


示例19: Shader

        private Shader(GraphicsDevice device, ShaderStage shaderStage, byte[] shaderBytecode)
            : base(device)
        {
            this.stage = shaderStage;

            switch (shaderStage)
            {
                case ShaderStage.Vertex:
                    NativeDeviceChild = new VertexShader(device.NativeDevice, shaderBytecode);
                    NativeInputSignature = shaderBytecode;
                    break;
                case ShaderStage.Hull:
                    NativeDeviceChild = new HullShader(device.NativeDevice, shaderBytecode);
                    break;
                case ShaderStage.Domain:
                    NativeDeviceChild = new DomainShader(device.NativeDevice, shaderBytecode);
                    break;
                case ShaderStage.Geometry:
                    NativeDeviceChild = new GeometryShader(device.NativeDevice, shaderBytecode);
                    break;
                case ShaderStage.Pixel:
                    NativeDeviceChild = new PixelShader(device.NativeDevice, shaderBytecode);
                    break;
                case ShaderStage.Compute:
                    NativeDeviceChild = new ComputeShader(device.NativeDevice, shaderBytecode);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("shaderStage");
            }
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:30,代码来源:Shader.Direct3D.cs


示例20: UpdateEffect

        /// <summary>
        /// Compiles or recompiles the effect if necesssary.
        /// </summary>
        /// <param name="graphicsDevice"></param>
        /// <returns>True if the effect was recompiled, false otherwise.</returns>
        public bool UpdateEffect(GraphicsDevice graphicsDevice)
        {
            if (permutationCounter != Parameters.PermutationCounter || (effect != null && effect.SourceChanged))
            {
                permutationCounter = Parameters.PermutationCounter;

                var oldEffect = effect;
                ChooseEffect(graphicsDevice);

                // Early exit: same effect, and already initialized
                if (oldEffect == effect && descriptorReflection != null)
                    return false;

                // Update reflection and rearrange buffers/resources
                var layoutNames = effect.Bytecode.Reflection.ResourceBindings.Select(x => x.ResourceGroup ?? "Globals").Distinct().ToList();
                descriptorReflection = EffectDescriptorSetReflection.New(graphicsDevice, effect.Bytecode, layoutNames, "Globals");

                RootSignature = RootSignature.New(graphicsDevice, descriptorReflection);

                bufferUploader.Compile(graphicsDevice, descriptorReflection, effect.Bytecode);

                // Create parameter updater
                var layouts = new DescriptorSetLayoutBuilder[descriptorReflection.Layouts.Count];
                for (int i = 0; i < descriptorReflection.Layouts.Count; ++i)
                    layouts[i] = descriptorReflection.Layouts[i].Layout;
                var parameterUpdaterLayout = new EffectParameterUpdaterLayout(graphicsDevice, effect, layouts);
                parameterUpdater = new EffectParameterUpdater(parameterUpdaterLayout, Parameters);

                descriptorSets = new DescriptorSet[parameterUpdater.ResourceGroups.Length];

                return true;
            }

            return false;
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:40,代码来源:EffectInstance.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Graphics.Texture类代码示例发布时间:2022-05-26
下一篇:
C# Games.GameTime类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap