Support for the largePoints feature in Vulkan

Bug: b/149537975 Tests: dEQP-VK.*point* Change-Id: I22ee0c0ebc4e7b414e055e2b87010004dfc8741a Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41948Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarMarc-Antoine Desroches <madesroches@google.com>
parent 8c13b2f0
...@@ -66,6 +66,7 @@ struct Primitive MEMORY_SANITIZER_ONLY( ...@@ -66,6 +66,7 @@ struct Primitive MEMORY_SANITIZER_ONLY(
float pointCoordX; float pointCoordX;
float pointCoordY; float pointCoordY;
float pointSizeInv;
PlaneEquation z; PlaneEquation z;
PlaneEquation w; PlaneEquation w;
......
...@@ -1153,6 +1153,7 @@ bool DrawCall::setupPoint(Primitive &primitive, Triangle &triangle, const DrawCa ...@@ -1153,6 +1153,7 @@ bool DrawCall::setupPoint(Primitive &primitive, Triangle &triangle, const DrawCa
triangle.v1.projected.x += iround(subPixF * 0.5f * pSize); triangle.v1.projected.x += iround(subPixF * 0.5f * pSize);
triangle.v2.projected.y -= iround(subPixF * 0.5f * pSize) * (data.HxF[0] > 0.0f ? 1 : -1); // Both Direct3D and OpenGL expect (0, 0) in the top-left corner triangle.v2.projected.y -= iround(subPixF * 0.5f * pSize) * (data.HxF[0] > 0.0f ? 1 : -1); // Both Direct3D and OpenGL expect (0, 0) in the top-left corner
primitive.pointSizeInv = 1.0f / pSize;
return draw.setupRoutine(&primitive, &triangle, &polygon, &data); return draw.setupRoutine(&primitive, &triangle, &polygon, &data);
} }
......
...@@ -66,10 +66,7 @@ void PixelProgram::setBuiltins(Int &x, Int &y, Float4 (&z)[4], Float4 &w, Int cM ...@@ -66,10 +66,7 @@ void PixelProgram::setBuiltins(Int &x, Int &y, Float4 (&z)[4], Float4 &w, Int cM
routine.fragCoord[1] = SIMD::Float(Float(y)) + SIMD::Float(0.5f, 0.5f, 1.5f, 1.5f); routine.fragCoord[1] = SIMD::Float(Float(y)) + SIMD::Float(0.5f, 0.5f, 1.5f, 1.5f);
routine.fragCoord[2] = z[0]; // sample 0 routine.fragCoord[2] = z[0]; // sample 0
routine.fragCoord[3] = w; routine.fragCoord[3] = w;
routine.pointCoord[0] = SIMD::Float(0.5f) +
SIMD::Float(Float(x) - (*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordX))));
routine.pointCoord[1] = SIMD::Float(0.5f) +
SIMD::Float(Float(y) - (*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordY))));
routine.invocationsPerSubgroup = SIMD::Width; routine.invocationsPerSubgroup = SIMD::Width;
routine.helperInvocation = ~maskAny(cMask); routine.helperInvocation = ~maskAny(cMask);
routine.windowSpacePosition[0] = x + SIMD::Int(0, 1, 0, 1); routine.windowSpacePosition[0] = x + SIMD::Int(0, 1, 0, 1);
...@@ -91,10 +88,10 @@ void PixelProgram::setBuiltins(Int &x, Int &y, Float4 (&z)[4], Float4 &w, Int cM ...@@ -91,10 +88,10 @@ void PixelProgram::setBuiltins(Int &x, Int &y, Float4 (&z)[4], Float4 &w, Int cM
routine.setInputBuiltin(spirvShader, spv::BuiltInPointCoord, [&](const SpirvShader::BuiltinMapping &builtin, Array<SIMD::Float> &value) { routine.setInputBuiltin(spirvShader, spv::BuiltInPointCoord, [&](const SpirvShader::BuiltinMapping &builtin, Array<SIMD::Float> &value) {
assert(builtin.SizeInComponents == 2); assert(builtin.SizeInComponents == 2);
value[builtin.FirstComponent + 0] = SIMD::Float(0.5f, 1.5f, 0.5f, 1.5f) + Float pointSizeFactor = *Pointer<Float>(primitive + OFFSET(Primitive, pointSizeInv));
SIMD::Float(Float(x) - (*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordX)))); value[builtin.FirstComponent + 0] = SIMD::Float(0.5f) + SIMD::Float(pointSizeFactor) * (((SIMD::Float(Float(x)) + SIMD::Float(0.f, 1.f, 0.f, 1.f)) - SIMD::Float(*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordX)))));
value[builtin.FirstComponent + 1] = SIMD::Float(0.5f, 0.5f, 1.5f, 1.5f) +
SIMD::Float(Float(y) - (*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordY)))); value[builtin.FirstComponent + 1] = SIMD::Float(0.5f) + SIMD::Float(pointSizeFactor) * (((SIMD::Float(Float(y)) + SIMD::Float(0.f, 0.f, 1.f, 1.f)) - SIMD::Float(*Pointer<Float>(primitive + OFFSET(Primitive, pointCoordY)))));
}); });
routine.setInputBuiltin(spirvShader, spv::BuiltInSubgroupSize, [&](const SpirvShader::BuiltinMapping &builtin, Array<SIMD::Float> &value) { routine.setInputBuiltin(spirvShader, spv::BuiltInSubgroupSize, [&](const SpirvShader::BuiltinMapping &builtin, Array<SIMD::Float> &value) {
......
...@@ -74,7 +74,7 @@ enum ...@@ -74,7 +74,7 @@ enum
enum enum
{ {
MAX_POINT_SIZE = 1, // Large points are not supported. If/when we turn this on, must be >= 64. MAX_POINT_SIZE = 1023,
}; };
constexpr int SUBPIXEL_PRECISION_BITS = 4; constexpr int SUBPIXEL_PRECISION_BITS = 4;
......
...@@ -71,7 +71,7 @@ const VkPhysicalDeviceFeatures &PhysicalDevice::getFeatures() const ...@@ -71,7 +71,7 @@ const VkPhysicalDeviceFeatures &PhysicalDevice::getFeatures() const
VK_TRUE, // fillModeNonSolid VK_TRUE, // fillModeNonSolid
VK_FALSE, // depthBounds VK_FALSE, // depthBounds
VK_FALSE, // wideLines VK_FALSE, // wideLines
VK_FALSE, // largePoints VK_TRUE, // largePoints
VK_FALSE, // alphaToOne VK_FALSE, // alphaToOne
VK_FALSE, // multiViewport VK_FALSE, // multiViewport
VK_TRUE, // samplerAnisotropy VK_TRUE, // samplerAnisotropy
......
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