Fix minor warnings in shaders

This commit is contained in:
Wojtek Figat
2021-05-15 14:19:40 +02:00
parent def45ce8bb
commit dbb42e9805
11 changed files with 50 additions and 54 deletions

BIN
Content/Shaders/DepthOfField.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/EyeAdaptation.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/GUI.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/VolumetricFog.flax (Stored with Git LFS)

Binary file not shown.

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<BokehGSOutput>
// 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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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);