Skip to content

Commit

Permalink
Use constructors instead of cast operators
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Feb 7, 2022
1 parent 19d3a69 commit 94b2e51
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions shaders/cBloom.fx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void DownsampleVS(in uint ID, out float4 Position, out float4 TexCoord[4], float
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
const float2 PixelSize = 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -Factor);
const float2 PixelSize = 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -Factor));
// Quadrant
TexCoord[0] = TexCoord0.xyxy + float4(-1.0, -1.0, 1.0, 1.0) * PixelSize.xyxy;
// Left column
Expand All @@ -226,7 +226,7 @@ void UpsampleVS(in uint ID, out float4 Position, out float4 TexCoord[3], float F
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
const float2 PixelSize = 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -Factor);
const float2 PixelSize = 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -Factor));
// Left column
TexCoord[0] = TexCoord0.xyyy + float4(-2.0, 2.0, 0.0, -2.0) * PixelSize.xyyy;
// Center column
Expand Down
22 changes: 11 additions & 11 deletions shaders/cInterpolation.fx
Original file line number Diff line number Diff line change
Expand Up @@ -346,22 +346,22 @@ namespace Interpolation

void Downsample1VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 DownsampleOffsets[4] : TEXCOORD0)
{
DownsampleVS(ID, 1.0 / (uint2)ldexp(BUFFER_SIZE, -1.0), Position, DownsampleOffsets);
DownsampleVS(ID, 1.0 / uint2(ldexp(BUFFER_SIZE, -1.0)), Position, DownsampleOffsets);
}

void Downsample2VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 DownsampleOffsets[4] : TEXCOORD0)
{
DownsampleVS(ID, 1.0 / (uint2)ldexp(BUFFER_SIZE, -2.0), Position, DownsampleOffsets);
DownsampleVS(ID, 1.0 / uint2(ldexp(BUFFER_SIZE, -2.0)), Position, DownsampleOffsets);
}

void Upsample1VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 UpsampleOffsets[3] : TEXCOORD0)
{
UpsampleVS(ID, 1.0 / (uint2)ldexp(BUFFER_SIZE, -1.0), Position, UpsampleOffsets);
UpsampleVS(ID, 1.0 / uint2(ldexp(BUFFER_SIZE, -1.0)), Position, UpsampleOffsets);
}

void Upsample0VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 UpsampleOffsets[3] : TEXCOORD0)
{
UpsampleVS(ID, 1.0 / (uint2)ldexp(BUFFER_SIZE, 0.0), Position, UpsampleOffsets);
UpsampleVS(ID, 1.0 / uint2(ldexp(BUFFER_SIZE, 0.0)), Position, UpsampleOffsets);
}

void DerivativesVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets : TEXCOORD0)
Expand All @@ -377,49 +377,49 @@ namespace Interpolation
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -7.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -7.0)), Offsets);
}

void EstimateLevel5VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -6.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -6.0)), Offsets);
}

void EstimateLevel4VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -5.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -5.0)), Offsets);
}

void EstimateLevel3VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -4.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -4.0)), Offsets);
}

void EstimateLevel2VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -3.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -3.0)), Offsets);
}

void EstimateLevel1VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -2.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -2.0)), Offsets);
}

void EstimateLevel0VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -1.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -1.0)), Offsets);
}

// Pixel shaders
Expand Down
22 changes: 11 additions & 11 deletions shaders/cMotionBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -329,22 +329,22 @@ namespace MotionBlur

void Downsample1VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 DownsampleOffsets[4] : TEXCOORD0)
{
DownsampleVS(ID, 1.0 / (uint2)ldexp(BUFFER_SIZE, -1.0), Position, DownsampleOffsets);
DownsampleVS(ID, 1.0 / uint2(ldexp(BUFFER_SIZE, -1.0)), Position, DownsampleOffsets);
}

void Downsample2VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 DownsampleOffsets[4] : TEXCOORD0)
{
DownsampleVS(ID, 1.0 / (uint2)ldexp(BUFFER_SIZE, -2.0), Position, DownsampleOffsets);
DownsampleVS(ID, 1.0 / uint2(ldexp(BUFFER_SIZE, -2.0)), Position, DownsampleOffsets);
}

void Upsample1VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 UpsampleOffsets[3] : TEXCOORD0)
{
UpsampleVS(ID, 1.0 / (uint2)ldexp(BUFFER_SIZE, -1.0), Position, UpsampleOffsets);
UpsampleVS(ID, 1.0 / uint2(ldexp(BUFFER_SIZE, -1.0)), Position, UpsampleOffsets);
}

void Upsample0VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 UpsampleOffsets[3] : TEXCOORD0)
{
UpsampleVS(ID, 1.0 / (uint2)ldexp(BUFFER_SIZE, 0.0), Position, UpsampleOffsets);
UpsampleVS(ID, 1.0 / uint2(ldexp(BUFFER_SIZE, 0.0)), Position, UpsampleOffsets);
}

void DerivativesVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets : TEXCOORD0)
Expand All @@ -360,49 +360,49 @@ namespace MotionBlur
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -7.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -7.0)), Offsets);
}

void EstimateLevel5VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -6.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -6.0)), Offsets);
}

void EstimateLevel4VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -5.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -5.0)), Offsets);
}

void EstimateLevel3VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -4.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -4.0)), Offsets);
}

void EstimateLevel2VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -3.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -3.0)), Offsets);
}

void EstimateLevel1VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -2.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -2.0)), Offsets);
}

void EstimateLevel0VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
float2 TexCoord0;
PostProcessVS(ID, Position, TexCoord0);
UpsampleOffsets(TexCoord0, 1.0 / (uint2)ldexp(BUFFER_SIZE, -1.0), Offsets);
UpsampleOffsets(TexCoord0, 1.0 / uint2(ldexp(BUFFER_SIZE, -1.0)), Offsets);
}

// Pixel shaders
Expand Down
26 changes: 13 additions & 13 deletions shaders/cOpticalFlow.fx
Original file line number Diff line number Diff line change
Expand Up @@ -379,32 +379,32 @@ namespace OpticalFlow

void Downsample1VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 DownsampleCoords[4] : TEXCOORD0)
{
DownsampleVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -1.0), Position, DownsampleCoords);
DownsampleVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -1.0)), Position, DownsampleCoords);
}

void Downsample2VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 DownsampleCoords[4] : TEXCOORD0)
{
DownsampleVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -2.0), Position, DownsampleCoords);
DownsampleVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -2.0)), Position, DownsampleCoords);
}

void Downsample3VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 DownsampleCoords[4] : TEXCOORD0)
{
DownsampleVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -3.0), Position, DownsampleCoords);
DownsampleVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -3.0)), Position, DownsampleCoords);
}

void Upsample2VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 UpsampleCoords[3] : TEXCOORD0)
{
UpsampleVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -3.0), Position, UpsampleCoords);
UpsampleVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -3.0)), Position, UpsampleCoords);
}

void Upsample1VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 UpsampleCoords[3] : TEXCOORD0)
{
UpsampleVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -2.0), Position, UpsampleCoords);
UpsampleVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -2.0)), Position, UpsampleCoords);
}

void Upsample0VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 UpsampleCoords[3] : TEXCOORD0)
{
UpsampleVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -1.0), Position, UpsampleCoords);
UpsampleVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -1.0)), Position, UpsampleCoords);
}

void DerivativesVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets : TEXCOORD0)
Expand All @@ -425,37 +425,37 @@ namespace OpticalFlow

void EstimateLevel6VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
EstimateVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -7.0), Position, Offsets);
EstimateVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -7.0)), Position, Offsets);
}

void EstimateLevel5VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
EstimateVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -6.0), Position, Offsets);
EstimateVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -6.0)), Position, Offsets);
}

void EstimateLevel4VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
EstimateVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -5.0), Position, Offsets);
EstimateVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -5.0)), Position, Offsets);
}

void EstimateLevel3VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
EstimateVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -4.0), Position, Offsets);
EstimateVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -4.0)), Position, Offsets);
}

void EstimateLevel2VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
EstimateVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -3.0), Position, Offsets);
EstimateVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -3.0)), Position, Offsets);
}

void EstimateLevel1VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
EstimateVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -2.0), Position, Offsets);
EstimateVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -2.0)), Position, Offsets);
}

void EstimateLevel0VS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float4 Offsets[3] : TEXCOORD0)
{
EstimateVS(ID, 1.0 / (uint2)ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -1.0), Position, Offsets);
EstimateVS(ID, 1.0 / uint2(ldexp(float2(BUFFER_WIDTH, BUFFER_HEIGHT), -1.0)), Position, Offsets);
}

void VelocityStreamsVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float2 Velocity : TEXCOORD0)
Expand Down

0 comments on commit 94b2e51

Please sign in to comment.