Commit 9f796506 by Xiaoxuan Liu Committed by Commit Bot

Vulkan: Fix gl_SamplePosition XY-flip and rotation.

In multi sample scenario, gl_SamplePosition is not handled with XY-flip and rotation, add codes for flip and rotation. Bug: angleproject:5637 Test: dEQP-GLES31.functional.shaders.multisample_interpolation. interpolate_at_offset.at_sample_position.default_framebuffer --deqp-gl-config-name=rgba8888d24s8ms4 Test: dEQP-GLES31.functional.shaders.sample_variables.sample_pos. correctness.default_framebuffer --deqp-gl-config-name=rgba8888d24s8ms4 Change-Id: I7ba2227e85c62d2ca7bf534a841a1c3a5c9beb5e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2781124Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarMohan Maiya <m.maiya@samsung.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 3fd439c2
......@@ -1007,10 +1007,11 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
{
case gl::ShaderType::Fragment:
{
bool usesPointCoord = false;
bool usesFragCoord = false;
bool usesSampleMaskIn = false;
bool usesLastFragData = false;
bool usesPointCoord = false;
bool usesFragCoord = false;
bool usesSampleMaskIn = false;
bool usesLastFragData = false;
bool useSamplePosition = false;
// Search for the gl_PointCoord usage, if its used, we need to flip the y coordinate.
for (const ShaderVariable &inputVarying : mInputVaryings)
......@@ -1026,6 +1027,12 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
continue;
}
if (inputVarying.name == "gl_SamplePosition")
{
useSamplePosition = true;
continue;
}
if (inputVarying.name == "gl_PointCoord")
{
usesPointCoord = true;
......@@ -1143,6 +1150,32 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
}
}
if (useSamplePosition)
{
TIntermTyped *flipXY = specConst->getFlipXY();
if (!flipXY)
{
flipXY = driverUniforms->getFlipXYRef();
}
TIntermConstantUnion *pivot = CreateFloatNode(0.5f);
TIntermTyped *fragRotation = nullptr;
if (usePreRotation)
{
fragRotation = specConst->getFragRotationMatrix();
if (!fragRotation)
{
fragRotation = driverUniforms->getFragRotationMatrixRef();
}
}
if (!RotateAndFlipBuiltinVariable(this, root, GetMainSequence(root), flipXY,
&getSymbolTable(),
BuiltInVariable::gl_SamplePosition(),
kFlippedPointCoordName, pivot, fragRotation))
{
return false;
}
}
if (usesFragCoord)
{
if (!InsertFragCoordCorrection(this, compileOptions, root, GetMainSequence(root),
......
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