From dbb42e98055ee4b62568a3d58a4bcc5cff25c1ca Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 15 May 2021 14:19:40 +0200 Subject: [PATCH] Fix minor warnings in shaders --- Content/Shaders/DepthOfField.flax | 4 +- Content/Shaders/EyeAdaptation.flax | 4 +- Content/Shaders/GUI.flax | 4 +- Content/Shaders/VolumetricFog.flax | 4 +- Source/Engine/Render2D/Render2D.cpp | 14 ++---- Source/Engine/Renderer/VolumetricFogPass.cpp | 6 +-- Source/Engine/Renderer/VolumetricFogPass.h | 6 +-- Source/Shaders/DepthOfField.shader | 50 ++++++++++---------- Source/Shaders/EyeAdaptation.shader | 2 +- Source/Shaders/GUI.shader | 6 +-- Source/Shaders/VolumetricFog.shader | 4 +- 11 files changed, 50 insertions(+), 54 deletions(-) diff --git a/Content/Shaders/DepthOfField.flax b/Content/Shaders/DepthOfField.flax index a84047429..6c4d9daec 100644 --- a/Content/Shaders/DepthOfField.flax +++ b/Content/Shaders/DepthOfField.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92355644db4cdfd96250b779a87385e6805d01ce084801b3a4be704f026e9bca -size 21025 +oid sha256:d8b69fce536cb27d497f6ff91f8adff3fbeaa9a704ced1b3271f4d621c195d53 +size 21054 diff --git a/Content/Shaders/EyeAdaptation.flax b/Content/Shaders/EyeAdaptation.flax index 9c538e798..93e17c1a2 100644 --- a/Content/Shaders/EyeAdaptation.flax +++ b/Content/Shaders/EyeAdaptation.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c12b7b43743e4e609a4155d7a4117421298d679d07548ffa48a386da496556b0 -size 4605 +oid sha256:f0d2b41560554e53692958ddea4cb53a082a7fbe88d7cb99eeccd095c45f631a +size 4600 diff --git a/Content/Shaders/GUI.flax b/Content/Shaders/GUI.flax index 73fd80725..0e9077247 100644 --- a/Content/Shaders/GUI.flax +++ b/Content/Shaders/GUI.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ea8cffddde04c7f3829ce0bd0cb61deecb50a9ac954c552cddb72d182538d605 -size 5108 +oid sha256:aae706e79bbc4eb9508da338a3ba2b4300f012771bac3c1a43835fd41ad7282a +size 5111 diff --git a/Content/Shaders/VolumetricFog.flax b/Content/Shaders/VolumetricFog.flax index 118e46c91..19420d9ad 100644 --- a/Content/Shaders/VolumetricFog.flax +++ b/Content/Shaders/VolumetricFog.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:81de76f651892a4d410c4624de3cab685d29b6711938c04325dac776588e3ec9 -size 14293 +oid sha256:2b71f70eab5a3139707a624ec2ea796e83114d3cc5351c9648921e13bffa2386 +size 14288 diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp index e1319c858..de58f6ea7 100644 --- a/Source/Engine/Render2D/Render2D.cpp +++ b/Source/Engine/Render2D/Render2D.cpp @@ -62,7 +62,7 @@ PACK_STRUCT(struct Data { PACK_STRUCT(struct BlurData { Vector2 InvBufferSize; - int32 SampleCount; + uint32 SampleCount; float Dummy0; Vector4 Bounds; Vector4 WeightAndOffsets[RENDER2D_BLUR_MAX_SAMPLES / 2]; @@ -877,20 +877,16 @@ static Vector2 GetWeightAndOffset(float dist, float sigma) return Vector2(totalWeight, offset); } -static int32 ComputeBlurWeights(int32 kernelSize, float sigma, Vector4* outWeightsAndOffsets) +static uint32 ComputeBlurWeights(int32 kernelSize, float sigma, Vector4* outWeightsAndOffsets) { - const int32 numSamples = Math::DivideAndRoundUp(kernelSize, 2); - + const uint32 numSamples = Math::DivideAndRoundUp((uint32)kernelSize, 2u); outWeightsAndOffsets[0] = Vector4(Vector2(GetWeight(0, sigma), 0), GetWeightAndOffset(1, sigma)); - - int32 sampleIndex = 1; - for (int32 x = 3; x < kernelSize; x += 4) + uint32 sampleIndex = 1; + for (uint32 x = 3; x < kernelSize; x += 4) { outWeightsAndOffsets[sampleIndex] = Vector4(GetWeightAndOffset((float)x, sigma), GetWeightAndOffset((float)(x + 2), sigma)); - sampleIndex++; } - return numSamples; } diff --git a/Source/Engine/Renderer/VolumetricFogPass.cpp b/Source/Engine/Renderer/VolumetricFogPass.cpp index 3a5307789..c460533d6 100644 --- a/Source/Engine/Renderer/VolumetricFogPass.cpp +++ b/Source/Engine/Renderer/VolumetricFogPass.cpp @@ -194,9 +194,9 @@ bool VolumetricFogPass::Init(RenderContext& renderContext, GPUContext* context, _cache.Data.GlobalExtinctionScale = options.ExtinctionScale; _cache.Data.GlobalEmissive = options.Emissive.ToVector3() * options.Emissive.A; _cache.Data.GridSize = _cache.GridSize; - _cache.Data.GridSizeIntX = (int32)_cache.GridSize.X; - _cache.Data.GridSizeIntY = (int32)_cache.GridSize.Y; - _cache.Data.GridSizeIntZ = (int32)_cache.GridSize.Z; + _cache.Data.GridSizeIntX = (uint32)_cache.GridSize.X; + _cache.Data.GridSizeIntY = (uint32)_cache.GridSize.Y; + _cache.Data.GridSizeIntZ = (uint32)_cache.GridSize.Z; _cache.Data.HistoryWeight = _cache.HistoryWeight; _cache.Data.FogParameters = options.FogParameters; _cache.Data.InverseSquaredLightDistanceBiasScale = _cache.InverseSquaredLightDistanceBiasScale; diff --git a/Source/Engine/Renderer/VolumetricFogPass.h b/Source/Engine/Renderer/VolumetricFogPass.h index 4c86185ff..94ada2034 100644 --- a/Source/Engine/Renderer/VolumetricFogPass.h +++ b/Source/Engine/Renderer/VolumetricFogPass.h @@ -46,9 +46,9 @@ private: Vector3 GridSize; uint32 MissedHistorySamplesCount; - int32 GridSizeIntX; - int32 GridSizeIntY; - int32 GridSizeIntZ; + uint32 GridSizeIntX; + uint32 GridSizeIntY; + uint32 GridSizeIntZ; float PhaseG; Vector2 Dummy0; diff --git a/Source/Shaders/DepthOfField.shader b/Source/Shaders/DepthOfField.shader index 737b7c4cd..f8753bbba 100644 --- a/Source/Shaders/DepthOfField.shader +++ b/Source/Shaders/DepthOfField.shader @@ -137,17 +137,17 @@ META_CS(true, FEATURE_LEVEL_SM5) void CS_DepthOfFieldH(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThreadID) { // These positions are relative to the "grid", AKA the horizontal group of pixels that this thread group is writing to - const int gridStartX = groupID.x * DOF_GRID_SIZE; - const int gridX = groupThreadID.x - DOF_APRON_SIZE; + const uint gridStartX = groupID.x * DOF_GRID_SIZE; + const uint gridX = groupThreadID.x - DOF_APRON_SIZE; // These positions are relative to the pixel coordinates - const int sampleX = gridStartX + gridX; - const int sampleY = groupID.y; + const uint sampleX = gridStartX + gridX; + const uint sampleY = groupID.y; uint2 textureSize; Input0.GetDimensions(textureSize.x, textureSize.y); - const int2 samplePos = int2(sampleX, sampleY); + const uint2 samplePos = uint2(sampleX, sampleY); // Sample the textures #if USE_CS_HALF_PIXEL_OFFSET @@ -186,7 +186,7 @@ void CS_DepthOfFieldH(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_Group for (int x = -DOF_MAX_SAMPLE_RADIUS; x <= DOF_MAX_SAMPLE_RADIUS; x++) { // Grab the sample from shared memory - int groupTapX = groupThreadID.x + x; + uint groupTapX = groupThreadID.x + x; DOFSample tap = Samples[groupTapX]; // Reject the sample if it's outside the CoC radius @@ -218,17 +218,17 @@ META_CS(true, FEATURE_LEVEL_SM5) void CS_DepthOfFieldV(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThreadID) { // These positions are relative to the "grid", AKA the vertical group of pixels that this thread group is writing to - const int gridStartY = groupID.y * DOF_GRID_SIZE; - const int gridY = groupThreadID.y - DOF_APRON_SIZE; + const uint gridStartY = groupID.y * DOF_GRID_SIZE; + const uint gridY = groupThreadID.y - DOF_APRON_SIZE; // These positions are relative to the pixel coordinates - const int sampleX = groupID.x; - const int sampleY = gridStartY + gridY; + const uint sampleX = groupID.x; + const uint sampleY = gridStartY + gridY; uint2 textureSize; Input0.GetDimensions(textureSize.x, textureSize.y); - const int2 samplePos = int2(sampleX, sampleY); + const uint2 samplePos = uint2(sampleX, sampleY); // Sample the textures #if USE_CS_HALF_PIXEL_OFFSET @@ -267,7 +267,7 @@ void CS_DepthOfFieldV(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_Group for (int y = -DOF_MAX_SAMPLE_RADIUS; y <= DOF_MAX_SAMPLE_RADIUS; y++) { // Grab the sample from shared memory - int groupTapY = groupThreadID.y + y; + uint groupTapY = groupThreadID.y + y; DOFSample tap = Samples[groupTapY]; // Reject the sample if it's outside the CoC radius @@ -311,17 +311,17 @@ META_CS(true, FEATURE_LEVEL_SM5) void CS_CoCSpreadH(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThreadID) { // These positions are relative to the "grid", AKA the horizontal group of pixels that this thread group is writing to - const int gridStartX = groupID.x * DOF_GRID_SIZE; - const int gridX = groupThreadID.x - DOF_APRON_SIZE; + const uint gridStartX = groupID.x * DOF_GRID_SIZE; + const uint gridX = groupThreadID.x - DOF_APRON_SIZE; // These positions are relative to the pixel coordinates - const int sampleX = gridStartX + gridX; - const int sampleY = groupID.y; + const uint sampleX = gridStartX + gridX; + const uint sampleY = groupID.y; uint2 textureSize; Input0.GetDimensions(textureSize.x, textureSize.y); - const int2 samplePos = int2(sampleX, sampleY); + const uint2 samplePos = uint2(sampleX, sampleY); // Sample the textures #if USE_CS_HALF_PIXEL_OFFSET @@ -355,7 +355,7 @@ void CS_CoCSpreadH(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThr for (int x = -DOF_MAX_SAMPLE_RADIUS; x <= DOF_MAX_SAMPLE_RADIUS; x++) { // Grab the sample from shared memory - int groupTapX = groupThreadID.x + x; + uint groupTapX = groupThreadID.x + x; CoCSample tap = Samples[groupTapX]; // Only accept samples if they're from the foreground, and have a higher blur amount @@ -382,17 +382,17 @@ META_CS(true, FEATURE_LEVEL_SM5) void CS_CoCSpreadV(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThreadID) { // These positions are relative to the "grid", AKA the vertical group of pixels that this thread group is writing to - const int gridStartY = groupID.y * DOF_GRID_SIZE; - const int gridY = groupThreadID.y - DOF_APRON_SIZE; + const uint gridStartY = groupID.y * DOF_GRID_SIZE; + const uint gridY = groupThreadID.y - DOF_APRON_SIZE; // These positions are relative to the pixel coordinates - const int sampleX = groupID.x; - const int sampleY = gridStartY + gridY; + const uint sampleX = groupID.x; + const uint sampleY = gridStartY + gridY; uint2 textureSize; Input0.GetDimensions(textureSize.x, textureSize.y); - const int2 samplePos = int2(sampleX, sampleY); + const uint2 samplePos = uint2(sampleX, sampleY); // Sample the textures #if USE_CS_HALF_PIXEL_OFFSET @@ -425,7 +425,7 @@ void CS_CoCSpreadV(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThr for (int y = -DOF_MAX_SAMPLE_RADIUS; y <= DOF_MAX_SAMPLE_RADIUS; y++) { // Grab the sample from shared memory - int groupTapY = groupThreadID.y + y; + uint groupTapY = groupThreadID.y + y; CoCSample tap = Samples[groupTapY]; // Only accept samples if they're from the foreground, and have a higher blur amount @@ -605,7 +605,7 @@ void GS_Bokeh(point BokehVSOutput input[1], inout TriangleStream // Emit 4 new verts, and 2 new triangles UNROLL - for (int i = 0; i < 4; i++) + for (uint i = 0; i < 4; i++) { output.PositionCS = float4(input[0].Position.xy, 1.0f, 1.0f); output.PositionCS.xy += Offsets[i] * input[0].Size; diff --git a/Source/Shaders/EyeAdaptation.shader b/Source/Shaders/EyeAdaptation.shader index fca80b7fc..b9d5544a4 100644 --- a/Source/Shaders/EyeAdaptation.shader +++ b/Source/Shaders/EyeAdaptation.shader @@ -31,7 +31,7 @@ float AdaptLuminance(float currentLum, Texture2D previousLuminance) float luminance = previousLum + delta * (1.0f - exp2(-DeltaTime * adaptionSpeed)); luminance = lerp(luminance, currentLum, DropHistory); - return clamp(luminance, MinBrightness, MaxBrightness).xxxx; + return clamp(luminance, MinBrightness, MaxBrightness); } #ifdef _PS_Manual diff --git a/Source/Shaders/GUI.shader b/Source/Shaders/GUI.shader index 3057dfbae..b5023d0e9 100644 --- a/Source/Shaders/GUI.shader +++ b/Source/Shaders/GUI.shader @@ -14,7 +14,7 @@ META_CB_END META_CB_BEGIN(1, BlurData) float2 InvBufferSize; -int SampleCount; +uint SampleCount; float Dummy0; float4 Bounds; float4 WeightAndOffsets[MAX_SAMPLES / 2]; @@ -148,9 +148,9 @@ float4 PS_Blur(Quad_VS2PS input) : SV_Target0 result += GetSample(weight, offset, uv); } - for (int i = 2; i < SampleCount; i += 2) + for (uint i = 2; i < SampleCount; i += 2) { - int index = i / 2; + uint index = i / 2; { float weight = WeightAndOffsets[index].x; float offset = WeightAndOffsets[index].y; diff --git a/Source/Shaders/VolumetricFog.shader b/Source/Shaders/VolumetricFog.shader index 79b055732..efacd448f 100644 --- a/Source/Shaders/VolumetricFog.shader +++ b/Source/Shaders/VolumetricFog.shader @@ -39,7 +39,7 @@ float HistoryWeight; float3 GridSize; uint MissedHistorySamplesCount; -int3 GridSizeInt; +uint3 GridSizeInt; float PhaseG; float2 Dummy0; @@ -276,7 +276,7 @@ void CS_Initialize(uint3 GroupId : SV_GroupID, uint3 DispatchThreadId : SV_Dispa float3 scattering = GlobalAlbedo * extinction; float absorption = max(0.0f, extinction - Luminance(scattering)); - if (all((int3)gridCoordinate < GridSizeInt)) + if (all(gridCoordinate < GridSizeInt)) { RWVBufferA[gridCoordinate] = float4(scattering, absorption); RWVBufferB[gridCoordinate] = float4(GlobalEmissive, 0);