Commit dcb803a7 by Alexis Hetu Committed by Alexis Hétu

Removed SwiftShader's custom Depth/Stencil comparison enums

- Replaced DepthCompareMode, StencilCompareMode and AlphaCompareMode by VkCompareOp. - Replaced StencilOperation by VkStencilOp. Bug b/118386749 Change-Id: I7dec0cff119012345865eb164599f086edf2c88a Reviewed-on: https://swiftshader-review.googlesource.com/c/22768Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent e2ecf375
...@@ -175,29 +175,29 @@ namespace sw ...@@ -175,29 +175,29 @@ namespace sw
stencilBuffer = nullptr; stencilBuffer = nullptr;
stencilEnable = false; stencilEnable = false;
stencilCompareMode = STENCIL_ALWAYS; stencilCompareMode = VK_COMPARE_OP_ALWAYS;
stencilReference = 0; stencilReference = 0;
stencilMask = 0xFFFFFFFF; stencilMask = 0xFFFFFFFF;
stencilFailOperation = OPERATION_KEEP; stencilFailOperation = VK_STENCIL_OP_KEEP;
stencilPassOperation = OPERATION_KEEP; stencilPassOperation = VK_STENCIL_OP_KEEP;
stencilZFailOperation = OPERATION_KEEP; stencilZFailOperation = VK_STENCIL_OP_KEEP;
stencilWriteMask = 0xFFFFFFFF; stencilWriteMask = 0xFFFFFFFF;
twoSidedStencil = false; twoSidedStencil = false;
stencilCompareModeCCW = STENCIL_ALWAYS; stencilCompareModeCCW = VK_COMPARE_OP_ALWAYS;
stencilReferenceCCW = 0; stencilReferenceCCW = 0;
stencilMaskCCW = 0xFFFFFFFF; stencilMaskCCW = 0xFFFFFFFF;
stencilFailOperationCCW = OPERATION_KEEP; stencilFailOperationCCW = VK_STENCIL_OP_KEEP;
stencilPassOperationCCW = OPERATION_KEEP; stencilPassOperationCCW = VK_STENCIL_OP_KEEP;
stencilZFailOperationCCW = OPERATION_KEEP; stencilZFailOperationCCW = VK_STENCIL_OP_KEEP;
stencilWriteMaskCCW = 0xFFFFFFFF; stencilWriteMaskCCW = 0xFFFFFFFF;
alphaCompareMode = ALPHA_ALWAYS; alphaCompareMode = VK_COMPARE_OP_ALWAYS;
alphaTestEnable = false; alphaTestEnable = false;
rasterizerDiscard = false; rasterizerDiscard = false;
depthCompareMode = DEPTH_LESS; depthCompareMode = VK_COMPARE_OP_LESS;
depthBufferEnable = true; depthBufferEnable = true;
depthWriteEnable = true; depthWriteEnable = true;
...@@ -343,8 +343,8 @@ namespace sw ...@@ -343,8 +343,8 @@ namespace sw
{ {
if(transparencyAntialiasing != TRANSPARENCY_NONE) return true; if(transparencyAntialiasing != TRANSPARENCY_NONE) return true;
if(!alphaTestEnable) return false; if(!alphaTestEnable) return false;
if(alphaCompareMode == ALPHA_ALWAYS) return false; if(alphaCompareMode == VK_COMPARE_OP_ALWAYS) return false;
if(alphaReference == 0.0f && alphaCompareMode == ALPHA_GREATEREQUAL) return false; if(alphaReference == 0.0f && alphaCompareMode == VK_COMPARE_OP_GREATER_OR_EQUAL) return false;
return true; return true;
} }
......
...@@ -84,62 +84,6 @@ namespace sw ...@@ -84,62 +84,6 @@ namespace sw
DRAW_LAST = DRAW_INDEXEDTRIANGLEFAN32 DRAW_LAST = DRAW_INDEXEDTRIANGLEFAN32
}; };
enum DepthCompareMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
{
DEPTH_ALWAYS,
DEPTH_NEVER,
DEPTH_EQUAL,
DEPTH_NOTEQUAL,
DEPTH_LESS,
DEPTH_LESSEQUAL,
DEPTH_GREATER,
DEPTH_GREATEREQUAL,
DEPTH_LAST = DEPTH_GREATEREQUAL
};
enum StencilCompareMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
{
STENCIL_ALWAYS,
STENCIL_NEVER,
STENCIL_EQUAL,
STENCIL_NOTEQUAL,
STENCIL_LESS,
STENCIL_LESSEQUAL,
STENCIL_GREATER,
STENCIL_GREATEREQUAL,
STENCIL_LAST = STENCIL_GREATEREQUAL
};
enum StencilOperation ENUM_UNDERLYING_TYPE_UNSIGNED_INT
{
OPERATION_KEEP,
OPERATION_ZERO,
OPERATION_REPLACE,
OPERATION_INCRSAT,
OPERATION_DECRSAT,
OPERATION_INVERT,
OPERATION_INCR,
OPERATION_DECR,
OPERATION_LAST = OPERATION_DECR
};
enum AlphaCompareMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
{
ALPHA_ALWAYS,
ALPHA_NEVER,
ALPHA_EQUAL,
ALPHA_NOTEQUAL,
ALPHA_LESS,
ALPHA_LESSEQUAL,
ALPHA_GREATER,
ALPHA_GREATEREQUAL,
ALPHA_LAST = ALPHA_GREATEREQUAL
};
enum CullMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT enum CullMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
{ {
CULL_NONE, CULL_NONE,
...@@ -275,25 +219,25 @@ namespace sw ...@@ -275,25 +219,25 @@ namespace sw
DrawType drawType; DrawType drawType;
bool stencilEnable; bool stencilEnable;
StencilCompareMode stencilCompareMode; VkCompareOp stencilCompareMode;
int stencilReference; int stencilReference;
int stencilMask; int stencilMask;
StencilOperation stencilFailOperation; VkStencilOp stencilFailOperation;
StencilOperation stencilPassOperation; VkStencilOp stencilPassOperation;
StencilOperation stencilZFailOperation; VkStencilOp stencilZFailOperation;
int stencilWriteMask; int stencilWriteMask;
bool twoSidedStencil; bool twoSidedStencil;
StencilCompareMode stencilCompareModeCCW; VkCompareOp stencilCompareModeCCW;
int stencilReferenceCCW; int stencilReferenceCCW;
int stencilMaskCCW; int stencilMaskCCW;
StencilOperation stencilFailOperationCCW; VkStencilOp stencilFailOperationCCW;
StencilOperation stencilPassOperationCCW; VkStencilOp stencilPassOperationCCW;
StencilOperation stencilZFailOperationCCW; VkStencilOp stencilZFailOperationCCW;
int stencilWriteMaskCCW; int stencilWriteMaskCCW;
// Pixel processor states // Pixel processor states
AlphaCompareMode alphaCompareMode; VkCompareOp alphaCompareMode;
bool alphaTestEnable; bool alphaTestEnable;
CullMode cullMode; CullMode cullMode;
...@@ -335,7 +279,7 @@ namespace sw ...@@ -335,7 +279,7 @@ namespace sw
// Pixel processor states // Pixel processor states
bool rasterizerDiscard; bool rasterizerDiscard;
bool depthBufferEnable; bool depthBufferEnable;
DepthCompareMode depthCompareMode; VkCompareOp depthCompareMode;
bool depthWriteEnable; bool depthWriteEnable;
bool alphaBlendEnable; bool alphaBlendEnable;
......
...@@ -343,12 +343,12 @@ namespace sw ...@@ -343,12 +343,12 @@ namespace sw
context->setDepthBufferEnable(depthBufferEnable); context->setDepthBufferEnable(depthBufferEnable);
} }
void PixelProcessor::setDepthCompare(DepthCompareMode depthCompareMode) void PixelProcessor::setDepthCompare(VkCompareOp depthCompareMode)
{ {
context->depthCompareMode = depthCompareMode; context->depthCompareMode = depthCompareMode;
} }
void PixelProcessor::setAlphaCompare(AlphaCompareMode alphaCompareMode) void PixelProcessor::setAlphaCompare(VkCompareOp alphaCompareMode)
{ {
context->alphaCompareMode = alphaCompareMode; context->alphaCompareMode = alphaCompareMode;
} }
...@@ -379,7 +379,7 @@ namespace sw ...@@ -379,7 +379,7 @@ namespace sw
context->stencilEnable = stencilEnable; context->stencilEnable = stencilEnable;
} }
void PixelProcessor::setStencilCompare(StencilCompareMode stencilCompareMode) void PixelProcessor::setStencilCompare(VkCompareOp stencilCompareMode)
{ {
context->stencilCompareMode = stencilCompareMode; context->stencilCompareMode = stencilCompareMode;
} }
...@@ -408,17 +408,17 @@ namespace sw ...@@ -408,17 +408,17 @@ namespace sw
stencilCCW.set(context->stencilReferenceCCW, stencilMaskCCW, context->stencilWriteMaskCCW); stencilCCW.set(context->stencilReferenceCCW, stencilMaskCCW, context->stencilWriteMaskCCW);
} }
void PixelProcessor::setStencilFailOperation(StencilOperation stencilFailOperation) void PixelProcessor::setStencilFailOperation(VkStencilOp stencilFailOperation)
{ {
context->stencilFailOperation = stencilFailOperation; context->stencilFailOperation = stencilFailOperation;
} }
void PixelProcessor::setStencilPassOperation(StencilOperation stencilPassOperation) void PixelProcessor::setStencilPassOperation(VkStencilOp stencilPassOperation)
{ {
context->stencilPassOperation = stencilPassOperation; context->stencilPassOperation = stencilPassOperation;
} }
void PixelProcessor::setStencilZFailOperation(StencilOperation stencilZFailOperation) void PixelProcessor::setStencilZFailOperation(VkStencilOp stencilZFailOperation)
{ {
context->stencilZFailOperation = stencilZFailOperation; context->stencilZFailOperation = stencilZFailOperation;
} }
...@@ -440,22 +440,22 @@ namespace sw ...@@ -440,22 +440,22 @@ namespace sw
context->twoSidedStencil = enable; context->twoSidedStencil = enable;
} }
void PixelProcessor::setStencilCompareCCW(StencilCompareMode stencilCompareMode) void PixelProcessor::setStencilCompareCCW(VkCompareOp stencilCompareMode)
{ {
context->stencilCompareModeCCW = stencilCompareMode; context->stencilCompareModeCCW = stencilCompareMode;
} }
void PixelProcessor::setStencilFailOperationCCW(StencilOperation stencilFailOperation) void PixelProcessor::setStencilFailOperationCCW(VkStencilOp stencilFailOperation)
{ {
context->stencilFailOperationCCW = stencilFailOperation; context->stencilFailOperationCCW = stencilFailOperation;
} }
void PixelProcessor::setStencilPassOperationCCW(StencilOperation stencilPassOperation) void PixelProcessor::setStencilPassOperationCCW(VkStencilOp stencilPassOperation)
{ {
context->stencilPassOperationCCW = stencilPassOperation; context->stencilPassOperationCCW = stencilPassOperation;
} }
void PixelProcessor::setStencilZFailOperationCCW(StencilOperation stencilZFailOperation) void PixelProcessor::setStencilZFailOperationCCW(VkStencilOp stencilZFailOperation)
{ {
context->stencilZFailOperationCCW = stencilZFailOperation; context->stencilZFailOperationCCW = stencilZFailOperation;
} }
......
...@@ -37,24 +37,24 @@ namespace sw ...@@ -37,24 +37,24 @@ namespace sw
bool depthOverride : 1; // TODO: Eliminate by querying shader. bool depthOverride : 1; // TODO: Eliminate by querying shader.
bool shaderContainsKill : 1; // TODO: Eliminate by querying shader. bool shaderContainsKill : 1; // TODO: Eliminate by querying shader.
DepthCompareMode depthCompareMode : BITS(DEPTH_LAST); VkCompareOp depthCompareMode : BITS(VK_COMPARE_OP_END_RANGE);
AlphaCompareMode alphaCompareMode : BITS(ALPHA_LAST); VkCompareOp alphaCompareMode : BITS(VK_COMPARE_OP_END_RANGE);
bool depthWriteEnable : 1; bool depthWriteEnable : 1;
bool quadLayoutDepthBuffer : 1; bool quadLayoutDepthBuffer : 1;
bool stencilActive : 1; bool stencilActive : 1;
StencilCompareMode stencilCompareMode : BITS(STENCIL_LAST); VkCompareOp stencilCompareMode : BITS(VK_COMPARE_OP_END_RANGE);
StencilOperation stencilFailOperation : BITS(OPERATION_LAST); VkStencilOp stencilFailOperation : BITS(VK_STENCIL_OP_END_RANGE);
StencilOperation stencilPassOperation : BITS(OPERATION_LAST); VkStencilOp stencilPassOperation : BITS(VK_STENCIL_OP_END_RANGE);
StencilOperation stencilZFailOperation : BITS(OPERATION_LAST); VkStencilOp stencilZFailOperation : BITS(VK_STENCIL_OP_END_RANGE);
bool noStencilMask : 1; bool noStencilMask : 1;
bool noStencilWriteMask : 1; bool noStencilWriteMask : 1;
bool stencilWriteMasked : 1; bool stencilWriteMasked : 1;
bool twoSidedStencil : 1; bool twoSidedStencil : 1;
StencilCompareMode stencilCompareModeCCW : BITS(STENCIL_LAST); VkCompareOp stencilCompareModeCCW : BITS(VK_COMPARE_OP_END_RANGE);
StencilOperation stencilFailOperationCCW : BITS(OPERATION_LAST); VkStencilOp stencilFailOperationCCW : BITS(VK_STENCIL_OP_END_RANGE);
StencilOperation stencilPassOperationCCW : BITS(OPERATION_LAST); VkStencilOp stencilPassOperationCCW : BITS(VK_STENCIL_OP_END_RANGE);
StencilOperation stencilZFailOperationCCW : BITS(OPERATION_LAST); VkStencilOp stencilZFailOperationCCW : BITS(VK_STENCIL_OP_END_RANGE);
bool noStencilMaskCCW : 1; bool noStencilMaskCCW : 1;
bool noStencilWriteMaskCCW : 1; bool noStencilWriteMaskCCW : 1;
bool stencilWriteMaskedCCW : 1; bool stencilWriteMaskedCCW : 1;
...@@ -119,7 +119,7 @@ namespace sw ...@@ -119,7 +119,7 @@ namespace sw
bool alphaTestActive() const bool alphaTestActive() const
{ {
return (alphaCompareMode != ALPHA_ALWAYS) || (transparencyAntialiasing != TRANSPARENCY_NONE); return (alphaCompareMode != VK_COMPARE_OP_ALWAYS) || (transparencyAntialiasing != TRANSPARENCY_NONE);
} }
unsigned int hash; unsigned int hash;
...@@ -209,8 +209,8 @@ namespace sw ...@@ -209,8 +209,8 @@ namespace sw
void setWriteSRGB(bool sRGB); void setWriteSRGB(bool sRGB);
void setDepthBufferEnable(bool depthBufferEnable); void setDepthBufferEnable(bool depthBufferEnable);
void setDepthCompare(DepthCompareMode depthCompareMode); void setDepthCompare(VkCompareOp depthCompareMode);
void setAlphaCompare(AlphaCompareMode alphaCompareMode); void setAlphaCompare(VkCompareOp alphaCompareMode);
void setDepthWriteEnable(bool depthWriteEnable); void setDepthWriteEnable(bool depthWriteEnable);
void setAlphaTestEnable(bool alphaTestEnable); void setAlphaTestEnable(bool alphaTestEnable);
void setCullMode(CullMode cullMode, bool frontFacingCCW); void setCullMode(CullMode cullMode, bool frontFacingCCW);
...@@ -220,20 +220,20 @@ namespace sw ...@@ -220,20 +220,20 @@ namespace sw
void setLogicalOperation(LogicalOperation logicalOperation); void setLogicalOperation(LogicalOperation logicalOperation);
void setStencilEnable(bool stencilEnable); void setStencilEnable(bool stencilEnable);
void setStencilCompare(StencilCompareMode stencilCompareMode); void setStencilCompare(VkCompareOp stencilCompareMode);
void setStencilReference(int stencilReference); void setStencilReference(int stencilReference);
void setStencilMask(int stencilMask); void setStencilMask(int stencilMask);
void setStencilFailOperation(StencilOperation stencilFailOperation); void setStencilFailOperation(VkStencilOp stencilFailOperation);
void setStencilPassOperation(StencilOperation stencilPassOperation); void setStencilPassOperation(VkStencilOp stencilPassOperation);
void setStencilZFailOperation(StencilOperation stencilZFailOperation); void setStencilZFailOperation(VkStencilOp stencilZFailOperation);
void setStencilWriteMask(int stencilWriteMask); void setStencilWriteMask(int stencilWriteMask);
void setTwoSidedStencil(bool enable); void setTwoSidedStencil(bool enable);
void setStencilCompareCCW(StencilCompareMode stencilCompareMode); void setStencilCompareCCW(VkCompareOp stencilCompareMode);
void setStencilReferenceCCW(int stencilReference); void setStencilReferenceCCW(int stencilReference);
void setStencilMaskCCW(int stencilMask); void setStencilMaskCCW(int stencilMask);
void setStencilFailOperationCCW(StencilOperation stencilFailOperation); void setStencilFailOperationCCW(VkStencilOp stencilFailOperation);
void setStencilPassOperationCCW(StencilOperation stencilPassOperation); void setStencilPassOperationCCW(VkStencilOp stencilPassOperation);
void setStencilZFailOperationCCW(StencilOperation stencilZFailOperation); void setStencilZFailOperationCCW(VkStencilOp stencilZFailOperation);
void setStencilWriteMaskCCW(int stencilWriteMask); void setStencilWriteMaskCCW(int stencilWriteMask);
void setBlendConstant(const Color<float> &blendConstant); void setBlendConstant(const Color<float> &blendConstant);
......
...@@ -161,7 +161,7 @@ namespace sw ...@@ -161,7 +161,7 @@ namespace sw
if(veryEarlyDepthTest && state.multiSample == 1 && !state.depthOverride) if(veryEarlyDepthTest && state.multiSample == 1 && !state.depthOverride)
{ {
if(!state.stencilActive && state.depthTestActive && (state.depthCompareMode == DEPTH_LESSEQUAL || state.depthCompareMode == DEPTH_LESS)) // FIXME: Both modes ok? if(!state.stencilActive && state.depthTestActive && (state.depthCompareMode == VK_COMPARE_OP_LESS_OR_EQUAL || state.depthCompareMode == VK_COMPARE_OP_LESS)) // FIXME: Both modes ok?
{ {
Float4 xxxx = Float4(Float(x0)) + *Pointer<Float4>(primitive + OFFSET(Primitive,xQuad), 16); Float4 xxxx = Float4(Float(x0)) + *Pointer<Float4>(primitive + OFFSET(Primitive,xQuad), 16);
......
...@@ -339,43 +339,43 @@ namespace sw ...@@ -339,43 +339,43 @@ namespace sw
sMask = SignMask(value) & cMask; sMask = SignMask(value) & cMask;
} }
void PixelRoutine::stencilTest(Byte8 &value, StencilCompareMode stencilCompareMode, bool CCW) void PixelRoutine::stencilTest(Byte8 &value, VkCompareOp stencilCompareMode, bool CCW)
{ {
Byte8 equal; Byte8 equal;
switch(stencilCompareMode) switch(stencilCompareMode)
{ {
case STENCIL_ALWAYS: case VK_COMPARE_OP_ALWAYS:
value = Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); value = Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
break; break;
case STENCIL_NEVER: case VK_COMPARE_OP_NEVER:
value = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); value = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
break; break;
case STENCIL_LESS: // a < b ~ b > a case VK_COMPARE_OP_LESS: // a < b ~ b > a
value += Byte8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80); value += Byte8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80);
value = CmpGT(As<SByte8>(value), *Pointer<SByte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedSignedQ))); value = CmpGT(As<SByte8>(value), *Pointer<SByte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedSignedQ)));
break; break;
case STENCIL_EQUAL: case VK_COMPARE_OP_EQUAL:
value = CmpEQ(value, *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedQ))); value = CmpEQ(value, *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedQ)));
break; break;
case STENCIL_NOTEQUAL: // a != b ~ !(a == b) case VK_COMPARE_OP_NOT_EQUAL: // a != b ~ !(a == b)
value = CmpEQ(value, *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedQ))); value = CmpEQ(value, *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedQ)));
value ^= Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); value ^= Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
break; break;
case STENCIL_LESSEQUAL: // a <= b ~ (b > a) || (a == b) case VK_COMPARE_OP_LESS_OR_EQUAL: // a <= b ~ (b > a) || (a == b)
equal = value; equal = value;
equal = CmpEQ(equal, *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedQ))); equal = CmpEQ(equal, *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedQ)));
value += Byte8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80); value += Byte8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80);
value = CmpGT(As<SByte8>(value), *Pointer<SByte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedSignedQ))); value = CmpGT(As<SByte8>(value), *Pointer<SByte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedSignedQ)));
value |= equal; value |= equal;
break; break;
case STENCIL_GREATER: // a > b case VK_COMPARE_OP_GREATER: // a > b
equal = *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedSignedQ)); equal = *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedSignedQ));
value += Byte8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80); value += Byte8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80);
equal = CmpGT(As<SByte8>(equal), As<SByte8>(value)); equal = CmpGT(As<SByte8>(equal), As<SByte8>(value));
value = equal; value = equal;
break; break;
case STENCIL_GREATEREQUAL: // a >= b ~ !(a < b) ~ !(b > a) case VK_COMPARE_OP_GREATER_OR_EQUAL: // a >= b ~ !(a < b) ~ !(b > a)
value += Byte8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80); value += Byte8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80);
value = CmpGT(As<SByte8>(value), *Pointer<SByte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedSignedQ))); value = CmpGT(As<SByte8>(value), *Pointer<SByte8>(data + OFFSET(DrawData,stencil[CCW].referenceMaskedSignedQ)));
value ^= Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); value ^= Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
...@@ -426,7 +426,7 @@ namespace sw ...@@ -426,7 +426,7 @@ namespace sw
Float4 zValue; Float4 zValue;
if(state.depthCompareMode != DEPTH_NEVER || (state.depthCompareMode != DEPTH_ALWAYS && !state.depthWriteEnable)) if(state.depthCompareMode != VK_COMPARE_OP_NEVER || (state.depthCompareMode != VK_COMPARE_OP_ALWAYS && !state.depthWriteEnable))
{ {
if(!state.quadLayoutDepthBuffer) if(!state.quadLayoutDepthBuffer)
{ {
...@@ -444,19 +444,19 @@ namespace sw ...@@ -444,19 +444,19 @@ namespace sw
switch(state.depthCompareMode) switch(state.depthCompareMode)
{ {
case DEPTH_ALWAYS: case VK_COMPARE_OP_ALWAYS:
// Optimized // Optimized
break; break;
case DEPTH_NEVER: case VK_COMPARE_OP_NEVER:
// Optimized // Optimized
break; break;
case DEPTH_EQUAL: case VK_COMPARE_OP_EQUAL:
zTest = CmpEQ(zValue, Z); zTest = CmpEQ(zValue, Z);
break; break;
case DEPTH_NOTEQUAL: case VK_COMPARE_OP_NOT_EQUAL:
zTest = CmpNEQ(zValue, Z); zTest = CmpNEQ(zValue, Z);
break; break;
case DEPTH_LESS: case VK_COMPARE_OP_LESS:
if(complementaryDepthBuffer) if(complementaryDepthBuffer)
{ {
zTest = CmpLT(zValue, Z); zTest = CmpLT(zValue, Z);
...@@ -466,7 +466,7 @@ namespace sw ...@@ -466,7 +466,7 @@ namespace sw
zTest = CmpNLE(zValue, Z); zTest = CmpNLE(zValue, Z);
} }
break; break;
case DEPTH_GREATEREQUAL: case VK_COMPARE_OP_GREATER_OR_EQUAL:
if(complementaryDepthBuffer) if(complementaryDepthBuffer)
{ {
zTest = CmpNLT(zValue, Z); zTest = CmpNLT(zValue, Z);
...@@ -476,7 +476,7 @@ namespace sw ...@@ -476,7 +476,7 @@ namespace sw
zTest = CmpLE(zValue, Z); zTest = CmpLE(zValue, Z);
} }
break; break;
case DEPTH_LESSEQUAL: case VK_COMPARE_OP_LESS_OR_EQUAL:
if(complementaryDepthBuffer) if(complementaryDepthBuffer)
{ {
zTest = CmpLE(zValue, Z); zTest = CmpLE(zValue, Z);
...@@ -486,7 +486,7 @@ namespace sw ...@@ -486,7 +486,7 @@ namespace sw
zTest = CmpNLT(zValue, Z); zTest = CmpNLT(zValue, Z);
} }
break; break;
case DEPTH_GREATER: case VK_COMPARE_OP_GREATER:
if(complementaryDepthBuffer) if(complementaryDepthBuffer)
{ {
zTest = CmpNLE(zValue, Z); zTest = CmpNLE(zValue, Z);
...@@ -502,10 +502,10 @@ namespace sw ...@@ -502,10 +502,10 @@ namespace sw
switch(state.depthCompareMode) switch(state.depthCompareMode)
{ {
case DEPTH_ALWAYS: case VK_COMPARE_OP_ALWAYS:
zMask = cMask; zMask = cMask;
break; break;
case DEPTH_NEVER: case VK_COMPARE_OP_NEVER:
zMask = 0x0; zMask = 0x0;
break; break;
default: default:
...@@ -528,35 +528,35 @@ namespace sw ...@@ -528,35 +528,35 @@ namespace sw
switch(state.alphaCompareMode) switch(state.alphaCompareMode)
{ {
case ALPHA_ALWAYS: case VK_COMPARE_OP_ALWAYS:
aMask = 0xF; aMask = 0xF;
break; break;
case ALPHA_NEVER: case VK_COMPARE_OP_NEVER:
aMask = 0x0; aMask = 0x0;
break; break;
case ALPHA_EQUAL: case VK_COMPARE_OP_EQUAL:
cmp = CmpEQ(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4))); cmp = CmpEQ(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4)));
aMask = SignMask(PackSigned(cmp, Short4(0x0000))); aMask = SignMask(PackSigned(cmp, Short4(0x0000)));
break; break;
case ALPHA_NOTEQUAL: // a != b ~ !(a == b) case VK_COMPARE_OP_NOT_EQUAL: // a != b ~ !(a == b)
cmp = CmpEQ(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4))) ^ Short4(0xFFFFu); // FIXME cmp = CmpEQ(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4))) ^ Short4(0xFFFFu); // FIXME
aMask = SignMask(PackSigned(cmp, Short4(0x0000))); aMask = SignMask(PackSigned(cmp, Short4(0x0000)));
break; break;
case ALPHA_LESS: // a < b ~ b > a case VK_COMPARE_OP_LESS: // a < b ~ b > a
cmp = CmpGT(*Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4)), alpha); cmp = CmpGT(*Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4)), alpha);
aMask = SignMask(PackSigned(cmp, Short4(0x0000))); aMask = SignMask(PackSigned(cmp, Short4(0x0000)));
break; break;
case ALPHA_GREATEREQUAL: // a >= b ~ (a > b) || (a == b) ~ !(b > a) // TODO: Approximate case VK_COMPARE_OP_GREATER_OR_EQUAL: // a >= b ~ (a > b) || (a == b) ~ !(b > a) // TODO: Approximate
equal = CmpEQ(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4))); equal = CmpEQ(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4)));
cmp = CmpGT(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4))); cmp = CmpGT(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4)));
cmp |= equal; cmp |= equal;
aMask = SignMask(PackSigned(cmp, Short4(0x0000))); aMask = SignMask(PackSigned(cmp, Short4(0x0000)));
break; break;
case ALPHA_LESSEQUAL: // a <= b ~ !(a > b) case VK_COMPARE_OP_LESS_OR_EQUAL: // a <= b ~ !(a > b)
cmp = CmpGT(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4))) ^ Short4(0xFFFFu); // FIXME cmp = CmpGT(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4))) ^ Short4(0xFFFFu); // FIXME
aMask = SignMask(PackSigned(cmp, Short4(0x0000))); aMask = SignMask(PackSigned(cmp, Short4(0x0000)));
break; break;
case ALPHA_GREATER: // a > b case VK_COMPARE_OP_GREATER: // a > b
cmp = CmpGT(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4))); cmp = CmpGT(alpha, *Pointer<Short4>(data + OFFSET(DrawData,factor.alphaReference4)));
aMask = SignMask(PackSigned(cmp, Short4(0x0000))); aMask = SignMask(PackSigned(cmp, Short4(0x0000)));
break; break;
...@@ -624,7 +624,7 @@ namespace sw ...@@ -624,7 +624,7 @@ namespace sw
Float4 zValue; Float4 zValue;
if(state.depthCompareMode != DEPTH_NEVER || (state.depthCompareMode != DEPTH_ALWAYS && !state.depthWriteEnable)) if(state.depthCompareMode != VK_COMPARE_OP_NEVER || (state.depthCompareMode != VK_COMPARE_OP_ALWAYS && !state.depthWriteEnable))
{ {
if(!state.quadLayoutDepthBuffer) if(!state.quadLayoutDepthBuffer)
{ {
...@@ -661,9 +661,9 @@ namespace sw ...@@ -661,9 +661,9 @@ namespace sw
return; return;
} }
if(state.stencilPassOperation == OPERATION_KEEP && state.stencilZFailOperation == OPERATION_KEEP && state.stencilFailOperation == OPERATION_KEEP) if(state.stencilPassOperation == VK_STENCIL_OP_KEEP && state.stencilZFailOperation == VK_STENCIL_OP_KEEP && state.stencilFailOperation == VK_STENCIL_OP_KEEP)
{ {
if(!state.twoSidedStencil || (state.stencilPassOperationCCW == OPERATION_KEEP && state.stencilZFailOperationCCW == OPERATION_KEEP && state.stencilFailOperationCCW == OPERATION_KEEP)) if(!state.twoSidedStencil || (state.stencilPassOperationCCW == VK_STENCIL_OP_KEEP && state.stencilZFailOperationCCW == VK_STENCIL_OP_KEEP && state.stencilFailOperationCCW == VK_STENCIL_OP_KEEP))
{ {
return; return;
} }
...@@ -720,7 +720,7 @@ namespace sw ...@@ -720,7 +720,7 @@ namespace sw
*Pointer<Byte4>(buffer) = Byte4(newValue); *Pointer<Byte4>(buffer) = Byte4(newValue);
} }
void PixelRoutine::stencilOperation(Byte8 &newValue, Byte8 &bufferValue, StencilOperation stencilPassOperation, StencilOperation stencilZFailOperation, StencilOperation stencilFailOperation, bool CCW, Int &zMask, Int &sMask) void PixelRoutine::stencilOperation(Byte8 &newValue, Byte8 &bufferValue, VkStencilOp stencilPassOperation, VkStencilOp stencilZFailOperation, VkStencilOp stencilFailOperation, bool CCW, Int &zMask, Int &sMask)
{ {
Byte8 &pass = newValue; Byte8 &pass = newValue;
Byte8 fail; Byte8 fail;
...@@ -753,32 +753,32 @@ namespace sw ...@@ -753,32 +753,32 @@ namespace sw
} }
} }
void PixelRoutine::stencilOperation(Byte8 &output, Byte8 &bufferValue, StencilOperation operation, bool CCW) void PixelRoutine::stencilOperation(Byte8 &output, Byte8 &bufferValue, VkStencilOp operation, bool CCW)
{ {
switch(operation) switch(operation)
{ {
case OPERATION_KEEP: case VK_STENCIL_OP_KEEP:
output = bufferValue; output = bufferValue;
break; break;
case OPERATION_ZERO: case VK_STENCIL_OP_ZERO:
output = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); output = Byte8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
break; break;
case OPERATION_REPLACE: case VK_STENCIL_OP_REPLACE:
output = *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceQ)); output = *Pointer<Byte8>(data + OFFSET(DrawData,stencil[CCW].referenceQ));
break; break;
case OPERATION_INCRSAT: case VK_STENCIL_OP_INCREMENT_AND_CLAMP:
output = AddSat(bufferValue, Byte8(1, 1, 1, 1, 1, 1, 1, 1)); output = AddSat(bufferValue, Byte8(1, 1, 1, 1, 1, 1, 1, 1));
break; break;
case OPERATION_DECRSAT: case VK_STENCIL_OP_DECREMENT_AND_CLAMP:
output = SubSat(bufferValue, Byte8(1, 1, 1, 1, 1, 1, 1, 1)); output = SubSat(bufferValue, Byte8(1, 1, 1, 1, 1, 1, 1, 1));
break; break;
case OPERATION_INVERT: case VK_STENCIL_OP_INVERT:
output = bufferValue ^ Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); output = bufferValue ^ Byte8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
break; break;
case OPERATION_INCR: case VK_STENCIL_OP_INCREMENT_AND_WRAP:
output = bufferValue + Byte8(1, 1, 1, 1, 1, 1, 1, 1); output = bufferValue + Byte8(1, 1, 1, 1, 1, 1, 1, 1);
break; break;
case OPERATION_DECR: case VK_STENCIL_OP_DECREMENT_AND_WRAP:
output = bufferValue - Byte8(1, 1, 1, 1, 1, 1, 1, 1); output = bufferValue - Byte8(1, 1, 1, 1, 1, 1, 1, 1);
break; break;
default: default:
......
...@@ -66,9 +66,9 @@ namespace sw ...@@ -66,9 +66,9 @@ namespace sw
private: private:
Float4 interpolateCentroid(Float4 &x, Float4 &y, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective); Float4 interpolateCentroid(Float4 &x, Float4 &y, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective);
void stencilTest(Pointer<Byte> &sBuffer, int q, Int &x, Int &sMask, Int &cMask); void stencilTest(Pointer<Byte> &sBuffer, int q, Int &x, Int &sMask, Int &cMask);
void stencilTest(Byte8 &value, StencilCompareMode stencilCompareMode, bool CCW); void stencilTest(Byte8 &value, VkCompareOp stencilCompareMode, bool CCW);
void stencilOperation(Byte8 &newValue, Byte8 &bufferValue, StencilOperation stencilPassOperation, StencilOperation stencilZFailOperation, StencilOperation stencilFailOperation, bool CCW, Int &zMask, Int &sMask); void stencilOperation(Byte8 &newValue, Byte8 &bufferValue, VkStencilOp stencilPassOperation, VkStencilOp stencilZFailOperation, VkStencilOp stencilFailOperation, bool CCW, Int &zMask, Int &sMask);
void stencilOperation(Byte8 &output, Byte8 &bufferValue, StencilOperation operation, bool CCW); void stencilOperation(Byte8 &output, Byte8 &bufferValue, VkStencilOp operation, bool CCW);
Bool depthTest(Pointer<Byte> &zBuffer, int q, Int &x, Float4 &z, Int &sMask, Int &zMask, Int &cMask); Bool depthTest(Pointer<Byte> &zBuffer, int q, Int &x, Float4 &z, Int &sMask, Int &zMask, Int &cMask);
// Raster operations // Raster operations
......
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