From 952fc90d9ae86d286811d3a1fd71e84973cc16c9 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Tue, 31 Dec 2019 12:50:16 +0100 Subject: [PATCH] dof, motionblur: unroll the loops --- WickedEngine/depthoffield_mainCS.hlsl | 4 ++++ WickedEngine/depthoffield_prepassCS.hlsl | 1 + WickedEngine/motionblurCS.hlsl | 1 + WickedEngine/wiVersion.cpp | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/WickedEngine/depthoffield_mainCS.hlsl b/WickedEngine/depthoffield_mainCS.hlsl index b88054b11..ebd82cf12 100644 --- a/WickedEngine/depthoffield_mainCS.hlsl +++ b/WickedEngine/depthoffield_mainCS.hlsl @@ -60,8 +60,10 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) #ifdef DEPTHOFFIELD_CHEAP color = center_color; + [unroll] for (uint j = 0; j < ringCount; ++j) { + [unroll] for (uint i = ringSampleCount[j]; i < ringSampleCount[j + 1]; ++i) { const float offsetCoc = disc[i].z; @@ -75,8 +77,10 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) #else float4 background = center_backgroundWeight * float4(center_color.rgb, 1); float4 foreground = center_foregroundWeight * float4(center_color.rgb, 1); + [unroll] for (uint j = 0; j < ringCount; ++j) { + [unroll] for (uint i = ringSampleCount[j]; i < ringSampleCount[j + 1]; ++i) { const float offsetCoc = disc[i].z; diff --git a/WickedEngine/depthoffield_prepassCS.hlsl b/WickedEngine/depthoffield_prepassCS.hlsl index 47f6db9f4..6655b2454 100644 --- a/WickedEngine/depthoffield_prepassCS.hlsl +++ b/WickedEngine/depthoffield_prepassCS.hlsl @@ -54,6 +54,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) float seed = 54321; const float2 ringScale = 2 * coc * xPPResolution_rcp; + [unroll] for (uint i = ringSampleCount[0]; i < ringSampleCount[1]; ++i) { const float offsetCoc = disc[i].z; diff --git a/WickedEngine/motionblurCS.hlsl b/WickedEngine/motionblurCS.hlsl index 3b974d063..d98c5b71e 100644 --- a/WickedEngine/motionblurCS.hlsl +++ b/WickedEngine/motionblurCS.hlsl @@ -82,6 +82,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) float4 sum = 0; float numSampling = 0; float2 uv2 = uv - range * sampling_direction; + [unroll] for (float i = -range; i <= range; i += 2.0f) { const float depth1 = texture_lineardepth.SampleLevel(sampler_point_clamp, uv2, 0); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index e6977d314..50f4ba7be 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 36; // minor bug fixes, alterations, refactors, updates - const int revision = 35; + const int revision = 36; long GetVersion()