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) {
|
||||
}
|
||||
|
||||
bool DepthStencilStateBase::DepthTestEnabled() const {
|
||||
return depthInfo.compareFunction != nxt::CompareFunction::Always;
|
||||
}
|
||||
|
||||
bool DepthStencilStateBase::StencilTestEnabled() const {
|
||||
return stencilInfo.back.compareFunction != nxt::CompareFunction::Always ||
|
||||
stencilInfo.back.stencilFail != nxt::StencilOperation::Keep ||
|
||||
|
|
|
@ -47,7 +47,6 @@ namespace backend {
|
|||
uint32_t writeMask = 0xff;
|
||||
};
|
||||
|
||||
bool DepthTestEnabled() const;
|
||||
bool StencilTestEnabled() const;
|
||||
const DepthInfo& GetDepth() const;
|
||||
const StencilInfo& GetStencil() const;
|
||||
|
|
|
@ -67,14 +67,11 @@ namespace metal {
|
|||
: DepthStencilStateBase(builder) {
|
||||
MTLDepthStencilDescriptor* mtlDepthStencilDescriptor = [MTLDepthStencilDescriptor new];
|
||||
|
||||
if (DepthTestEnabled()) {
|
||||
auto& depth = GetDepth();
|
||||
mtlDepthStencilDescriptor.depthCompareFunction = MetalDepthStencilCompareFunction(depth.compareFunction);
|
||||
mtlDepthStencilDescriptor.depthWriteEnabled = depth.depthWriteEnabled;
|
||||
}
|
||||
|
||||
auto& stencil = GetStencil();
|
||||
|
||||
if (StencilTestEnabled()) {
|
||||
MTLStencilDescriptor* backFaceStencil = [MTLStencilDescriptor new];
|
||||
MTLStencilDescriptor* frontFaceStencil = [MTLStencilDescriptor new];
|
||||
|
|
|
@ -74,14 +74,15 @@ namespace opengl {
|
|||
}
|
||||
|
||||
void DepthStencilState::ApplyNow(PersistentPipelineState &persistentPipelineState) const {
|
||||
if (DepthTestEnabled()) {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
} else {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
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) {
|
||||
glDepthMask(GL_TRUE);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue