internal static void SetupTargets(IUavTexture accumTarget, IUavTexture coverageTarget, bool clear) { if (MyRender11.DebugOverrides.OIT) SetupOIT(accumTarget, coverageTarget, clear); else SetupStandard(); }
void DisposeTexture(MyBorrowedUavTexture uav) { IUavTexture uavTexture = uav.UavTexture; MyManagers.RwTextures.DisposeTex(ref uavTexture); MyBorrowedTextureKey key = uav.Key; m_dictionaryUavTextures[key].Remove(uav); m_objectPoolUav.Deallocate(uav); }
internal static void SetupTargets(IUavTexture accumTarget, IUavTexture coverageTarget, bool clear) { if (MyRender11.DebugOverrides.OIT) { SetupOIT(accumTarget, coverageTarget, clear); } else { SetupStandard(); } }
internal static void RemoveAtmosphere(uint ID) { m_atmospheres.Remove(ID); if (AtmosphereLUT.ContainsKey(ID)) { IUavTexture uav = AtmosphereLUT[ID].TransmittanceLut; MyManagers.RwTextures.DisposeTex(ref uav); } AtmosphereLUT.Remove(ID); }
static void SetupOIT(IUavTexture accumTarget, IUavTexture coverageTarget, bool clear) { RC.SetScreenViewport(); RC.SetBlendState(MyBlendStateManager.BlendWeightedTransparency); if (clear) { RC.ClearRtv(accumTarget, new SharpDX.Color4(0, 0, 0, 0)); RC.ClearRtv(coverageTarget, new SharpDX.Color4(1, 1, 1, 1));//0,0,0,0)); } RC.SetRtvs(MyGBuffer.Main.ResolvedDepthStencil, MyDepthStencilAccess.ReadOnly, accumTarget, coverageTarget); }
static void SetupOIT(IUavTexture accumTarget, IUavTexture coverageTarget, bool clear) { RC.SetScreenViewport(); RC.SetBlendState(MyBlendStateManager.BlendWeightedTransparency); if (clear) { RC.ClearRtv(accumTarget, new SharpDX.Color4(0, 0, 0, 0)); RC.ClearRtv(coverageTarget, new SharpDX.Color4(1, 1, 1, 1));//0,0,0,0)); } RC.SetRtvs(MyGBuffer.Main.ResolvedDepthStencil, MyDepthStencilAccess.ReadOnly, accumTarget, coverageTarget); }
internal static void Init() { var threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS) }; m_initialShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Init.hlsl", threadMacros); m_sumShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Sum.hlsl", threadMacros); threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS), new ShaderMacro("_FINAL", null) }; m_finalShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Sum.hlsl", threadMacros); m_skipShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Skip.hlsl"); m_prevLum = MyManagers.RwTextures.CreateUav("MyLuminanceAverage.PrevLum", 1, 1, Format.R32G32_Float); }
internal static void Init() { var threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS) }; m_initialShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Init.hlsl", threadMacros); m_sumShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Sum.hlsl", threadMacros); threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS), new ShaderMacro("_FINAL", null) }; m_finalShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Sum.hlsl", threadMacros); m_skipShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Skip.hlsl"); m_prevLum = MyManagers.RwTextures.CreateUav("MyLuminanceAverage.PrevLum", 1, 1, Format.R32G32_Float); }
public static void Deselect() { m_selRtvTexture = null; m_selUavTexture = null; if (m_selBorrowedRtvTexture != null) { m_selBorrowedRtvTexture.Release(); m_selBorrowedRtvTexture = null; } if (m_selBorrowedUavTexture != null) { m_selBorrowedUavTexture.Release(); m_selBorrowedUavTexture = null; } }
public static void Deselect() { m_selRtvTexture = null; m_selUavTexture = null; if (m_selBorrowedRtvTexture != null) { m_selBorrowedRtvTexture.Release(); m_selBorrowedRtvTexture = null; } if (m_selBorrowedUavTexture != null) { m_selBorrowedUavTexture.Release(); m_selBorrowedUavTexture = null; } }
static void SetupOIT(IUavTexture accumTarget, IUavTexture coverageTarget, bool clear) { RC.SetScreenViewport(); RC.SetBlendState(MyBlendStateManager.BlendWeightedTransparency); if (clear) { RC.ClearRtv(accumTarget, new SharpDX.Color4(0, 0, 0, 0)); RC.ClearRtv(coverageTarget, new SharpDX.Color4(1, 1, 1, 1));//0,0,0,0)); } if (MyRender11.MultisamplingEnabled) RC.SetRtvs(MyScreenDependants.m_resolvedDepth, MyDepthStencilAccess.ReadOnly, accumTarget, coverageTarget); else RC.SetRtvs(MyGBuffer.Main.DepthStencil, MyDepthStencilAccess.ReadOnly, accumTarget, coverageTarget); }
public void DisposeTex(ref IUavTexture texture) { if (texture == null) { return; } MyUavTexture textureInternal = (MyUavTexture)texture; if (m_isDeviceInit) { textureInternal.OnDeviceEnd(); } m_uavTextures.Deallocate(textureInternal); texture = null; }
static void SetupOIT(IUavTexture accumTarget, IUavTexture coverageTarget, bool clear) { RC.SetScreenViewport(); RC.SetBlendState(MyBlendStateManager.BlendWeightedTransparency); if (clear) { RC.ClearRtv(accumTarget, new SharpDX.Color4(0, 0, 0, 0)); RC.ClearRtv(coverageTarget, new SharpDX.Color4(1, 1, 1, 1));//0,0,0,0)); } if (MyRender11.MultisamplingEnabled) { RC.SetRtvs(MyScreenDependants.m_resolvedDepth, MyDepthStencilAccess.ReadOnly, accumTarget, coverageTarget); } else { RC.SetRtvs(MyGBuffer.Main.DepthStencil, MyDepthStencilAccess.ReadOnly, accumTarget, coverageTarget); } }
static void DisplayOverlappingHeatMap(IUavTexture accumTarget, IUavTexture coverageTarget, bool useGrayscale) { IBorrowedRtvTexture heatMap = MyManagers.RwTexturesPool.BorrowRtv("MyTransparentRendering.HeatMap", Format.R8G8B8A8_UNorm); RC.ClearRtv(heatMap, default(RawColor4)); RC.SetRtv(heatMap); RC.PixelShader.SetSrv(0, accumTarget); RC.PixelShader.Set(useGrayscale ? m_psOverlappingHeatMapInGrayscale : m_psOverlappingHeatMap); RC.SetBlendState(MyBlendStateManager.BlendAdditive); RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil); MyScreenPass.DrawFullscreenQuad(); RC.PixelShader.Set(null); RC.PixelShader.SetSrv(0, null); RC.SetRtv(null); SetupOIT(accumTarget, coverageTarget, false); MyDebugTextureDisplay.Select(heatMap); heatMap.Release(); }
public static void Select(IUavTexture tex) { Deselect(); m_selUavTexture = tex; }
internal void GatherArray(IUavTexture postprocessTarget, ISrvBindable cascadeArray, MyProjectionInfo[] cascadeInfo, ConstantsBufferId cascadeConstantBuffer) { MyShadowsQuality shadowsQuality = MyRender11.RenderSettings.ShadowQuality.GetShadowsQuality(); if (!MyRender11.Settings.EnableShadows || !MyRender11.DebugOverrides.Shadows || shadowsQuality == MyShadowsQuality.DISABLED) { RC.ClearUav(postprocessTarget, new RawInt4()); return; } MarkCascadesInStencil(cascadeInfo); MyGpuProfiler.IC_BeginBlock("Cascades postprocess"); if (shadowsQuality == MyShadowsQuality.LOW) { RC.ComputeShader.Set(m_gatherCS_LD); } else if (shadowsQuality == MyShadowsQuality.MEDIUM) { RC.ComputeShader.Set(m_gatherCS_MD); } else if (shadowsQuality == MyShadowsQuality.HIGH) { RC.ComputeShader.Set(m_gatherCS_HD); } RC.ComputeShader.SetUav(0, postprocessTarget); RC.ComputeShader.SetSrv(0, MyRender11.MultisamplingEnabled ? MyScreenDependants.m_resolvedDepth.SrvDepth : MyGBuffer.Main.DepthStencil.SrvDepth); RC.ComputeShader.SetSrv(1, MyGBuffer.Main.DepthStencil.SrvStencil); RC.ComputeShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MySamplerStateManager.Shadowmap); if (!MyStereoRender.Enable) { RC.ComputeShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); } else { MyStereoRender.CSBindRawCB_FrameConstants(RC); } //RC.ComputeShader.SetConstantBuffer(4, MyManagers.Shadows.GetCsmConstantBufferOldOne()); RC.ComputeShader.SetConstantBuffer(4, cascadeConstantBuffer); RC.ComputeShader.SetSrv(MyCommon.CASCADES_SM_SLOT, cascadeArray); //RC.ComputeShader.SetSrv(MyCommon.CASCADES_SM_SLOT, MyManagers.Shadow.GetCsmForGbuffer()); Vector2I threadGroups = GetThreadGroupCount(); RC.Dispatch(threadGroups.X, threadGroups.Y, 1); RC.ComputeShader.SetUav(0, null); RC.ComputeShader.SetSrv(0, null); RC.ComputeShader.SetSrv(1, null); if (shadowsQuality == MyShadowsQuality.HIGH && MyShadowCascades.Settings.Data.EnableShadowBlur) { IBorrowedUavTexture helper = MyManagers.RwTexturesPool.BorrowUav("MyShadowCascadesPostProcess.Helper", Format.R8_UNorm); MyBlur.Run(postprocessTarget, helper, postprocessTarget, depthStencilState: MyDepthStencilStateManager.IgnoreDepthStencil, depthDiscardThreshold: 0.2f, clearColor: Color4.White); helper.Release(); } MyGpuProfiler.IC_EndBlock(); }
public void DisposeTex(ref IUavTexture texture) { if (texture == null) return; MyUavTexture textureInternal = (MyUavTexture) texture; if (m_isDeviceInit) textureInternal.OnDeviceEnd(); m_uavTextures.Deallocate(textureInternal); texture = null; }
static void DisplayOverlappingHeatMap(IUavTexture accumTarget, IUavTexture coverageTarget, bool useGrayscale) { IBorrowedRtvTexture heatMap = MyManagers.RwTexturesPool.BorrowRtv("MyTransparentRendering.HeatMap", Format.R8G8B8A8_UNorm); RC.ClearRtv(heatMap, default(RawColor4)); RC.SetRtv(heatMap); RC.PixelShader.SetSrv(0, accumTarget); RC.PixelShader.Set(useGrayscale ? m_psOverlappingHeatMapInGrayscale : m_psOverlappingHeatMap); RC.SetBlendState(MyBlendStateManager.BlendAdditive); RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil); MyScreenPass.DrawFullscreenQuad(); RC.PixelShader.Set(null); RC.PixelShader.SetSrv(0, null); RC.SetRtv(null); SetupOIT(accumTarget, coverageTarget, false); MyDebugTextureDisplay.Select(heatMap); heatMap.Release(); }
internal void GatherArray(IUavTexture postprocessTarget, ISrvBindable cascadeArray, MyProjectionInfo[] cascadeInfo, IConstantBuffer cascadeConstantBuffer) { MyShadowsQuality shadowsQuality = MyRender11.RenderSettings.ShadowQuality.GetShadowsQuality(); if (!MyRender11.Settings.EnableShadows || !MyRender11.DebugOverrides.Shadows || shadowsQuality == MyShadowsQuality.DISABLED) { RC.ClearUav(postprocessTarget, new RawInt4()); return; } MarkCascadesInStencil(cascadeInfo); MyGpuProfiler.IC_BeginBlock("Cascades postprocess"); if (shadowsQuality == MyShadowsQuality.LOW) RC.ComputeShader.Set(m_gatherCS_LD); else if (shadowsQuality == MyShadowsQuality.MEDIUM) RC.ComputeShader.Set(m_gatherCS_MD); else if (shadowsQuality == MyShadowsQuality.HIGH) RC.ComputeShader.Set(m_gatherCS_HD); RC.ComputeShader.SetUav(0, postprocessTarget); RC.ComputeShader.SetSrv(0, MyGBuffer.Main.ResolvedDepthStencil.SrvDepth); RC.ComputeShader.SetSrv(1, MyGBuffer.Main.DepthStencil.SrvStencil); RC.ComputeShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MySamplerStateManager.Shadowmap); if (!MyStereoRender.Enable) RC.ComputeShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); else MyStereoRender.CSBindRawCB_FrameConstants(RC); //RC.ComputeShader.SetConstantBuffer(4, MyManagers.Shadows.GetCsmConstantBufferOldOne()); RC.ComputeShader.SetConstantBuffer(4, cascadeConstantBuffer); RC.ComputeShader.SetSrv(MyCommon.CASCADES_SM_SLOT, cascadeArray); //RC.ComputeShader.SetSrv(MyCommon.CASCADES_SM_SLOT, MyManagers.Shadow.GetCsmForGbuffer()); Vector2I threadGroups = GetThreadGroupCount(); RC.Dispatch(threadGroups.X, threadGroups.Y, 1); RC.ComputeShader.SetUav(0, null); RC.ComputeShader.SetSrv(0, null); RC.ComputeShader.SetSrv(1, null); if (shadowsQuality == MyShadowsQuality.HIGH && MyShadowCascades.Settings.Data.EnableShadowBlur) { IBorrowedUavTexture helper = MyManagers.RwTexturesPool.BorrowUav("MyShadowCascadesPostProcess.Helper", Format.R8_UNorm); MyBlur.Run(postprocessTarget, helper, postprocessTarget, depthStencilState: MyDepthStencilStateManager.IgnoreDepthStencil, depthDiscardThreshold: 0.2f, clearColor: Color4.White); helper.Release(); } MyGpuProfiler.IC_EndBlock(); }
public static void Select(IUavTexture tex) { Deselect(); m_selUavTexture = tex; }
protected override void CreateTextureInternal(ref MyBorrowedTextureKey key) { UavTexture = MyManagers.RwTextures.CreateUav( NamesGenerator.GetUniqueName(), key.Width, key.Height, key.Format, key.SamplesCount, key.SamplesQuality); }