Commit b9fc42de by Alexis Hetu Committed by Alexis Hétu

Sample location fix

The sample locations were reordered "for fragment offset computation". The reordering was causing some sample location tests to fail. Fixes SwANGLE tests: dEQP.GLES31/functional_texture_multisample_samples_*_sample_position Bug: b/147387937 b/139793135 Change-Id: I1a62d96517f2be0d625b9e9f8082d6f9e4c6a3f2 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40508Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent bdf2b720
...@@ -299,12 +299,8 @@ Constants::Constants() ...@@ -299,12 +299,8 @@ Constants::Constants()
{ {
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
{ {
// Reorder sample points for centroid computation sampleX[q][c][i] = c & (1 << i) ? X[q][0] : 0.0f;
const float Xs[4] = { X[1][0], X[2][0], X[0][0], X[3][0] }; sampleY[q][c][i] = c & (1 << i) ? Y[q][0] : 0.0f;
const float Ys[4] = { Y[1][0], Y[2][0], Y[0][0], Y[3][0] };
sampleX[q][c][i] = c & (1 << i) ? Xs[q] : 0.0f;
sampleY[q][c][i] = c & (1 << i) ? Ys[q] : 0.0f;
weight[c][i] = c & (1 << i) ? 1.0f : 0.0f; weight[c][i] = c & (1 << i) ? 1.0f : 0.0f;
} }
} }
...@@ -312,9 +308,8 @@ Constants::Constants() ...@@ -312,9 +308,8 @@ Constants::Constants()
constexpr auto subPixB = vk::SUBPIXEL_PRECISION_BITS; constexpr auto subPixB = vk::SUBPIXEL_PRECISION_BITS;
// Reorder sample points for fragment offset computation const int Xf[4] = { toFixedPoint(X[0][0], subPixB), toFixedPoint(X[1][0], subPixB), toFixedPoint(X[2][0], subPixB), toFixedPoint(X[3][0], subPixB) };
const int Xf[4] = { toFixedPoint(X[2][0], subPixB), toFixedPoint(X[1][0], subPixB), toFixedPoint(X[3][0], subPixB), toFixedPoint(X[0][0], subPixB) }; const int Yf[4] = { toFixedPoint(Y[0][0], subPixB), toFixedPoint(Y[1][0], subPixB), toFixedPoint(Y[2][0], subPixB), toFixedPoint(Y[3][0], subPixB) };
const int Yf[4] = { toFixedPoint(Y[2][0], subPixB), toFixedPoint(Y[1][0], subPixB), toFixedPoint(Y[3][0], subPixB), toFixedPoint(Y[0][0], subPixB) };
memcpy(&this->Xf, &Xf, sizeof(Xf)); memcpy(&this->Xf, &Xf, sizeof(Xf));
memcpy(&this->Yf, &Yf, sizeof(Yf)); memcpy(&this->Yf, &Yf, sizeof(Yf));
......
...@@ -108,10 +108,10 @@ struct Constants ...@@ -108,10 +108,10 @@ struct Constants
}; };
static constexpr float SampleLocationsY[4] = { static constexpr float SampleLocationsY[4] = {
-(VkSampleLocations4[0][1] - 0.5f), VkSampleLocations4[0][1] - 0.5f,
-(VkSampleLocations4[1][1] - 0.5f), VkSampleLocations4[1][1] - 0.5f,
-(VkSampleLocations4[2][1] - 0.5f), VkSampleLocations4[2][1] - 0.5f,
-(VkSampleLocations4[3][1] - 0.5f), VkSampleLocations4[3][1] - 0.5f,
}; };
// Compute the yMin and yMax multisample offsets so that they are just // Compute the yMin and yMax multisample offsets so that they are just
......
...@@ -202,8 +202,9 @@ void SetupRoutine::generate() ...@@ -202,8 +202,9 @@ void SetupRoutine::generate()
if(state.enableMultiSampling) if(state.enableMultiSampling)
{ {
Xq[i] = Xq[i] + *Pointer<Int>(constants + OFFSET(Constants, Xf) + q * sizeof(int)); // The subtraction here is because we're not moving the point, we're testing the edge against it
Yq[i] = Yq[i] + *Pointer<Int>(constants + OFFSET(Constants, Yf) + q * sizeof(int)); Xq[i] = Xq[i] - *Pointer<Int>(constants + OFFSET(Constants, Xf) + q * sizeof(int));
Yq[i] = Yq[i] - *Pointer<Int>(constants + OFFSET(Constants, Yf) + q * sizeof(int));
} }
i++; i++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment