Commit ef55c4e7 by Chris Forbes

Fix PointCoord builtin

There were two bugs here: - Across a 2x2 pixel quad, we were producing a uniform PointCoord value. This is not correct, and causes trouble even for size 1 points if the derivative of the PointCoord value is ever used, or if the non-helper lane is not lane 0 (in which case the live lane may end up having PointCoord values outside [0,1].) - SetupRoutine was using the clipspace position of the vertex. Xf,Yf are specified to be in screenspace. It's possible to do this in a less redundant way, but currently we don't have unrounded vertex positions in screenspace available in the setup program. Just reproject for now, as we do in clipping paths etc. Note that we only do this if we're drawing points, so most (filled triangle) draws should not incur any additional cost. Bug: b/140680704 Test: dEQP-VK.glsl.builtin_var.simple.pointcoord* Change-Id: If006cc92b86673b6bb747cf60f60e0ed46f5e8e3 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/36115Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
parent c03ce008
......@@ -78,9 +78,9 @@ namespace sw
routine.setInputBuiltin(spirvShader, spv::BuiltInPointCoord, [&](const SpirvShader::BuiltinMapping& builtin, Array<SIMD::Float>& value)
{
assert(builtin.SizeInComponents == 2);
value[builtin.FirstComponent+0] = SIMD::Float(0.5f) +
value[builtin.FirstComponent+0] = SIMD::Float(0.5f, 1.5f, 0.5f, 1.5f) +
SIMD::Float(Float(x) - (*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordX))));
value[builtin.FirstComponent+1] = SIMD::Float(0.5f) +
value[builtin.FirstComponent+1] = SIMD::Float(0.5f, 0.5f, 1.5f, 1.5f) +
SIMD::Float(Float(y) - (*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordY))));
});
......
......@@ -294,11 +294,6 @@ namespace sw
conditionalRotate2(wMax == w2, v0, v1, v2);
}
*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordX)) =
*Pointer<Float>(v0 + OFFSET(Vertex, x));
*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordY)) =
*Pointer<Float>(v0 + OFFSET(Vertex, y));
Float w0 = *Pointer<Float>(v0 + OFFSET(Vertex, w));
Float w1 = *Pointer<Float>(v1 + OFFSET(Vertex, w));
Float w2 = *Pointer<Float>(v2 + OFFSET(Vertex, w));
......@@ -320,6 +315,12 @@ namespace sw
Int Y1 = *Pointer<Int>(v1 + OFFSET(Vertex,projected.y));
Int Y2 = *Pointer<Int>(v2 + OFFSET(Vertex,projected.y));
if(point)
{
*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordX)) = Float(1.0f / subPixF) * Float(X0);
*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordY)) = Float(1.0f / subPixF) * Float(Y0);
}
if(line)
{
X2 = X1 + Y1 - Y0;
......
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