Ejemplo n.º 1
0
        internal static void Blend(RwTexId dst, RwTexId src0, RwTexId src1, float blendWeight)
        {
            //MyImmediateRC.RC.Context.CopyResource(src1.Resource, dst.Resource);

            RC.DeviceContext.ComputeShader.Set(m_blend);

            var mipLevels = dst.Description2d.MipLevels;
            var side      = dst.Description2d.Width;

            RC.CSSetCB(1, MyCommon.GetObjectCB(32));

            RC.DeviceContext.ComputeShader.SetSamplers(0, MyRender11.StandardSamplers);

            for (int j = 0; j < 6; ++j)
            {
                var mipSide = side;
                for (int i = 0; i < mipLevels; ++i)
                {
                    uint samplesNum = i == 0 ? 1u : 64u;

                    var blendConstantData = new MyBlendData {
                        field0 = 0, field1 = 0, MipSide = (uint)mipSide, field2 = 0, W = blendWeight
                    };
                    var mapping = MyMapping.MapDiscard(MyCommon.GetObjectCB(32));
                    mapping.WriteAndPosition(ref blendConstantData);
                    mapping.Unmap();

                    RC.DeviceContext.ComputeShader.SetShaderResource(0, src0.SubresourceSrv(j, i));
                    RC.DeviceContext.ComputeShader.SetShaderResource(1, src1.SubresourceSrv(j, i));

                    // The single parameter version of SetUnorderedAccessView allocates
                    ComputeShaderId.TmpUav[0] = dst.SubresourceUav(j, i);
                    RC.DeviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount);
                    RC.DeviceContext.Dispatch((mipSide + 7) / 8, (mipSide + 7) / 8, 1);

                    mipSide >>= 1;
                }
            }

            ComputeShaderId.TmpUav[0] = null;
            RC.DeviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount);
            RC.DeviceContext.ComputeShader.SetShaderResource(0, null);
            RC.DeviceContext.ComputeShader.SetShaderResource(1, null);

            RC.DeviceContext.ComputeShader.Set(null);
        }
Ejemplo n.º 2
0
        internal static void Blend(IUavArrayTexture dst, IUavArrayTexture src0, IUavArrayTexture src1, float blendWeight)
        {
            //MyImmediateRC.RC.Context.CopyResource(src1.Resource, dst.Resource);

            RC.ComputeShader.Set(m_blend);

            var mipLevels = dst.MipmapLevels;
            var side      = dst.Size.X;

            RC.ComputeShader.SetConstantBuffer(1, MyCommon.GetObjectCB(32));

            RC.ComputeShader.SetSamplers(0, MySamplerStateManager.StandardSamplers);

            for (int j = 0; j < 6; ++j)
            {
                var mipSide = side;
                for (int i = 0; i < mipLevels; ++i)
                {
                    uint samplesNum = i == 0 ? 1u : 64u;

                    var blendConstantData = new MyBlendData {
                        field0 = 0, field1 = 0, MipSide = (uint)mipSide, field2 = 0, W = blendWeight
                    };
                    var mapping = MyMapping.MapDiscard(MyCommon.GetObjectCB(32));
                    mapping.WriteAndPosition(ref blendConstantData);
                    mapping.Unmap();

                    RC.ComputeShader.SetSrv(0, src0.SubresourceSrv(j, i));
                    RC.ComputeShader.SetSrv(1, src1.SubresourceSrv(j, i));

                    // The single parameter version of SetUnorderedAccessView allocates
                    RC.ComputeShader.SetUav(0, dst.SubresourceUav(j, i));
                    RC.Dispatch((mipSide + 7) / 8, (mipSide + 7) / 8, 1);

                    mipSide >>= 1;
                }
            }

            RC.ComputeShader.SetUav(0, null);
            RC.ComputeShader.SetSrv(0, null);
            RC.ComputeShader.SetSrv(1, null);

            RC.ComputeShader.Set(null);
        }
Ejemplo n.º 3
0
        internal static void Blend(IUavArrayTexture dst, IUavArrayTexture src0, IUavArrayTexture src1, float blendWeight)
        {
            //MyImmediateRC.RC.Context.CopyResource(src1.Resource, dst.Resource);

            RC.ComputeShader.Set(m_blend);

            var mipLevels = dst.MipmapLevels;
            var side = dst.Size.X;

            RC.ComputeShader.SetConstantBuffer(1, MyCommon.GetObjectCB(32));

            RC.ComputeShader.SetSamplers(0, MySamplerStateManager.StandardSamplers);

            for (int j = 0; j < 6; ++j)
            {
                var mipSide = side;
                for (int i = 0; i < mipLevels; ++i)
                {
                    uint samplesNum = i == 0 ? 1u : 64u;

                    var blendConstantData = new MyBlendData { field0 = 0, field1 = 0, MipSide = (uint)mipSide, field2 = 0, W = blendWeight };
                    var mapping = MyMapping.MapDiscard(MyCommon.GetObjectCB(32));
                    mapping.WriteAndPosition(ref blendConstantData);
                    mapping.Unmap();

                    RC.ComputeShader.SetSrv(0, src0.SubresourceSrv(j, i));
                    RC.ComputeShader.SetSrv(1, src1.SubresourceSrv(j, i));

                    // The single parameter version of SetUnorderedAccessView allocates
                    RC.ComputeShader.SetUav(0, dst.SubresourceUav(j, i), -1);
                    RC.Dispatch((mipSide + 7) / 8, (mipSide + 7) / 8, 1);

                    mipSide >>= 1;
                }
            }

            RC.ComputeShader.SetUav(0, null);
            RC.ComputeShader.SetSrv(0, null);
            RC.ComputeShader.SetSrv(1, null);

            RC.ComputeShader.Set(null);
        }
        internal static void Blend(RwTexId dst, RwTexId src0, RwTexId src1, float blendWeight)
        {
            //MyImmediateRC.RC.Context.CopyResource(src1.Resource, dst.Resource);

            RC.DeviceContext.ComputeShader.Set(m_blend);

            var mipLevels = dst.Description2d.MipLevels;
            var side = dst.Description2d.Width;

            RC.CSSetCB(1, MyCommon.GetObjectCB(32));

            RC.DeviceContext.ComputeShader.SetSamplers(0, MyRender11.StandardSamplers);

            for (int j = 0; j < 6; ++j)
            {
                var mipSide = side;
                for (int i = 0; i < mipLevels; ++i)
                {
                    uint samplesNum = i == 0 ? 1u : 64u;

                    var blendConstantData = new MyBlendData { field0 = 0, field1 = 0, MipSide = (uint)mipSide, field2 = 0, W = blendWeight };
                    var mapping = MyMapping.MapDiscard(MyCommon.GetObjectCB(32));
                    mapping.WriteAndPosition(ref blendConstantData);
                    mapping.Unmap();

                    RC.DeviceContext.ComputeShader.SetShaderResource(0, src0.SubresourceSrv(j, i));
                    RC.DeviceContext.ComputeShader.SetShaderResource(1, src1.SubresourceSrv(j, i));

                    // The single parameter version of SetUnorderedAccessView allocates
                    ComputeShaderId.TmpUav[0] = dst.SubresourceUav(j, i);
                    RC.DeviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount);
                    RC.DeviceContext.Dispatch((mipSide + 7) / 8, (mipSide + 7) / 8, 1);

                    mipSide >>= 1;
                }
            }

            ComputeShaderId.TmpUav[0] = null;
            RC.DeviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount);
            RC.DeviceContext.ComputeShader.SetShaderResource(0, null);
            RC.DeviceContext.ComputeShader.SetShaderResource(1, null);

            RC.DeviceContext.ComputeShader.Set(null);
        }