private void DownSampling()
        {
            DownScaleConstStruct constData = new DownScaleConstStruct()
            {
                ResX       = (uint)(GetDisplay.Width / 4),
                ResY       = (uint)(GetDisplay.Height / 4),
                Domain     = (uint)((GetDisplay.Width * GetDisplay.Height) / 16),
                GroupSize  = (uint)((GetDisplay.Width * GetDisplay.Height) / (16 * 1024)),
                Adaptation = Math.Min(RenderBackend.EngineRef.Time.DeltaTime / AdaptationPercent, 0.9999f),
            };

            D3DUtils.WriteToDynamicBuffer(GetContext, DownScaleConstantsBuffer, constData);

            SetComputeShader(DownsamplingFirsPassCSName);

            GetContext.ComputeShader.SetShaderResource(0, HDRTarget.ResourceView);
            GetContext.ComputeShader.SetUnorderedAccessView(0, CSLuminanceUAV);
            if (DwnSmplPrev)
            {
                GetContext.ComputeShader.SetShaderResource(1, CSAvgLuminanceSRV);
            }
            else
            {
                GetContext.ComputeShader.SetShaderResource(1, CSPrevAvgLuminanceSRV);
            }

            GetContext.Dispatch((GetDisplay.Width * GetDisplay.Height) / (16 * 1024), 1, 1);

            GetContext.ComputeShader.SetShaderResource(0, null);
            GetContext.ComputeShader.SetUnorderedAccessView(0, null);

            GetContext.ComputeShader.SetShaderResource(2, CSLuminanceSRV);
            if (DwnSmplPrev)
            {
                GetContext.ComputeShader.SetUnorderedAccessView(0, CSPrevAvgLuminanceUAV);
            }
            else
            {
                GetContext.ComputeShader.SetUnorderedAccessView(0, CSAvgLuminanceUAV);
            }
            SetComputeShader(DownsamplingSecondPassCSName);
            GetContext.Dispatch(1, 1, 1);

            GetContext.ComputeShader.SetShaderResource(1, null);
            GetContext.ComputeShader.SetShaderResource(2, null);
            GetContext.ComputeShader.SetUnorderedAccessView(0, null);
            DwnSmplPrev = !DwnSmplPrev;
        }
        private void LightCullingPass(StandardFrameData frameData)
        {
            CurrentPass = Pass.LightCulling;

            UpdateLights(frameData.LightsList);
            m_PerFrameConstBuffer.NumLights           = NonDirLightsCount;
            m_PerFrameConstBuffer.DirLightsNum        = DirLightsCount;
            m_PerFrameConstBuffer.MaxNumLightsPerTile = (uint)GetMaxNumLightsPerTile();
            GetContext.UpdateSubresource(ref m_PerFrameConstBuffer, PerFrameConstantBuffer);

            m_PerObjectConstBuffer = new CommonStructs.ConstBufferPerObjectStruct()
            {
                WorldMatrix         = Matrix.Identity,
                WorldViewMatrix     = Matrix.Identity * frameData.CamerasList[0].View,
                WorldViewProjMatrix = Matrix.Identity * frameData.CamerasList[0].ViewProjection,
            };
            GetContext.UpdateSubresource(ref m_PerObjectConstBuffer, PerObjConstantBuffer);
            GetContext.ComputeShader.SetConstantBuffer(0, PerObjConstantBuffer);
            GetContext.ComputeShader.SetConstantBuffer(1, PerFrameConstantBuffer);

            GetContext.OutputMerger.SetRenderTargets(null, (RenderTargetView)null);

            SetNullVertexShader();
            SetNullPixelShader();
            SetNullRasterizerState();
            SetBlendState(BlendStates.Opaque);

            GetContext.ComputeShader.Set(AssetsLoader.GetShader <ComputeShader>("LightCullingCS"));
            GetContext.ComputeShader.SetShaderResource(0, LightCenterAndRadiusSRV);
            GetContext.ComputeShader.SetShaderResource(1, GetDisplay.DepthStencilSRVRef);
            GetContext.ComputeShader.SetUnorderedAccessView(0, LightIndexURV);

            GetContext.Dispatch(GetNumTilesX(), GetNumTilesY(), 1);

            GetContext.ComputeShader.Set(null);
            GetContext.ComputeShader.SetShaderResource(0, null);
            GetContext.ComputeShader.SetShaderResource(1, null);
            GetContext.ComputeShader.SetUnorderedAccessView(0, null);
        }