@@ -80,19 +80,35 @@ public ShadowSetup(ShadowInitParameters shadowInit, ShadowSettings shadowSetting
8080 } ;
8181
8282 // binding code. This needs to be in sync with ShadowContext.hlsl
83- ShadowContext . BindDel binder = ( ShadowContext sc , CommandBuffer cb ) =>
84- {
85- // bind buffers
86- cb . SetGlobalBuffer ( "_ShadowDatasExp" , s_ShadowDataBuffer ) ;
87- cb . SetGlobalBuffer ( "_ShadowPayloads" , s_ShadowPayloadBuffer ) ;
88- // bind textures
83+ ShadowContext . BindDel binder = ( ShadowContext sc , CommandBuffer cb , ComputeShader computeShader , int computeKernel ) =>
84+ {
8985 uint offset , count ;
9086 RenderTargetIdentifier [ ] tex ;
91- sc . GetTex2DArrays ( out tex , out offset , out count ) ;
92- cb . SetGlobalTexture ( "_ShadowmapExp_VSM_0" , tex [ 0 ] ) ;
93- cb . SetGlobalTexture ( "_ShadowmapExp_VSM_1" , tex [ 1 ] ) ;
94- cb . SetGlobalTexture ( "_ShadowmapExp_VSM_2" , tex [ 2 ] ) ;
95- cb . SetGlobalTexture ( "_ShadowmapExp_PCF" , tex [ 3 ] ) ;
87+ sc . GetTex2DArrays ( out tex , out offset , out count ) ;
88+
89+ if ( computeShader )
90+ {
91+ // bind buffers
92+ cb . SetComputeBufferParam ( computeShader , computeKernel , "_ShadowDatasExp" , s_ShadowDataBuffer ) ;
93+ cb . SetComputeBufferParam ( computeShader , computeKernel , "_ShadowPayloads" , s_ShadowPayloadBuffer ) ;
94+ // bind textures
95+ cb . SetComputeTextureParam ( computeShader , computeKernel , "_ShadowmapExp_VSM_0" , tex [ 0 ] ) ;
96+ cb . SetComputeTextureParam ( computeShader , computeKernel , "_ShadowmapExp_VSM_1" , tex [ 1 ] ) ;
97+ cb . SetComputeTextureParam ( computeShader , computeKernel , "_ShadowmapExp_VSM_2" , tex [ 2 ] ) ;
98+ cb . SetComputeTextureParam ( computeShader , computeKernel , "_ShadowmapExp_PCF" , tex [ 3 ] ) ;
99+ }
100+ else
101+ {
102+ // bind buffers
103+ cb . SetGlobalBuffer ( "_ShadowDatasExp" , s_ShadowDataBuffer ) ;
104+ cb . SetGlobalBuffer ( "_ShadowPayloads" , s_ShadowPayloadBuffer ) ;
105+ // bind textures
106+ cb . SetGlobalTexture ( "_ShadowmapExp_VSM_0" , tex [ 0 ] ) ;
107+ cb . SetGlobalTexture ( "_ShadowmapExp_VSM_1" , tex [ 1 ] ) ;
108+ cb . SetGlobalTexture ( "_ShadowmapExp_VSM_2" , tex [ 2 ] ) ;
109+ cb . SetGlobalTexture ( "_ShadowmapExp_PCF" , tex [ 3 ] ) ;
110+ }
111+
96112 // TODO: Currently samplers are hard coded in ShadowContext.hlsl, so we can't really set them here
97113 } ;
98114
@@ -1825,9 +1841,9 @@ private void UpdateDataBuffers()
18251841 s_LightVolumeDataBuffer . SetData ( m_lightList . lightVolumes ) ;
18261842 }
18271843
1828- private void BindGlobalParams ( CommandBuffer cmd , ComputeShader computeShader , int kernelIndex , Camera camera )
1844+ private void BindGlobalParams ( CommandBuffer cmd , Camera camera )
18291845 {
1830- m_ShadowMgr . BindResources ( cmd ) ;
1846+ m_ShadowMgr . BindResources ( cmd , activeComputeShader , activeComputeKernel ) ;
18311847
18321848 SetGlobalBuffer ( "g_vLightListGlobal" , ! usingFptl ? s_PerVoxelLightLists : s_LightList ) ; // opaques list (unless MSAA possibly)
18331849
@@ -1881,7 +1897,7 @@ private void PushGlobalParams(Camera camera, CommandBuffer cmd, ComputeShader co
18811897 m_ShadowMgr . SyncData ( ) ;
18821898
18831899 SetGlobalPropertyRedirect ( computeShader , kernelIndex , cmd ) ;
1884- BindGlobalParams ( cmd , computeShader , kernelIndex , camera ) ;
1900+ BindGlobalParams ( cmd , camera ) ;
18851901 SetGlobalPropertyRedirect ( null , 0 , null ) ;
18861902 }
18871903 }
0 commit comments