Esempio n. 1
0
        public QueryBase()
        {
            _dataArrivedAction = new System.Action <AsyncGPUReadbackRequest>(DataArrived);

            if (_maxQueryCount != OceanRenderer.Instance._lodDataAnimWaves.Settings.MaxQueryCount)
            {
                _maxQueryCount          = OceanRenderer.Instance._lodDataAnimWaves.Settings.MaxQueryCount;
                _queryPosXZ_minGridSize = new Vector3[_maxQueryCount];
            }

            _computeBufQueries = new ComputeBuffer(_maxQueryCount, 12, ComputeBufferType.Default);
            _computeBufResults = new ComputeBuffer(_maxQueryCount, 12, ComputeBufferType.Default);

            _queryResults     = new NativeArray <Vector3>(_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);
            _queryResultsLast = new NativeArray <Vector3>(_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);

            _shaderProcessQueries = ComputeShaderHelpers.LoadShader(QueryShaderName);
            if (_shaderProcessQueries == null)
            {
                Debug.LogError($"Could not load Query compute shader {QueryShaderName}");
                return;
            }
            _kernelHandle = _shaderProcessQueries.FindKernel(QueryKernelName);
            _wrapper      = new PropertyWrapperComputeStandalone(_shaderProcessQueries, _kernelHandle);
        }
        protected virtual void OnEnable()
        {
            _dataArrivedAction = new System.Action <AsyncGPUReadbackRequest>(DataArrived);

            if (_maxQueryCount != OceanRenderer.Instance._simSettingsAnimatedWaves.MaxQueryCount)
            {
                _maxQueryCount          = OceanRenderer.Instance._simSettingsAnimatedWaves.MaxQueryCount;
                _queryPosXZ_minGridSize = new Vector3[_maxQueryCount];
            }

            _computeBufQueries = new ComputeBuffer(_maxQueryCount, 12, ComputeBufferType.Default);
            _computeBufResults = new ComputeBuffer(_maxQueryCount, 12, ComputeBufferType.Default);

            _queryResults     = new NativeArray <Vector3>(_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);
            _queryResultsLast = new NativeArray <Vector3>(_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);

            _shaderProcessQueries = ComputeShaderHelpers.LoadShader(QueryShaderName);
            if (_shaderProcessQueries == null)
            {
                enabled = false;
                return;
            }
            _kernelHandle = _shaderProcessQueries.FindKernel(QueryKernelName);
            _wrapper      = new PropertyWrapperComputeStandalone(_shaderProcessQueries, _kernelHandle);
        }
Esempio n. 3
0
        protected override void BindInputsAndOutputs(PropertyWrapperComputeStandalone wrapper, ComputeBuffer resultsBuffer)
        {
            LodDataMgrAnimWaves.Bind(wrapper);
            ShaderProcessQueries.SetTexture(_kernelHandle, sp_LD_TexArray_AnimatedWaves, OceanRenderer.Instance._lodDataAnimWaves.DataTexture);
            ShaderProcessQueries.SetBuffer(_kernelHandle, sp_ResultDisplacements, resultsBuffer);

            ShaderProcessQueries.SetBuffer(_kernelHandle, OceanRenderer.sp_cascadeData, OceanRenderer.Instance._bufCascadeDataTgt);
        }
Esempio n. 4
0
 protected override void BindInputsAndOutputs(PropertyWrapperComputeStandalone wrapper, ComputeBuffer resultsBuffer)
 {
     if (OceanRenderer.Instance._lodDataFlow != null)
     {
         OceanRenderer.Instance._lodDataFlow.BindResultData(wrapper);
         ShaderProcessQueries.SetTexture(_kernelHandle, sp_LD_TexArray_Flow, OceanRenderer.Instance._lodDataFlow.DataTexture);
     }
     ShaderProcessQueries.SetBuffer(_kernelHandle, sp_ResultFlows, resultsBuffer);
 }
Esempio n. 5
0
        protected virtual void OnEnable()
        {
            _dataArrivedAction = new System.Action <AsyncGPUReadbackRequest>(DataArrived);

            _shaderProcessQueries = Resources.Load <ComputeShader>(QueryShaderName);
            _kernelHandle         = _shaderProcessQueries.FindKernel(QueryKernelName);
            _wrapper = new PropertyWrapperComputeStandalone(_shaderProcessQueries, _kernelHandle);

            _computeBufQueries = new ComputeBuffer(s_maxQueryCount, 12, ComputeBufferType.Default);
            _computeBufResults = new ComputeBuffer(s_maxQueryCount, 12, ComputeBufferType.Default);

            _queryResults     = new NativeArray <Vector3>(s_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);
            _queryResultsLast = new NativeArray <Vector3>(s_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);
        }
Esempio n. 6
0
 protected abstract void BindInputsAndOutputs(PropertyWrapperComputeStandalone wrapper, ComputeBuffer resultsBuffer);
Esempio n. 7
0
 protected override void BindInputsAndOutputs(PropertyWrapperComputeStandalone wrapper, ComputeBuffer resultsBuffer)
 {
     LodDataMgrFlow.Bind(wrapper);
     ShaderProcessQueries.SetBuffer(_kernelHandle, sp_ResultFlows, resultsBuffer);
 }