Add StencilStateFaceDescriptor, in order to match web idl
BUG=dawn:31 Change-Id: I52f95ed134ae5afdf4fc872d5cfc5f36ec1a7a69 Reviewed-on: https://dawn-review.googlesource.com/c/3302 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
parent
8d7de591f4
commit
48485e36a8
15
dawn.json
15
dawn.json
|
@ -550,10 +550,7 @@
|
||||||
"name": "set stencil function",
|
"name": "set stencil function",
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "face", "type": "face"},
|
{"name": "face", "type": "face"},
|
||||||
{"name": "stencil compare function", "type": "compare function"},
|
{"name": "descriptor", "type": "stencil state face descriptor", "annotation": "const*"}
|
||||||
{"name": "stencil failure operation", "type": "stencil operation"},
|
|
||||||
{"name": "depth failure operation", "type": "stencil operation"},
|
|
||||||
{"name": "stencil pass operation", "type": "stencil operation"}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -965,6 +962,16 @@
|
||||||
{"value": 7, "name": "decrement wrap"}
|
{"value": 7, "name": "decrement wrap"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"stencil state face descriptor": {
|
||||||
|
"category": "structure",
|
||||||
|
"extensible": false,
|
||||||
|
"members": [
|
||||||
|
{"name": "compare", "type": "compare function"},
|
||||||
|
{"name": "stencil fail op", "type": "stencil operation"},
|
||||||
|
{"name": "depth fail op", "type": "stencil operation"},
|
||||||
|
{"name": "pass op", "type": "stencil operation"}
|
||||||
|
]
|
||||||
|
},
|
||||||
"swap chain": {
|
"swap chain": {
|
||||||
"category": "object",
|
"category": "object",
|
||||||
"methods": [
|
"methods": [
|
||||||
|
|
|
@ -211,11 +211,16 @@ void init() {
|
||||||
|
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
|
dawn::StencilStateFaceDescriptor planeStencilDescriptor;
|
||||||
|
planeStencilDescriptor.compare = dawn::CompareFunction::Always;
|
||||||
|
planeStencilDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
|
planeStencilDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
planeStencilDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
auto planeStencilState = device.CreateDepthStencilStateBuilder()
|
auto planeStencilState = device.CreateDepthStencilStateBuilder()
|
||||||
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
||||||
.SetDepthWriteEnabled(false)
|
.SetDepthWriteEnabled(false)
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
.SetStencilFunction(dawn::Face::Both, &planeStencilDescriptor)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor pDescriptor(device);
|
utils::ComboRenderPipelineDescriptor pDescriptor(device);
|
||||||
pDescriptor.layout = pl;
|
pDescriptor.layout = pl;
|
||||||
|
@ -230,11 +235,17 @@ void init() {
|
||||||
|
|
||||||
planePipeline = device.CreateRenderPipeline(&pDescriptor);
|
planePipeline = device.CreateRenderPipeline(&pDescriptor);
|
||||||
|
|
||||||
auto reflectionStencilState = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor reflectionStencilDescriptor;
|
||||||
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
reflectionStencilDescriptor.compare = dawn::CompareFunction::Equal;
|
||||||
.SetDepthWriteEnabled(true)
|
reflectionStencilDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Equal, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
reflectionStencilDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
.GetResult();
|
reflectionStencilDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
auto reflectionStencilState =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
||||||
|
.SetDepthWriteEnabled(true)
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &reflectionStencilDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor rfDescriptor(device);
|
utils::ComboRenderPipelineDescriptor rfDescriptor(device);
|
||||||
rfDescriptor.layout = pl;
|
rfDescriptor.layout = pl;
|
||||||
|
|
|
@ -27,14 +27,14 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DepthStencilStateBase::StencilTestEnabled() const {
|
bool DepthStencilStateBase::StencilTestEnabled() const {
|
||||||
return mStencilInfo.back.compareFunction != dawn::CompareFunction::Always ||
|
return mStencilInfo.back.compare != dawn::CompareFunction::Always ||
|
||||||
mStencilInfo.back.stencilFail != dawn::StencilOperation::Keep ||
|
mStencilInfo.back.stencilFailOp != dawn::StencilOperation::Keep ||
|
||||||
mStencilInfo.back.depthFail != dawn::StencilOperation::Keep ||
|
mStencilInfo.back.depthFailOp != dawn::StencilOperation::Keep ||
|
||||||
mStencilInfo.back.depthStencilPass != dawn::StencilOperation::Keep ||
|
mStencilInfo.back.passOp != dawn::StencilOperation::Keep ||
|
||||||
mStencilInfo.front.compareFunction != dawn::CompareFunction::Always ||
|
mStencilInfo.front.compare != dawn::CompareFunction::Always ||
|
||||||
mStencilInfo.front.stencilFail != dawn::StencilOperation::Keep ||
|
mStencilInfo.front.stencilFailOp != dawn::StencilOperation::Keep ||
|
||||||
mStencilInfo.front.depthFail != dawn::StencilOperation::Keep ||
|
mStencilInfo.front.depthFailOp != dawn::StencilOperation::Keep ||
|
||||||
mStencilInfo.front.depthStencilPass != dawn::StencilOperation::Keep;
|
mStencilInfo.front.passOp != dawn::StencilOperation::Keep;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DepthStencilStateBase::DepthInfo& DepthStencilStateBase::GetDepth() const {
|
const DepthStencilStateBase::DepthInfo& DepthStencilStateBase::GetDepth() const {
|
||||||
|
@ -85,11 +85,9 @@ namespace dawn_native {
|
||||||
mDepthInfo.depthWriteEnabled = enabled;
|
mDepthInfo.depthWriteEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthStencilStateBuilder::SetStencilFunction(dawn::Face face,
|
void DepthStencilStateBuilder::SetStencilFunction(
|
||||||
dawn::CompareFunction stencilCompareFunction,
|
dawn::Face face,
|
||||||
dawn::StencilOperation stencilFail,
|
const StencilStateFaceDescriptor* descriptor) {
|
||||||
dawn::StencilOperation depthFail,
|
|
||||||
dawn::StencilOperation depthStencilPass) {
|
|
||||||
if (face == dawn::Face::None) {
|
if (face == dawn::Face::None) {
|
||||||
HandleError("Can't set stencil function of None face");
|
HandleError("Can't set stencil function of None face");
|
||||||
return;
|
return;
|
||||||
|
@ -103,10 +101,10 @@ namespace dawn_native {
|
||||||
|
|
||||||
mPropertiesSet |= DEPTH_STENCIL_STATE_PROPERTY_STENCIL_BACK_FUNCTION;
|
mPropertiesSet |= DEPTH_STENCIL_STATE_PROPERTY_STENCIL_BACK_FUNCTION;
|
||||||
|
|
||||||
mStencilInfo.back.compareFunction = stencilCompareFunction;
|
mStencilInfo.back.compare = descriptor->compare;
|
||||||
mStencilInfo.back.stencilFail = stencilFail;
|
mStencilInfo.back.stencilFailOp = descriptor->stencilFailOp;
|
||||||
mStencilInfo.back.depthFail = depthFail;
|
mStencilInfo.back.depthFailOp = descriptor->depthFailOp;
|
||||||
mStencilInfo.back.depthStencilPass = depthStencilPass;
|
mStencilInfo.back.passOp = descriptor->passOp;
|
||||||
}
|
}
|
||||||
if (face & dawn::Face::Front) {
|
if (face & dawn::Face::Front) {
|
||||||
if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_STENCIL_FRONT_FUNCTION) != 0) {
|
if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_STENCIL_FRONT_FUNCTION) != 0) {
|
||||||
|
@ -116,10 +114,10 @@ namespace dawn_native {
|
||||||
|
|
||||||
mPropertiesSet |= DEPTH_STENCIL_STATE_PROPERTY_STENCIL_FRONT_FUNCTION;
|
mPropertiesSet |= DEPTH_STENCIL_STATE_PROPERTY_STENCIL_FRONT_FUNCTION;
|
||||||
|
|
||||||
mStencilInfo.front.compareFunction = stencilCompareFunction;
|
mStencilInfo.front.compare = descriptor->compare;
|
||||||
mStencilInfo.front.stencilFail = stencilFail;
|
mStencilInfo.front.stencilFailOp = descriptor->stencilFailOp;
|
||||||
mStencilInfo.front.depthFail = depthFail;
|
mStencilInfo.front.depthFailOp = descriptor->depthFailOp;
|
||||||
mStencilInfo.front.depthStencilPass = depthStencilPass;
|
mStencilInfo.front.passOp = descriptor->passOp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,16 +32,13 @@ namespace dawn_native {
|
||||||
bool depthWriteEnabled = false;
|
bool depthWriteEnabled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StencilFaceInfo {
|
|
||||||
dawn::CompareFunction compareFunction = dawn::CompareFunction::Always;
|
|
||||||
dawn::StencilOperation stencilFail = dawn::StencilOperation::Keep;
|
|
||||||
dawn::StencilOperation depthFail = dawn::StencilOperation::Keep;
|
|
||||||
dawn::StencilOperation depthStencilPass = dawn::StencilOperation::Keep;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct StencilInfo {
|
struct StencilInfo {
|
||||||
StencilFaceInfo back;
|
StencilStateFaceDescriptor back = {
|
||||||
StencilFaceInfo front;
|
dawn::CompareFunction::Always, dawn::StencilOperation::Keep,
|
||||||
|
dawn::StencilOperation::Keep, dawn::StencilOperation::Keep};
|
||||||
|
StencilStateFaceDescriptor front = {
|
||||||
|
dawn::CompareFunction::Always, dawn::StencilOperation::Keep,
|
||||||
|
dawn::StencilOperation::Keep, dawn::StencilOperation::Keep};
|
||||||
uint32_t readMask = 0xff;
|
uint32_t readMask = 0xff;
|
||||||
uint32_t writeMask = 0xff;
|
uint32_t writeMask = 0xff;
|
||||||
};
|
};
|
||||||
|
@ -62,11 +59,7 @@ namespace dawn_native {
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void SetDepthCompareFunction(dawn::CompareFunction depthCompareFunction);
|
void SetDepthCompareFunction(dawn::CompareFunction depthCompareFunction);
|
||||||
void SetDepthWriteEnabled(bool enabled);
|
void SetDepthWriteEnabled(bool enabled);
|
||||||
void SetStencilFunction(dawn::Face face,
|
void SetStencilFunction(dawn::Face face, const StencilStateFaceDescriptor* descriptor);
|
||||||
dawn::CompareFunction stencilCompareFunction,
|
|
||||||
dawn::StencilOperation stencilFail,
|
|
||||||
dawn::StencilOperation depthFail,
|
|
||||||
dawn::StencilOperation depthStencilPass);
|
|
||||||
void SetStencilMask(uint32_t readMask, uint32_t writeMask);
|
void SetStencilMask(uint32_t readMask, uint32_t writeMask);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -18,63 +18,64 @@
|
||||||
|
|
||||||
namespace dawn_native { namespace d3d12 {
|
namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
static D3D12_STENCIL_OP StencilOp(dawn::StencilOperation op) {
|
namespace {
|
||||||
switch (op) {
|
D3D12_STENCIL_OP StencilOp(dawn::StencilOperation op) {
|
||||||
case dawn::StencilOperation::Keep:
|
switch (op) {
|
||||||
return D3D12_STENCIL_OP_KEEP;
|
case dawn::StencilOperation::Keep:
|
||||||
case dawn::StencilOperation::Zero:
|
return D3D12_STENCIL_OP_KEEP;
|
||||||
return D3D12_STENCIL_OP_ZERO;
|
case dawn::StencilOperation::Zero:
|
||||||
case dawn::StencilOperation::Replace:
|
return D3D12_STENCIL_OP_ZERO;
|
||||||
return D3D12_STENCIL_OP_REPLACE;
|
case dawn::StencilOperation::Replace:
|
||||||
case dawn::StencilOperation::IncrementClamp:
|
return D3D12_STENCIL_OP_REPLACE;
|
||||||
return D3D12_STENCIL_OP_INCR_SAT;
|
case dawn::StencilOperation::IncrementClamp:
|
||||||
case dawn::StencilOperation::DecrementClamp:
|
return D3D12_STENCIL_OP_INCR_SAT;
|
||||||
return D3D12_STENCIL_OP_DECR_SAT;
|
case dawn::StencilOperation::DecrementClamp:
|
||||||
case dawn::StencilOperation::Invert:
|
return D3D12_STENCIL_OP_DECR_SAT;
|
||||||
return D3D12_STENCIL_OP_INVERT;
|
case dawn::StencilOperation::Invert:
|
||||||
case dawn::StencilOperation::IncrementWrap:
|
return D3D12_STENCIL_OP_INVERT;
|
||||||
return D3D12_STENCIL_OP_INCR;
|
case dawn::StencilOperation::IncrementWrap:
|
||||||
case dawn::StencilOperation::DecrementWrap:
|
return D3D12_STENCIL_OP_INCR;
|
||||||
return D3D12_STENCIL_OP_DECR;
|
case dawn::StencilOperation::DecrementWrap:
|
||||||
default:
|
return D3D12_STENCIL_OP_DECR;
|
||||||
UNREACHABLE();
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static D3D12_COMPARISON_FUNC ComparisonFunc(dawn::CompareFunction func) {
|
D3D12_COMPARISON_FUNC ComparisonFunc(dawn::CompareFunction func) {
|
||||||
switch (func) {
|
switch (func) {
|
||||||
case dawn::CompareFunction::Always:
|
case dawn::CompareFunction::Always:
|
||||||
return D3D12_COMPARISON_FUNC_ALWAYS;
|
return D3D12_COMPARISON_FUNC_ALWAYS;
|
||||||
case dawn::CompareFunction::Equal:
|
case dawn::CompareFunction::Equal:
|
||||||
return D3D12_COMPARISON_FUNC_EQUAL;
|
return D3D12_COMPARISON_FUNC_EQUAL;
|
||||||
case dawn::CompareFunction::Greater:
|
case dawn::CompareFunction::Greater:
|
||||||
return D3D12_COMPARISON_FUNC_GREATER;
|
return D3D12_COMPARISON_FUNC_GREATER;
|
||||||
case dawn::CompareFunction::GreaterEqual:
|
case dawn::CompareFunction::GreaterEqual:
|
||||||
return D3D12_COMPARISON_FUNC_GREATER_EQUAL;
|
return D3D12_COMPARISON_FUNC_GREATER_EQUAL;
|
||||||
case dawn::CompareFunction::Less:
|
case dawn::CompareFunction::Less:
|
||||||
return D3D12_COMPARISON_FUNC_LESS;
|
return D3D12_COMPARISON_FUNC_LESS;
|
||||||
case dawn::CompareFunction::LessEqual:
|
case dawn::CompareFunction::LessEqual:
|
||||||
return D3D12_COMPARISON_FUNC_LESS_EQUAL;
|
return D3D12_COMPARISON_FUNC_LESS_EQUAL;
|
||||||
case dawn::CompareFunction::Never:
|
case dawn::CompareFunction::Never:
|
||||||
return D3D12_COMPARISON_FUNC_NEVER;
|
return D3D12_COMPARISON_FUNC_NEVER;
|
||||||
case dawn::CompareFunction::NotEqual:
|
case dawn::CompareFunction::NotEqual:
|
||||||
return D3D12_COMPARISON_FUNC_NOT_EQUAL;
|
return D3D12_COMPARISON_FUNC_NOT_EQUAL;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static D3D12_DEPTH_STENCILOP_DESC StencilOpDesc(
|
D3D12_DEPTH_STENCILOP_DESC StencilOpDesc(const StencilStateFaceDescriptor descriptor) {
|
||||||
DepthStencilStateBase::StencilFaceInfo faceInfo) {
|
D3D12_DEPTH_STENCILOP_DESC desc;
|
||||||
D3D12_DEPTH_STENCILOP_DESC desc;
|
|
||||||
|
|
||||||
desc.StencilFailOp = StencilOp(faceInfo.stencilFail);
|
desc.StencilFailOp = StencilOp(descriptor.stencilFailOp);
|
||||||
desc.StencilDepthFailOp = StencilOp(faceInfo.depthFail);
|
desc.StencilDepthFailOp = StencilOp(descriptor.depthFailOp);
|
||||||
desc.StencilPassOp = StencilOp(faceInfo.depthStencilPass);
|
desc.StencilPassOp = StencilOp(descriptor.passOp);
|
||||||
desc.StencilFunc = ComparisonFunc(faceInfo.compareFunction);
|
desc.StencilFunc = ComparisonFunc(descriptor.compare);
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
DepthStencilState::DepthStencilState(DepthStencilStateBuilder* builder)
|
DepthStencilState::DepthStencilState(DepthStencilStateBuilder* builder)
|
||||||
: DepthStencilStateBase(builder) {
|
: DepthStencilStateBase(builder) {
|
||||||
|
|
|
@ -77,22 +77,22 @@ namespace dawn_native { namespace metal {
|
||||||
MTLStencilDescriptor* frontFaceStencil = [MTLStencilDescriptor new];
|
MTLStencilDescriptor* frontFaceStencil = [MTLStencilDescriptor new];
|
||||||
|
|
||||||
backFaceStencil.stencilCompareFunction =
|
backFaceStencil.stencilCompareFunction =
|
||||||
MetalDepthStencilCompareFunction(stencil.back.compareFunction);
|
MetalDepthStencilCompareFunction(stencil.back.compare);
|
||||||
backFaceStencil.stencilFailureOperation =
|
backFaceStencil.stencilFailureOperation =
|
||||||
MetalStencilOperation(stencil.back.stencilFail);
|
MetalStencilOperation(stencil.back.stencilFailOp);
|
||||||
backFaceStencil.depthFailureOperation = MetalStencilOperation(stencil.back.depthFail);
|
backFaceStencil.depthFailureOperation = MetalStencilOperation(stencil.back.depthFailOp);
|
||||||
backFaceStencil.depthStencilPassOperation =
|
backFaceStencil.depthStencilPassOperation = MetalStencilOperation(stencil.back.passOp);
|
||||||
MetalStencilOperation(stencil.back.depthStencilPass);
|
|
||||||
backFaceStencil.readMask = stencil.readMask;
|
backFaceStencil.readMask = stencil.readMask;
|
||||||
backFaceStencil.writeMask = stencil.writeMask;
|
backFaceStencil.writeMask = stencil.writeMask;
|
||||||
|
|
||||||
frontFaceStencil.stencilCompareFunction =
|
frontFaceStencil.stencilCompareFunction =
|
||||||
MetalDepthStencilCompareFunction(stencil.front.compareFunction);
|
MetalDepthStencilCompareFunction(stencil.front.compare);
|
||||||
frontFaceStencil.stencilFailureOperation =
|
frontFaceStencil.stencilFailureOperation =
|
||||||
MetalStencilOperation(stencil.front.stencilFail);
|
MetalStencilOperation(stencil.front.stencilFailOp);
|
||||||
frontFaceStencil.depthFailureOperation = MetalStencilOperation(stencil.front.depthFail);
|
frontFaceStencil.depthFailureOperation =
|
||||||
|
MetalStencilOperation(stencil.front.depthFailOp);
|
||||||
frontFaceStencil.depthStencilPassOperation =
|
frontFaceStencil.depthStencilPassOperation =
|
||||||
MetalStencilOperation(stencil.front.depthStencilPass);
|
MetalStencilOperation(stencil.front.passOp);
|
||||||
frontFaceStencil.readMask = stencil.readMask;
|
frontFaceStencil.readMask = stencil.readMask;
|
||||||
frontFaceStencil.writeMask = stencil.writeMask;
|
frontFaceStencil.writeMask = stencil.writeMask;
|
||||||
|
|
||||||
|
|
|
@ -98,17 +98,17 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
auto& stencilInfo = GetStencil();
|
auto& stencilInfo = GetStencil();
|
||||||
|
|
||||||
GLenum backCompareFunction = OpenGLCompareFunction(stencilInfo.back.compareFunction);
|
GLenum backCompareFunction = OpenGLCompareFunction(stencilInfo.back.compare);
|
||||||
GLenum frontCompareFunction = OpenGLCompareFunction(stencilInfo.front.compareFunction);
|
GLenum frontCompareFunction = OpenGLCompareFunction(stencilInfo.front.compare);
|
||||||
persistentPipelineState.SetStencilFuncsAndMask(backCompareFunction, frontCompareFunction,
|
persistentPipelineState.SetStencilFuncsAndMask(backCompareFunction, frontCompareFunction,
|
||||||
stencilInfo.readMask);
|
stencilInfo.readMask);
|
||||||
|
|
||||||
glStencilOpSeparate(GL_BACK, OpenGLStencilOperation(stencilInfo.back.stencilFail),
|
glStencilOpSeparate(GL_BACK, OpenGLStencilOperation(stencilInfo.back.stencilFailOp),
|
||||||
OpenGLStencilOperation(stencilInfo.back.depthFail),
|
OpenGLStencilOperation(stencilInfo.back.depthFailOp),
|
||||||
OpenGLStencilOperation(stencilInfo.back.depthStencilPass));
|
OpenGLStencilOperation(stencilInfo.back.passOp));
|
||||||
glStencilOpSeparate(GL_FRONT, OpenGLStencilOperation(stencilInfo.front.stencilFail),
|
glStencilOpSeparate(GL_FRONT, OpenGLStencilOperation(stencilInfo.front.stencilFailOp),
|
||||||
OpenGLStencilOperation(stencilInfo.front.depthFail),
|
OpenGLStencilOperation(stencilInfo.front.depthFailOp),
|
||||||
OpenGLStencilOperation(stencilInfo.front.depthStencilPass));
|
OpenGLStencilOperation(stencilInfo.front.passOp));
|
||||||
|
|
||||||
glStencilMask(stencilInfo.writeMask);
|
glStencilMask(stencilInfo.writeMask);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,15 +84,15 @@ namespace dawn_native { namespace vulkan {
|
||||||
const auto& stencil = GetStencil();
|
const auto& stencil = GetStencil();
|
||||||
mCreateInfo.stencilTestEnable = StencilTestEnabled() ? VK_TRUE : VK_FALSE;
|
mCreateInfo.stencilTestEnable = StencilTestEnabled() ? VK_TRUE : VK_FALSE;
|
||||||
|
|
||||||
mCreateInfo.front.failOp = VulkanStencilOp(stencil.front.stencilFail);
|
mCreateInfo.front.failOp = VulkanStencilOp(stencil.front.stencilFailOp);
|
||||||
mCreateInfo.front.passOp = VulkanStencilOp(stencil.front.depthStencilPass);
|
mCreateInfo.front.passOp = VulkanStencilOp(stencil.front.passOp);
|
||||||
mCreateInfo.front.depthFailOp = VulkanStencilOp(stencil.front.depthFail);
|
mCreateInfo.front.depthFailOp = VulkanStencilOp(stencil.front.depthFailOp);
|
||||||
mCreateInfo.front.compareOp = VulkanCompareOp(stencil.front.compareFunction);
|
mCreateInfo.front.compareOp = VulkanCompareOp(stencil.front.compare);
|
||||||
|
|
||||||
mCreateInfo.back.failOp = VulkanStencilOp(stencil.back.stencilFail);
|
mCreateInfo.back.failOp = VulkanStencilOp(stencil.back.stencilFailOp);
|
||||||
mCreateInfo.back.passOp = VulkanStencilOp(stencil.back.depthStencilPass);
|
mCreateInfo.back.passOp = VulkanStencilOp(stencil.back.passOp);
|
||||||
mCreateInfo.back.depthFailOp = VulkanStencilOp(stencil.back.depthFail);
|
mCreateInfo.back.depthFailOp = VulkanStencilOp(stencil.back.depthFailOp);
|
||||||
mCreateInfo.back.compareOp = VulkanCompareOp(stencil.back.compareFunction);
|
mCreateInfo.back.compareOp = VulkanCompareOp(stencil.back.compare);
|
||||||
|
|
||||||
// Dawn doesn't have separate front and back stencil masks.
|
// Dawn doesn't have separate front and back stencil masks.
|
||||||
mCreateInfo.front.compareMask = stencil.readMask;
|
mCreateInfo.front.compareMask = stencil.readMask;
|
||||||
|
|
|
@ -135,13 +135,25 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
// Check whether a stencil comparison function works as expected
|
// Check whether a stencil comparison function works as expected
|
||||||
// The less, equal, greater booleans denote wether the respective triangle should be visible based on the comparison function
|
// The less, equal, greater booleans denote wether the respective triangle should be visible based on the comparison function
|
||||||
void CheckStencilCompareFunction(dawn::CompareFunction compareFunction, bool less, bool equal, bool greater) {
|
void CheckStencilCompareFunction(dawn::CompareFunction compareFunction, bool less, bool equal, bool greater) {
|
||||||
dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor baseStencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
baseStencilFaceDescriptor.compare = dawn::CompareFunction::Always;
|
||||||
.GetResult();
|
baseStencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState baseState =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &baseStencilFaceDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor stencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, compareFunction, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
|
stencilFaceDescriptor.compare = compareFunction;
|
||||||
.GetResult();
|
stencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.passOp = dawn::StencilOperation::Keep;
|
||||||
|
dawn::DepthStencilState state =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilFaceDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
RGBA8 baseColor = RGBA8(255, 255, 255, 255);
|
RGBA8 baseColor = RGBA8(255, 255, 255, 255);
|
||||||
RGBA8 lessColor = RGBA8(255, 0, 0, 255);
|
RGBA8 lessColor = RGBA8(255, 0, 0, 255);
|
||||||
|
@ -163,13 +175,25 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
|
|
||||||
// Given the provided `initialStencil` and `reference`, check that applying the `stencilOperation` produces the `expectedStencil`
|
// Given the provided `initialStencil` and `reference`, check that applying the `stencilOperation` produces the `expectedStencil`
|
||||||
void CheckStencilOperation(dawn::StencilOperation stencilOperation, uint32_t initialStencil, uint32_t reference, uint32_t expectedStencil) {
|
void CheckStencilOperation(dawn::StencilOperation stencilOperation, uint32_t initialStencil, uint32_t reference, uint32_t expectedStencil) {
|
||||||
dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor baseStencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
baseStencilFaceDescriptor.compare = dawn::CompareFunction::Always;
|
||||||
.GetResult();
|
baseStencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState baseState =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &baseStencilFaceDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor stencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, stencilOperation)
|
stencilFaceDescriptor.compare = dawn::CompareFunction::Always;
|
||||||
.GetResult();
|
stencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.passOp = stencilOperation;
|
||||||
|
dawn::DepthStencilState state =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilFaceDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
CheckStencil({
|
CheckStencil({
|
||||||
// Wipe the stencil buffer with the initialStencil value
|
// Wipe the stencil buffer with the initialStencil value
|
||||||
|
@ -182,9 +206,15 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
|
|
||||||
// Draw a list of test specs, and check if the stencil value is equal to the expected value
|
// Draw a list of test specs, and check if the stencil value is equal to the expected value
|
||||||
void CheckStencil(std::vector<TestSpec> testParams, uint32_t expectedStencil) {
|
void CheckStencil(std::vector<TestSpec> testParams, uint32_t expectedStencil) {
|
||||||
dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor stencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Equal, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
|
stencilFaceDescriptor.compare = dawn::CompareFunction::Equal;
|
||||||
.GetResult();
|
stencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.passOp = dawn::StencilOperation::Keep;
|
||||||
|
dawn::DepthStencilState state =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilFaceDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
testParams.push_back({ state, RGBA8(0, 255, 0, 255), 0, expectedStencil });
|
testParams.push_back({ state, RGBA8(0, 255, 0, 255), 0, expectedStencil });
|
||||||
DoTest(testParams, RGBA8(0, 255, 0, 255));
|
DoTest(testParams, RGBA8(0, 255, 0, 255));
|
||||||
|
@ -415,14 +445,26 @@ TEST_P(DepthStencilStateTest, StencilDecrementWrap) {
|
||||||
|
|
||||||
// Check that the setting a stencil read mask works
|
// Check that the setting a stencil read mask works
|
||||||
TEST_P(DepthStencilStateTest, StencilReadMask) {
|
TEST_P(DepthStencilStateTest, StencilReadMask) {
|
||||||
dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor baseStencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
baseStencilFaceDescriptor.compare = dawn::CompareFunction::Always;
|
||||||
.GetResult();
|
baseStencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState baseState =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &baseStencilFaceDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor stencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Equal, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
|
stencilFaceDescriptor.compare = dawn::CompareFunction::Equal;
|
||||||
.SetStencilMask(0x2, 0xff)
|
stencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
.GetResult();
|
stencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.passOp = dawn::StencilOperation::Keep;
|
||||||
|
dawn::DepthStencilState state =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilFaceDescriptor)
|
||||||
|
.SetStencilMask(0x2, 0xff)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
RGBA8 baseColor = RGBA8(255, 255, 255, 255);
|
RGBA8 baseColor = RGBA8(255, 255, 255, 255);
|
||||||
RGBA8 red = RGBA8(255, 0, 0, 255);
|
RGBA8 red = RGBA8(255, 0, 0, 255);
|
||||||
|
@ -435,14 +477,26 @@ TEST_P(DepthStencilStateTest, StencilReadMask) {
|
||||||
|
|
||||||
// Check that setting a stencil write mask works
|
// Check that setting a stencil write mask works
|
||||||
TEST_P(DepthStencilStateTest, StencilWriteMask) {
|
TEST_P(DepthStencilStateTest, StencilWriteMask) {
|
||||||
dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor baseStencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
baseStencilFaceDescriptor.compare = dawn::CompareFunction::Always;
|
||||||
.SetStencilMask(0xff, 0x1)
|
baseStencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
.GetResult();
|
baseStencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState baseState =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &baseStencilFaceDescriptor)
|
||||||
|
.SetStencilMask(0xff, 0x1)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor stencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Equal, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
|
stencilFaceDescriptor.compare = dawn::CompareFunction::Equal;
|
||||||
.GetResult();
|
stencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.passOp = dawn::StencilOperation::Keep;
|
||||||
|
dawn::DepthStencilState state =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilFaceDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
RGBA8 baseColor = RGBA8(255, 255, 255, 255);
|
RGBA8 baseColor = RGBA8(255, 255, 255, 255);
|
||||||
RGBA8 green = RGBA8(0, 255, 0, 255);
|
RGBA8 green = RGBA8(0, 255, 0, 255);
|
||||||
|
@ -454,13 +508,25 @@ TEST_P(DepthStencilStateTest, StencilWriteMask) {
|
||||||
|
|
||||||
// Test that the stencil operation is executed on stencil fail
|
// Test that the stencil operation is executed on stencil fail
|
||||||
TEST_P(DepthStencilStateTest, StencilFail) {
|
TEST_P(DepthStencilStateTest, StencilFail) {
|
||||||
dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor baseStencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
baseStencilFaceDescriptor.compare = dawn::CompareFunction::Always;
|
||||||
.GetResult();
|
baseStencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState baseState =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &baseStencilFaceDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor stencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Less, dawn::StencilOperation::Replace, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
|
stencilFaceDescriptor.compare = dawn::CompareFunction::Less;
|
||||||
.GetResult();
|
stencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Replace;
|
||||||
|
stencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
stencilFaceDescriptor.passOp = dawn::StencilOperation::Keep;
|
||||||
|
dawn::DepthStencilState state =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilFaceDescriptor)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
CheckStencil({
|
CheckStencil({
|
||||||
{ baseState, RGBA8(255, 255, 255, 255), 1.f, 1 }, // Triangle to set stencil value to 1
|
{ baseState, RGBA8(255, 255, 255, 255), 1.f, 1 }, // Triangle to set stencil value to 1
|
||||||
|
@ -470,16 +536,28 @@ TEST_P(DepthStencilStateTest, StencilFail) {
|
||||||
|
|
||||||
// Test that the stencil operation is executed on stencil pass, depth fail
|
// Test that the stencil operation is executed on stencil pass, depth fail
|
||||||
TEST_P(DepthStencilStateTest, StencilDepthFail) {
|
TEST_P(DepthStencilStateTest, StencilDepthFail) {
|
||||||
dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor baseStencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
baseStencilFaceDescriptor.compare = dawn::CompareFunction::Always;
|
||||||
.SetDepthWriteEnabled(true)
|
baseStencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
.GetResult();
|
baseStencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState baseState =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &baseStencilFaceDescriptor)
|
||||||
|
.SetDepthWriteEnabled(true)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor stencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Greater, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace, dawn::StencilOperation::Keep)
|
stencilFaceDescriptor.compare = dawn::CompareFunction::Greater;
|
||||||
.SetDepthWriteEnabled(true)
|
stencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
stencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Replace;
|
||||||
.GetResult();
|
stencilFaceDescriptor.passOp = dawn::StencilOperation::Keep;
|
||||||
|
dawn::DepthStencilState state =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilFaceDescriptor)
|
||||||
|
.SetDepthWriteEnabled(true)
|
||||||
|
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
CheckStencil({
|
CheckStencil({
|
||||||
{ baseState, RGBA8(255, 255, 255, 255), 0.f, 1 }, // Triangle to set stencil value to 1. Depth is 0
|
{ baseState, RGBA8(255, 255, 255, 255), 0.f, 1 }, // Triangle to set stencil value to 1. Depth is 0
|
||||||
|
@ -489,16 +567,28 @@ TEST_P(DepthStencilStateTest, StencilDepthFail) {
|
||||||
|
|
||||||
// Test that the stencil operation is executed on stencil pass, depth pass
|
// Test that the stencil operation is executed on stencil pass, depth pass
|
||||||
TEST_P(DepthStencilStateTest, StencilDepthPass) {
|
TEST_P(DepthStencilStateTest, StencilDepthPass) {
|
||||||
dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor baseStencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
baseStencilFaceDescriptor.compare = dawn::CompareFunction::Always;
|
||||||
.SetDepthWriteEnabled(true)
|
baseStencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
.GetResult();
|
baseStencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
|
baseStencilFaceDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState baseState =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &baseStencilFaceDescriptor)
|
||||||
|
.SetDepthWriteEnabled(true)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
|
dawn::StencilStateFaceDescriptor stencilFaceDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Greater, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
stencilFaceDescriptor.compare = dawn::CompareFunction::Greater;
|
||||||
.SetDepthWriteEnabled(true)
|
stencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
stencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
.GetResult();
|
stencilFaceDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState state =
|
||||||
|
device.CreateDepthStencilStateBuilder()
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilFaceDescriptor)
|
||||||
|
.SetDepthWriteEnabled(true)
|
||||||
|
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
CheckStencil({
|
CheckStencil({
|
||||||
{ baseState, RGBA8(255, 255, 255, 255), 1.f, 1 }, // Triangle to set stencil value to 1. Depth is 0
|
{ baseState, RGBA8(255, 255, 255, 255), 1.f, 1 }, // Triangle to set stencil value to 1. Depth is 0
|
||||||
|
|
|
@ -21,13 +21,18 @@ class DepthStencilStateValidationTest : public ValidationTest {
|
||||||
TEST_F(DepthStencilStateValidationTest, CreationSuccess) {
|
TEST_F(DepthStencilStateValidationTest, CreationSuccess) {
|
||||||
// Success for setting all properties
|
// Success for setting all properties
|
||||||
{
|
{
|
||||||
dawn::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
dawn::StencilStateFaceDescriptor stencilFaceDescriptor;
|
||||||
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
stencilFaceDescriptor.compare = dawn::CompareFunction::Greater;
|
||||||
.SetDepthWriteEnabled(true)
|
stencilFaceDescriptor.stencilFailOp = dawn::StencilOperation::Keep;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Greater,
|
stencilFaceDescriptor.depthFailOp = dawn::StencilOperation::Keep;
|
||||||
dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
|
stencilFaceDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
.SetStencilMask(0x0, 0x1)
|
dawn::DepthStencilState ds =
|
||||||
.GetResult();
|
AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
||||||
|
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
||||||
|
.SetDepthWriteEnabled(true)
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilFaceDescriptor)
|
||||||
|
.SetStencilMask(0x0, 0x1)
|
||||||
|
.GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success for empty builder
|
// Success for empty builder
|
||||||
|
@ -38,12 +43,21 @@ TEST_F(DepthStencilStateValidationTest, CreationSuccess) {
|
||||||
|
|
||||||
// Test success when setting stencil function on separate faces
|
// Test success when setting stencil function on separate faces
|
||||||
{
|
{
|
||||||
dawn::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
dawn::StencilStateFaceDescriptor stencilFrontDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Front, dawn::CompareFunction::Less,
|
stencilFrontDescriptor.compare = dawn::CompareFunction::Less;
|
||||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
stencilFrontDescriptor.stencilFailOp = dawn::StencilOperation::Replace;
|
||||||
.SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Greater,
|
stencilFrontDescriptor.depthFailOp = dawn::StencilOperation::Replace;
|
||||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
stencilFrontDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
.GetResult();
|
dawn::StencilStateFaceDescriptor stencilBackDescriptor;
|
||||||
|
stencilBackDescriptor.compare = dawn::CompareFunction::Greater;
|
||||||
|
stencilBackDescriptor.stencilFailOp = dawn::StencilOperation::Replace;
|
||||||
|
stencilBackDescriptor.depthFailOp = dawn::StencilOperation::Replace;
|
||||||
|
stencilBackDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState ds =
|
||||||
|
AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
||||||
|
.SetStencilFunction(dawn::Face::Front, &stencilFrontDescriptor)
|
||||||
|
.SetStencilFunction(dawn::Face::Back, &stencilBackDescriptor)
|
||||||
|
.GetResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,21 +89,39 @@ TEST_F(DepthStencilStateValidationTest, CreationDuplicates) {
|
||||||
|
|
||||||
// Test failure when directly setting stencil function on a face multiple times
|
// Test failure when directly setting stencil function on a face multiple times
|
||||||
{
|
{
|
||||||
dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
dawn::StencilStateFaceDescriptor stencilBackDescriptor1;
|
||||||
.SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Less,
|
stencilBackDescriptor1.compare = dawn::CompareFunction::Less;
|
||||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
stencilBackDescriptor1.stencilFailOp = dawn::StencilOperation::Replace;
|
||||||
.SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Greater,
|
stencilBackDescriptor1.depthFailOp = dawn::StencilOperation::Replace;
|
||||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
stencilBackDescriptor1.passOp = dawn::StencilOperation::Replace;
|
||||||
.GetResult();
|
dawn::StencilStateFaceDescriptor stencilBackDescriptor2;
|
||||||
|
stencilBackDescriptor2.compare = dawn::CompareFunction::Greater;
|
||||||
|
stencilBackDescriptor2.stencilFailOp = dawn::StencilOperation::Replace;
|
||||||
|
stencilBackDescriptor2.depthFailOp = dawn::StencilOperation::Replace;
|
||||||
|
stencilBackDescriptor2.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState ds =
|
||||||
|
AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||||
|
.SetStencilFunction(dawn::Face::Back, &stencilBackDescriptor1)
|
||||||
|
.SetStencilFunction(dawn::Face::Back, &stencilBackDescriptor2)
|
||||||
|
.GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test failure when indirectly setting stencil function on a face multiple times
|
// Test failure when indirectly setting stencil function on a face multiple times
|
||||||
{
|
{
|
||||||
dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
dawn::StencilStateFaceDescriptor stencilBothDescriptor;
|
||||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Less,
|
stencilBothDescriptor.compare = dawn::CompareFunction::Less;
|
||||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
stencilBothDescriptor.stencilFailOp = dawn::StencilOperation::Replace;
|
||||||
.SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Greater,
|
stencilBothDescriptor.depthFailOp = dawn::StencilOperation::Replace;
|
||||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
stencilBothDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
.GetResult();
|
dawn::StencilStateFaceDescriptor stencilBackDescriptor;
|
||||||
|
stencilBackDescriptor.compare = dawn::CompareFunction::Greater;
|
||||||
|
stencilBackDescriptor.stencilFailOp = dawn::StencilOperation::Replace;
|
||||||
|
stencilBackDescriptor.depthFailOp = dawn::StencilOperation::Replace;
|
||||||
|
stencilBackDescriptor.passOp = dawn::StencilOperation::Replace;
|
||||||
|
dawn::DepthStencilState ds =
|
||||||
|
AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||||
|
.SetStencilFunction(dawn::Face::Both, &stencilBothDescriptor)
|
||||||
|
.SetStencilFunction(dawn::Face::Back, &stencilBackDescriptor)
|
||||||
|
.GetResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue