Commit 25be5bb9 by Chris Forbes

Add support for BuiltInFrontFacing

- Remove Primitive::area, it is unused - Always set front/back masks - Initialize frontfacing based on front/back mask Bug: b/118386749 Test: dEQP-VK.glsl.builtin_var.* Change-Id: I8ccb5a2deb64df2dc4774a3511a5d30c09c30e5f Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29208 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent d4e5e9e0
...@@ -50,8 +50,6 @@ namespace sw ...@@ -50,8 +50,6 @@ namespace sw
PlaneEquation V[MAX_INTERFACE_COMPONENTS]; PlaneEquation V[MAX_INTERFACE_COMPONENTS];
}; };
float area;
// Masks for two-sided stencil // Masks for two-sided stencil
int64_t clockwiseMask; int64_t clockwiseMask;
int64_t invClockwiseMask; int64_t invClockwiseMask;
......
...@@ -33,6 +33,14 @@ namespace sw ...@@ -33,6 +33,14 @@ namespace sw
routine.descriptorDynamicOffsets = data + OFFSET(DrawData, descriptorDynamicOffsets); routine.descriptorDynamicOffsets = data + OFFSET(DrawData, descriptorDynamicOffsets);
routine.pushConstants = data + OFFSET(DrawData, pushConstants); routine.pushConstants = data + OFFSET(DrawData, pushConstants);
auto it = spirvShader->inputBuiltins.find(spv::BuiltInFrontFacing);
if (it != spirvShader->inputBuiltins.end())
{
ASSERT(it->second.SizeInComponents == 1);
auto frontFacing = Int4(*Pointer<Int>(primitive + OFFSET(Primitive, clockwiseMask)));
routine.getVariable(it->second.Id)[it->second.FirstComponent] = As<Float4>(frontFacing);
}
auto activeLaneMask = SIMD::Int(0xFFFFFFFF); // TODO: Control this. auto activeLaneMask = SIMD::Int(0xFFFFFFFF); // TODO: Control this.
spirvShader->emit(&routine, activeLaneMask, descriptorSets); spirvShader->emit(&routine, activeLaneMask, descriptorSets);
spirvShader->emitEpilog(&routine); spirvShader->emitEpilog(&routine);
......
...@@ -107,32 +107,21 @@ namespace sw ...@@ -107,32 +107,21 @@ namespace sw
d = IfThenElse(A > 0.0f, d, Int(0)); d = IfThenElse(A > 0.0f, d, Int(0));
if(state.twoSidedStencil) If(frontFacing)
{ {
If(frontFacing) *Pointer<Byte8>(primitive + OFFSET(Primitive,clockwiseMask)) = Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
{ *Pointer<Byte8>(primitive + OFFSET(Primitive,invClockwiseMask)) = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
*Pointer<Byte8>(primitive + OFFSET(Primitive,clockwiseMask)) = Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
*Pointer<Byte8>(primitive + OFFSET(Primitive,invClockwiseMask)) = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
}
Else
{
*Pointer<Byte8>(primitive + OFFSET(Primitive,clockwiseMask)) = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
*Pointer<Byte8>(primitive + OFFSET(Primitive,invClockwiseMask)) = Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
}
} }
Else
if(state.vFace)
{ {
*Pointer<Float>(primitive + OFFSET(Primitive,area)) = 0.5f * A; *Pointer<Byte8>(primitive + OFFSET(Primitive,clockwiseMask)) = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
*Pointer<Byte8>(primitive + OFFSET(Primitive,invClockwiseMask)) = Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
} }
} }
else else
{ {
if(state.twoSidedStencil) *Pointer<Byte8>(primitive + OFFSET(Primitive,clockwiseMask)) = Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
{ *Pointer<Byte8>(primitive + OFFSET(Primitive,invClockwiseMask)) = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
*Pointer<Byte8>(primitive + OFFSET(Primitive,clockwiseMask)) = Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
*Pointer<Byte8>(primitive + OFFSET(Primitive,invClockwiseMask)) = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
}
} }
Int n = *Pointer<Int>(polygon + OFFSET(Polygon,n)); Int n = *Pointer<Int>(polygon + OFFSET(Polygon,n));
......
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