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


C# IDeviceContext.Dispatch方法代码示例

本文整理汇总了C#中IDeviceContext.Dispatch方法的典型用法代码示例。如果您正苦于以下问题:C# IDeviceContext.Dispatch方法的具体用法?C# IDeviceContext.Dispatch怎么用?C# IDeviceContext.Dispatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDeviceContext的用法示例。


在下文中一共展示了IDeviceContext.Dispatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateLossy

        public unsafe void CalculateLossy(IDeviceContext context, ITexture2D target, ITexture2D previous, ITexture2D temporalDiff, int mostDetailedMip)
        {
            var mipInfo = new MipInfo { MipLevel = mostDetailedMip, CoordDivisor = 1 << mostDetailedMip };

            var map = context.Map(mipInfoBuffer, 0, MapType.WriteDiscard, MapFlags.None);
            *(MipInfo*)map.Data = mipInfo;
            context.Unmap(mipInfoBuffer, 0);

            // todo: try doing everything using MostDetailedMip of SRV

            context.ShaderForDispatching = computeShader;
            context.ComputeStage.UniformBuffers[0] = mipInfoBuffer;
            context.ComputeStage.ShaderResources[0] = previous.ViewAsShaderResource(formatId, 0, previous.MipLevels);
            context.ComputeStage.ShaderResources[1] = temporalDiff.ViewAsShaderResource(formatId, 0, temporalDiff.MipLevels);
            context.ComputeStage.UnorderedAccessResources[0] = target.ViewAsUnorderedAccessResource(formatId, 0);

            context.Dispatch(RavcMath.DivideAndCeil(target.Width, 16), RavcMath.DivideAndCeil(target.Height, 16), 1);
        }
开发者ID:Zulkir,项目名称:RAVC,代码行数:18,代码来源:GpuLossyCalculator.cs

示例2: CalculateDiff

        public void CalculateDiff(IDeviceContext context, ITexture2D target, ITexture2D source, int mostDetailedMip)
        {
            context.ShaderForDispatching = computeShader;

            for (int i = EncodingConstants.SmallestMip; i >= mostDetailedMip; i--)
            {
                var srv = source.ViewAsShaderResource(formatId, i, i == EncodingConstants.SmallestMip ? 1 : 2);
                var uav = target.ViewAsUnorderedAccessResource(formatId, i);

                context.ComputeStage.ShaderResources[0] = srv;
                context.ComputeStage.UnorderedAccessResources[0] = uav;

                context.Dispatch(RavcMath.DivideAndCeil(target.Width >> i, 16), RavcMath.DivideAndCeil(target.Height >> i, 16), 1);

                context.ComputeStage.ShaderResources[0] = null;
                ((CDeviceContext)context).D3DDeviceContext.ComputeShader.SetShaderResource(0, null);
            }

            context.ComputeStage.UnorderedAccessResources[0] = null;
            ((CDeviceContext)context).D3DDeviceContext.ComputeShader.SetUnorderedAccessView(0, null);
        }
开发者ID:Zulkir,项目名称:RAVC,代码行数:21,代码来源:GpuSpatialDiffCalculator.cs

示例3: CalculateDiff

        public unsafe void CalculateDiff(IDeviceContext context, ITexture2D target, ITexture2D current, ITexture2D parentTexture, int colorDiffThreshold)
        {
            context.ShaderForDispatching = computeShader;

            var map = context.Map(frameInfoBuffer, 0, MapType.WriteDiscard, MapFlags.None);
            *(Vector4*)map.Data = new Vector4(colorDiffThreshold, 0, 0, 0);
            context.Unmap(frameInfoBuffer, 0);

            context.ComputeStage.UniformBuffers[0] = frameInfoBuffer;

            for (int i = 0; i < EncodingConstants.MipLevels; i++)
            {
                var uav = target.ViewAsUnorderedAccessResource(formatId, i);
                var currentSrv = current.ViewAsShaderResource(formatId, i, 1);
                var parentSrv = parentTexture.ViewAsShaderResource(formatId, i, 1);

                context.ComputeStage.UnorderedAccessResources[0] = uav;
                context.ComputeStage.ShaderResources[0] = currentSrv;
                context.ComputeStage.ShaderResources[1] = parentSrv;

                context.Dispatch(RavcMath.DivideAndCeil(target.Width >> i, 16), RavcMath.DivideAndCeil(target.Height >> i, 16), 1);
            }
        }
开发者ID:Zulkir,项目名称:RAVC,代码行数:23,代码来源:GpuTemporalDiffCalculator.cs

示例4: SwapBgraToRgba

        public void SwapBgraToRgba(IDeviceContext context, ITexture2D target, ITexture2D texture)
        {
            var uav = target.ViewAsUnorderedAccessResource(rgbaFormat, 0);
            var srv = texture.ViewAsShaderResource(bgraFormat, 0, 1);

            context.ShaderForDispatching = computeShader;
            context.ComputeStage.ShaderResources[0] = srv;
            context.ComputeStage.UnorderedAccessResources[0] = uav;

            context.Dispatch(RavcMath.DivideAndCeil(target.Width, 16), RavcMath.DivideAndCeil(target.Height, 16), 1);
        }
开发者ID:Zulkir,项目名称:RAVC,代码行数:11,代码来源:GpuChannelSwapper.cs

示例5: GenerateMips

        public void GenerateMips(IDeviceContext context, ITexture2D target, int mipLevels)
        {
            for (int i = 1; i < mipLevels; i++)
            {
                var srv = target.ViewAsShaderResource(formatId, i - 1, 1);
                var uav = target.ViewAsUnorderedAccessResource(formatId, i);

                context.ShaderForDispatching = computeShader;

                context.ComputeStage.ShaderResources[0] = srv;
                context.ComputeStage.UnorderedAccessResources[0] = uav;

                context.Dispatch(RavcMath.DivideAndCeil(target.Width >> i, 16), RavcMath.DivideAndCeil(target.Height >> i, 16), 1);
            }
        }
开发者ID:Zulkir,项目名称:RAVC,代码行数:15,代码来源:GpuMipGenerator.cs


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