Skip to content

Commit

Permalink
fixed command buffer get/release and unity 2022 complier errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lukakldiashvili committed May 15, 2023
1 parent 4393642 commit a209606
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
1 change: 0 additions & 1 deletion UnifiedUniversalBlur/Scripts/UniversalBlurFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ void SetupPassData(UniversalBlurPass.PassData passData)
passData.effectMaterial = passMaterial;
passData.passIndex = passIndex;
passData.requiresColor = requiresColor;
passData.isBeforeTransparents = injectedBeforeTransparents;
passData.profilingSampler ??= new ProfilingSampler("FullScreenPassRendererFeature");
passData.scale = scale;
passData.iterations = iterations;
Expand Down
34 changes: 13 additions & 21 deletions UnifiedUniversalBlur/Scripts/UniversalBlurPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@ private static void ExecutePass(PassData passData, ref RenderingData renderingDa
if (renderingData.cameraData.isSceneViewCamera && passData.disableInSceneView)
return;

CommandBuffer cmd =
#if UNITY_2022_1_OR_NEWER
renderingData.commandBuffer;
#else
CommandBufferPool.Get("FullScreenPassRendererFeature");
#endif
CommandBuffer cmd = CommandBufferPool.Get("FullScreenPassRendererFeature");

var cameraData = renderingData.cameraData;

Expand All @@ -87,25 +82,26 @@ private static void ExecutePass(PassData passData, ref RenderingData renderingDa
ProcessEffect(ref context);
#endif

context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);

void ProcessEffect(ref ScriptableRenderContext context)
{
if (passData.requiresColor)
{
var source =
#if UNITY_2022_1_OR_NEWER
passData.isBeforeTransparents
? cameraData.renderer.GetCameraColorBackBuffer(cmd)
: cameraData.renderer.cameraColorTargetHandle;
#else
#if UNITY_2022_1_OR_NEWER
cameraData.renderer.cameraColorTargetHandle;
#else
cameraData.renderer.cameraColorTarget;
#endif
#endif

// --- Start
#if UNITY_2022_1_OR_NEWER
Blitter.BlitCameraTexture(cmd, source, tmpRT1);
#else
cmd.Blit(source, tmpRT1);
#endif
#if UNITY_2022_1_OR_NEWER
Blitter.BlitCameraTexture(cmd, source, tmpRT1);
#else
cmd.Blit(source, tmpRT1);
#endif

void DoBlit()
{
Expand All @@ -129,9 +125,6 @@ void DoBlit()
cmd.SetGlobalTexture(k_GlobalFullScreenBlurTexture, tmpRT2);
// --- End
}

context.ExecuteCommandBuffer(cmd);
cmd.Clear();
}
}

Expand All @@ -141,7 +134,6 @@ internal class PassData
internal int passIndex;
internal bool requiresColor;
internal bool disableInSceneView;
internal bool isBeforeTransparents;

public ProfilingSampler profilingSampler;

Expand Down

0 comments on commit a209606

Please sign in to comment.