Commit 70a4ef10 by Jamie Madill Committed by Commit Bot

Vulkan: Fix depth range scaling.

We were using a formula that didn't work for some of the clipping tests. Bug: angleproject:2601 Change-Id: I60d965c2701656ad590c3b250c2cc777fb432421 Reviewed-on: https://chromium-review.googlesource.com/1194919Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 161a89b1
......@@ -256,7 +256,7 @@ void ReplaceGLDepthRangeWithDriverUniform(TIntermBlock *root,
// Transformations".
// The equations reduce to an expression:
//
// z_vk = w_gl * (0.5 * z_gl + 0.5)
// z_vk = 0.5 * (w_gl + z_gl)
//
// where z_vk is the depth output of a Vulkan vertex shader and z_gl is the same for GL.
void AppendVertexShaderDepthCorrectionToMain(TIntermBlock *root, TSymbolTable *symbolTable)
......@@ -276,21 +276,18 @@ void AppendVertexShaderDepthCorrectionToMain(TIntermBlock *root, TSymbolTable *s
constantValue->setFConst(0.5f);
TIntermConstantUnion *oneHalf = new TIntermConstantUnion(constantValue, *constantType);
// Create the expression "gl_Position.z * 0.5 + 0.5"
TIntermBinary *halfZ = new TIntermBinary(TOperator::EOpMul, positionZ, oneHalf);
TIntermBinary *halfZPlusHalf = new TIntermBinary(TOperator::EOpAdd, halfZ, oneHalf->deepCopy());
// Create a swizzle to "gl_Position.w"
TVector<int> swizzleOffsetW;
swizzleOffsetW.push_back(3);
TIntermSwizzle *positionW = new TIntermSwizzle(positionRef->deepCopy(), swizzleOffsetW);
// Create the expression "gl_Position.w * (gl_Position.z * 0.5 + 0.5)"
TIntermBinary *vulkanZ = new TIntermBinary(TOperator::EOpMul, positionW, halfZPlusHalf);
// Create the expression "(gl_Position.z + gl_Position.w) * 0.5".
TIntermBinary *zPlusW = new TIntermBinary(EOpAdd, positionZ->deepCopy(), positionW->deepCopy());
TIntermBinary *halfZPlusW = new TIntermBinary(EOpMul, zPlusW, oneHalf->deepCopy());
// Create the assignment "gl_Position.z = gl_Position.w * (gl_Position.z * 0.5 + 0.5)"
// Create the assignment "gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5"
TIntermTyped *positionZLHS = positionZ->deepCopy();
TIntermBinary *assignment = new TIntermBinary(TOperator::EOpAssign, positionZLHS, vulkanZ);
TIntermBinary *assignment = new TIntermBinary(TOperator::EOpAssign, positionZLHS, halfZPlusW);
// Append the assignment as a statement at the end of the shader.
RunAtTheEndOfShader(root, assignment, symbolTable);
......
......@@ -219,6 +219,9 @@
2405 VULKAN ANDROID : dEQP-GLES2.functional.draw.random.42 = SKIP
2405 VULKAN ANDROID : dEQP-GLES2.functional.draw.random.59 = SKIP
// Fails on Nexus 5x only. TODO(jmadill): Remove suppression when possible. http://anglebug.com/2791
2791 VULKAN ANDROID : dEQP-GLES2.functional.clipping.* = SKIP
2567 GLES ANDROID : dEQP-GLES2.functional.fbo.completeness.renderable.texture.depth.red_unsigned_byte = FAIL
2567 GLES ANDROID : dEQP-GLES2.functional.fbo.completeness.renderable.texture.depth.rg_unsigned_byte = FAIL
2567 GLES ANDROID : dEQP-GLES2.functional.fbo.completeness.renderable.texture.stencil.red_unsigned_byte = FAIL
......@@ -232,10 +235,16 @@
// Vulkan failures
2598 VULKAN : dEQP-GLES2.functional.rasterization.primitives.line* = SKIP
2599 VULKAN : dEQP-GLES2.functional.rasterization.limits.points = SKIP
2601 VULKAN : dEQP-GLES2.functional.clipping.* = SKIP
2598 VULKAN : dEQP-GLES2.functional.clipping.line.wide_line_z_clip = SKIP
2598 VULKAN : dEQP-GLES2.functional.clipping.line.wide_line_z_clip_viewport_center = SKIP
2598 VULKAN : dEQP-GLES2.functional.clipping.line.wide_line_z_clip_viewport_corner = SKIP
2598 VULKAN : dEQP-GLES2.functional.clipping.line.wide_line_clip = SKIP
2598 VULKAN : dEQP-GLES2.functional.clipping.line.long_wide_line_clip = SKIP
2598 VULKAN : dEQP-GLES2.functional.clipping.line.wide_line_attrib_clip = SKIP
// Vulkan AMD Windows specific failures
2602 VULKAN WIN AMD : dEQP-GLES2.functional.buffer.write.* = SKIP
2795 VULKAN WIN AMD : dEQP-GLES2.functional.clipping.point.wide_point_clip = FAIL
// TODO(fjhenigman): Figure out why these don't work.
2405 VULKAN WIN AMD : dEQP-GLES2.functional.draw.random.14 = SKIP
......
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