Commit 95b1db96 by Alexis Hetu Committed by Alexis Hétu

BuiltInPointCoord implementation

BuiltInPointCoord is defined as: "The following formulas are used to evaluate s and t: s = 1/2 + (xp - xf) / size t = 1/2 + (yp - yf) / size where size is the point’s size; (xp,yp) is the location at which the point sprite coordinates are evaluated - this may be the framebuffer coordinates of the fragment center, or the location of a sample; and (xf,yf) is the exact, unrounded framebuffer coordinate of the vertex for the point." So it was implemented by writing (xf,yf) in SetupRoutine, where this information is present and using the fragment's x and y coordinates as (xp,yp), which passes the test. Tests: dEQP-VK.glsl.builtin_var.simple.pointcoord Change-Id: I9146349bcce0f7c31dd0464c0f210a7306d5d033 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31992 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 5e3c9d53
...@@ -42,6 +42,9 @@ namespace sw ...@@ -42,6 +42,9 @@ namespace sw
float4 xQuad; float4 xQuad;
float4 yQuad; float4 yQuad;
float pointCoordX;
float pointCoordY;
PlaneEquation z; PlaneEquation z;
PlaneEquation w; PlaneEquation w;
......
...@@ -37,6 +37,16 @@ namespace sw ...@@ -37,6 +37,16 @@ namespace sw
var[it->second.FirstComponent+3] = w; var[it->second.FirstComponent+3] = w;
} }
it = spirvShader->inputBuiltins.find(spv::BuiltInPointCoord);
if(it != spirvShader->inputBuiltins.end())
{
auto &var = routine.getVariable(it->second.Id);
var[it->second.FirstComponent] = SIMD::Float(0.5f) +
SIMD::Float(Float(x) - (*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordX))));
var[it->second.FirstComponent + 1] = SIMD::Float(0.5f) +
SIMD::Float(Float(y) - (*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordY))));
}
it = spirvShader->inputBuiltins.find(spv::BuiltInSubgroupSize); it = spirvShader->inputBuiltins.find(spv::BuiltInSubgroupSize);
if (it != spirvShader->inputBuiltins.end()) if (it != spirvShader->inputBuiltins.end())
{ {
......
...@@ -293,6 +293,11 @@ namespace sw ...@@ -293,6 +293,11 @@ namespace sw
conditionalRotate2(wMax == w2, v0, v1, v2); conditionalRotate2(wMax == w2, v0, v1, v2);
} }
*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordX)) =
*Pointer<Float>(v0 + OFFSET(Vertex, builtins.position.x));
*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordY)) =
*Pointer<Float>(v0 + OFFSET(Vertex, builtins.position.y));
Float w0 = *Pointer<Float>(v0 + OFFSET(Vertex, builtins.position.w)); Float w0 = *Pointer<Float>(v0 + OFFSET(Vertex, builtins.position.w));
Float w1 = *Pointer<Float>(v1 + OFFSET(Vertex, builtins.position.w)); Float w1 = *Pointer<Float>(v1 + OFFSET(Vertex, builtins.position.w));
Float w2 = *Pointer<Float>(v2 + OFFSET(Vertex, builtins.position.w)); Float w2 = *Pointer<Float>(v2 + OFFSET(Vertex, builtins.position.w));
......
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