Remove DepthTestEnabled() and fix depth writes for depth function Always
This commit is contained in:
parent
cc8d2d529d
commit
ccf1fa2330
|
@ -24,10 +24,6 @@ namespace backend {
|
||||||
: depthInfo(builder->depthInfo), stencilInfo(builder->stencilInfo) {
|
: depthInfo(builder->depthInfo), stencilInfo(builder->stencilInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DepthStencilStateBase::DepthTestEnabled() const {
|
|
||||||
return depthInfo.compareFunction != nxt::CompareFunction::Always;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DepthStencilStateBase::StencilTestEnabled() const {
|
bool DepthStencilStateBase::StencilTestEnabled() const {
|
||||||
return stencilInfo.back.compareFunction != nxt::CompareFunction::Always ||
|
return stencilInfo.back.compareFunction != nxt::CompareFunction::Always ||
|
||||||
stencilInfo.back.stencilFail != nxt::StencilOperation::Keep ||
|
stencilInfo.back.stencilFail != nxt::StencilOperation::Keep ||
|
||||||
|
|
|
@ -47,7 +47,6 @@ namespace backend {
|
||||||
uint32_t writeMask = 0xff;
|
uint32_t writeMask = 0xff;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool DepthTestEnabled() const;
|
|
||||||
bool StencilTestEnabled() const;
|
bool StencilTestEnabled() const;
|
||||||
const DepthInfo& GetDepth() const;
|
const DepthInfo& GetDepth() const;
|
||||||
const StencilInfo& GetStencil() const;
|
const StencilInfo& GetStencil() const;
|
||||||
|
|
|
@ -67,14 +67,11 @@ namespace metal {
|
||||||
: DepthStencilStateBase(builder) {
|
: DepthStencilStateBase(builder) {
|
||||||
MTLDepthStencilDescriptor* mtlDepthStencilDescriptor = [MTLDepthStencilDescriptor new];
|
MTLDepthStencilDescriptor* mtlDepthStencilDescriptor = [MTLDepthStencilDescriptor new];
|
||||||
|
|
||||||
if (DepthTestEnabled()) {
|
auto& depth = GetDepth();
|
||||||
auto& depth = GetDepth();
|
mtlDepthStencilDescriptor.depthCompareFunction = MetalDepthStencilCompareFunction(depth.compareFunction);
|
||||||
mtlDepthStencilDescriptor.depthCompareFunction = MetalDepthStencilCompareFunction(depth.compareFunction);
|
mtlDepthStencilDescriptor.depthWriteEnabled = depth.depthWriteEnabled;
|
||||||
mtlDepthStencilDescriptor.depthWriteEnabled = depth.depthWriteEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& stencil = GetStencil();
|
auto& stencil = GetStencil();
|
||||||
|
|
||||||
if (StencilTestEnabled()) {
|
if (StencilTestEnabled()) {
|
||||||
MTLStencilDescriptor* backFaceStencil = [MTLStencilDescriptor new];
|
MTLStencilDescriptor* backFaceStencil = [MTLStencilDescriptor new];
|
||||||
MTLStencilDescriptor* frontFaceStencil = [MTLStencilDescriptor new];
|
MTLStencilDescriptor* frontFaceStencil = [MTLStencilDescriptor new];
|
||||||
|
|
|
@ -74,14 +74,15 @@ namespace opengl {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthStencilState::ApplyNow(PersistentPipelineState &persistentPipelineState) const {
|
void DepthStencilState::ApplyNow(PersistentPipelineState &persistentPipelineState) const {
|
||||||
if (DepthTestEnabled()) {
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
} else {
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& depthInfo = GetDepth();
|
auto& depthInfo = GetDepth();
|
||||||
|
|
||||||
|
// Depth writes only occur if depth is enabled
|
||||||
|
if (depthInfo.compareFunction == nxt::CompareFunction::Always && !depthInfo.depthWriteEnabled) {
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
} else {
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
if (depthInfo.depthWriteEnabled) {
|
if (depthInfo.depthWriteEnabled) {
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue