internal static void DrawEnvProbe() { int colorMipmap = 0; IUavArrayTexture colorTexture = MyManagers.EnvironmentProbe.Cubemap; DrawSrvTexture(256 * 2, 256 * 1, 256, 256, colorTexture.SubresourceSrv(0, colorMipmap)); DrawSrvTexture(256 * 0, 256 * 1, 256, 256, colorTexture.SubresourceSrv(1, colorMipmap)); DrawSrvTexture(256 * 1, 256 * 0, 256, 256, colorTexture.SubresourceSrv(2, colorMipmap)); DrawSrvTexture(256 * 1, 256 * 2, 256, 256, colorTexture.SubresourceSrv(3, colorMipmap)); DrawSrvTexture(256 * 1, 256 * 1, 256, 256, colorTexture.SubresourceSrv(4, colorMipmap)); DrawSrvTexture(256 * 3, 256 * 1, 256, 256, colorTexture.SubresourceSrv(5, colorMipmap)); }
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); }
internal static void BuildMipmaps(IUavArrayTexture texture) { RC.ComputeShader.Set(m_mipmap); var mipLevels = texture.MipmapLevels; var side = texture.Size.X; for (int j = 0; j < 6; ++j) { var mipSide = side; for (int i = 1; i < mipLevels; ++i) { RC.ComputeShader.SetUav(0, texture.SubresourceUav(j, i), -1); RC.ComputeShader.SetSrv(0, texture.SubresourceSrv(j, i - 1)); RC.Dispatch((mipSide + 7) / 8, (mipSide + 7) / 8, 1); RC.ComputeShader.SetSrv(0, null); mipSide >>= 1; } } RC.ComputeShader.SetUav(0, null, -1); RC.ComputeShader.Set(null); }
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); }