internal static void BuildMipmaps(RwTexId texture) { RC.DeviceContext.ComputeShader.Set(m_mipmap); var mipLevels = texture.Description2d.MipLevels; var side = texture.Description2d.Width; for (int j = 0; j < 6; ++j) { var mipSide = side; for (int i = 1; i < mipLevels; ++i) { ComputeShaderId.TmpUav[0] = texture.SubresourceUav(j, i); RC.DeviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount); RC.DeviceContext.ComputeShader.SetShaderResource(0, texture.SubresourceSrv(j, i - 1)); RC.DeviceContext.Dispatch((mipSide + 7) / 8, (mipSide + 7) / 8, 1); RC.DeviceContext.ComputeShader.SetShaderResource(0, null); mipSide >>= 1; } } ComputeShaderId.TmpUav[0] = null; RC.DeviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount); RC.DeviceContext.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); }
internal static void Blend(RwTexId dst, RwTexId src0, RwTexId src1, float w) { //MyImmediateRC.RC.Context.CopyResource(src1.Resource, dst.Resource); RC.Context.ComputeShader.Set(m_blend); var mipLevels = dst.Description2d.MipLevels; var side = dst.Description2d.Width; RC.CSSetCB(1, MyCommon.GetObjectCB(32)); RC.Context.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 mapping = MyMapping.MapDiscard(MyCommon.GetObjectCB(32)); mapping.stream.Write((uint)0); mapping.stream.Write((uint)0); mapping.stream.Write((uint)mipSide); mapping.stream.Write((uint)0); mapping.stream.Write(w); mapping.Unmap(); RC.Context.ComputeShader.SetShaderResources(0, src0.SubresourceSrv(j, i), src1.SubresourceSrv(j, i)); RC.Context.ComputeShader.SetUnorderedAccessView(0, dst.SubresourceUav(j, i)); RC.Context.Dispatch((mipSide + 7) / 8, (mipSide + 7) / 8, 1); mipSide >>= 1; } } RC.Context.ComputeShader.SetUnorderedAccessView(0, null); RC.Context.ComputeShader.SetShaderResources(0, null, null); RC.Context.ComputeShader.Set(null); }
internal void StepUpdateFiltering() { if (6 <= state && state < 12) { int faceId = state - 6; var matrix = CubeFaceViewMatrix(Vector3.Zero, faceId); MyEnvProbeProcessing.RunForwardPostprocess(workCubemap.SubresourceRtv(faceId), m_cubemapDepth.SubresourceSrv(faceId), ref matrix, MyAtmosphereRenderer.GetCurrentAtmosphereId()); MyEnvProbeProcessing.BuildMipmaps(workCubemap); MyEnvProbeProcessing.Prefilter(workCubemap, workCubemapPrefiltered); ++state; if (state == 12) { blendT0 = MyRender11.CurrentDrawTime; } return; } }