Remove MVKCommandEncoderState::reset().
MVKCommandEncoderState has numerous subclasses, and the polymorphic MVKCommandEncoderState::resetImpl() requires significant maintenance across these subclasses. It's only use was in disabling depth-stencil state. Remove MVKCommandEncoderState::reset() and all implementations of resetImpl() across all MVKCommandEncoderState subclasses. Remove MVKPipeline::__hasDepthStencilInfo and disable depth-stencil state automatically via cleared Vulkan struct in MVKPipeline.
This commit is contained in:
parent
4d46cf7375
commit
acf2a80535
@ -83,23 +83,11 @@ public:
|
|||||||
encodeImpl(stage);
|
encodeImpl(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks this instance as dirty and calls resetImpl() function to reset this instance
|
|
||||||
* back to initial state. Subclasses must override the resetImpl() function.
|
|
||||||
*/
|
|
||||||
void reset() {
|
|
||||||
_isDirty = true;
|
|
||||||
_isModified = false;
|
|
||||||
|
|
||||||
resetImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Constructs this instance for the specified command encoder. */
|
/** Constructs this instance for the specified command encoder. */
|
||||||
MVKCommandEncoderState(MVKCommandEncoder* cmdEncoder) : _cmdEncoder(cmdEncoder) {}
|
MVKCommandEncoderState(MVKCommandEncoder* cmdEncoder) : _cmdEncoder(cmdEncoder) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void encodeImpl(uint32_t stage) = 0;
|
virtual void encodeImpl(uint32_t stage) = 0;
|
||||||
virtual void resetImpl() = 0;
|
|
||||||
|
|
||||||
MVKCommandEncoder* _cmdEncoder;
|
MVKCommandEncoder* _cmdEncoder;
|
||||||
bool _isDirty = false;
|
bool _isDirty = false;
|
||||||
@ -127,7 +115,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
void resetImpl() override;
|
|
||||||
|
|
||||||
MVKPipeline* _pipeline = nullptr;
|
MVKPipeline* _pipeline = nullptr;
|
||||||
};
|
};
|
||||||
@ -156,7 +143,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
void resetImpl() override;
|
|
||||||
|
|
||||||
MVKSmallVector<VkViewport, kMVKCachedViewportScissorCount> _viewports, _dynamicViewports;
|
MVKSmallVector<VkViewport, kMVKCachedViewportScissorCount> _viewports, _dynamicViewports;
|
||||||
};
|
};
|
||||||
@ -185,7 +171,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
void resetImpl() override;
|
|
||||||
|
|
||||||
MVKSmallVector<VkRect2D, kMVKCachedViewportScissorCount> _scissors, _dynamicScissors;
|
MVKSmallVector<VkRect2D, kMVKCachedViewportScissorCount> _scissors, _dynamicScissors;
|
||||||
};
|
};
|
||||||
@ -212,7 +197,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
void resetImpl() override;
|
|
||||||
bool isTessellating();
|
bool isTessellating();
|
||||||
|
|
||||||
MVKSmallVector<char, 128> _pushConstants;
|
MVKSmallVector<char, 128> _pushConstants;
|
||||||
@ -252,7 +236,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
void resetImpl() override;
|
|
||||||
void setStencilState(MVKMTLStencilDescriptorData& stencilInfo,
|
void setStencilState(MVKMTLStencilDescriptorData& stencilInfo,
|
||||||
const VkStencilOpState& vkStencil,
|
const VkStencilOpState& vkStencil,
|
||||||
bool enabled);
|
bool enabled);
|
||||||
@ -283,7 +266,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
void resetImpl() override;
|
|
||||||
|
|
||||||
uint32_t _frontFaceValue = 0;
|
uint32_t _frontFaceValue = 0;
|
||||||
uint32_t _backFaceValue = 0;
|
uint32_t _backFaceValue = 0;
|
||||||
@ -312,7 +294,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
void resetImpl() override;
|
|
||||||
|
|
||||||
float _depthBiasConstantFactor = 0;
|
float _depthBiasConstantFactor = 0;
|
||||||
float _depthBiasClamp = 0;
|
float _depthBiasClamp = 0;
|
||||||
@ -340,7 +321,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
void resetImpl() override;
|
|
||||||
|
|
||||||
float _red = 0;
|
float _red = 0;
|
||||||
float _green = 0;
|
float _green = 0;
|
||||||
@ -440,23 +420,6 @@ protected:
|
|||||||
bool areSamplerStateBindingsDirty = false;
|
bool areSamplerStateBindingsDirty = false;
|
||||||
|
|
||||||
bool needsSwizzle = false;
|
bool needsSwizzle = false;
|
||||||
|
|
||||||
void reset() {
|
|
||||||
bufferBindings.clear();
|
|
||||||
textureBindings.clear();
|
|
||||||
samplerStateBindings.clear();
|
|
||||||
swizzleConstants.clear();
|
|
||||||
bufferSizes.clear();
|
|
||||||
|
|
||||||
areBufferBindingsDirty = false;
|
|
||||||
areTextureBindingsDirty = false;
|
|
||||||
areSamplerStateBindingsDirty = false;
|
|
||||||
swizzleBufferBinding.isDirty = false;
|
|
||||||
bufferSizeBufferBinding.isDirty = false;
|
|
||||||
viewRangeBufferBinding.isDirty = false;
|
|
||||||
|
|
||||||
needsSwizzle = false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -524,7 +487,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
void resetImpl() override;
|
|
||||||
void markDirty() override;
|
void markDirty() override;
|
||||||
|
|
||||||
ResourceBindings<8> _shaderStageResourceBindings[4];
|
ResourceBindings<8> _shaderStageResourceBindings[4];
|
||||||
@ -563,7 +525,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t) override;
|
void encodeImpl(uint32_t) override;
|
||||||
void resetImpl() override;
|
|
||||||
|
|
||||||
ResourceBindings<4> _resourceBindings;
|
ResourceBindings<4> _resourceBindings;
|
||||||
};
|
};
|
||||||
@ -589,7 +550,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t) override;
|
void encodeImpl(uint32_t) override;
|
||||||
void resetImpl() override;
|
|
||||||
|
|
||||||
MTLVisibilityResultMode _mtlVisibilityResultMode = MTLVisibilityResultModeDisabled;
|
MTLVisibilityResultMode _mtlVisibilityResultMode = MTLVisibilityResultModeDisabled;
|
||||||
NSUInteger _mtlVisibilityResultOffset = 0;
|
NSUInteger _mtlVisibilityResultOffset = 0;
|
||||||
|
@ -49,10 +49,6 @@ void MVKPipelineCommandEncoderState::encodeImpl(uint32_t stage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKPipelineCommandEncoderState::resetImpl() {
|
|
||||||
_pipeline = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKViewportCommandEncoderState
|
#pragma mark MVKViewportCommandEncoderState
|
||||||
@ -103,11 +99,6 @@ void MVKViewportCommandEncoderState::encodeImpl(uint32_t stage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKViewportCommandEncoderState::resetImpl() {
|
|
||||||
_viewports.clear();
|
|
||||||
_dynamicViewports.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKScissorCommandEncoderState
|
#pragma mark MVKScissorCommandEncoderState
|
||||||
@ -158,11 +149,6 @@ void MVKScissorCommandEncoderState::encodeImpl(uint32_t stage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKScissorCommandEncoderState::resetImpl() {
|
|
||||||
_scissors.clear();
|
|
||||||
_dynamicScissors.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKPushConstantsCommandEncoderState
|
#pragma mark MVKPushConstantsCommandEncoderState
|
||||||
@ -255,10 +241,6 @@ bool MVKPushConstantsCommandEncoderState::isTessellating() {
|
|||||||
return gp ? gp->isTessellationPipeline() : false;
|
return gp ? gp->isTessellationPipeline() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKPushConstantsCommandEncoderState::resetImpl() {
|
|
||||||
_pushConstants.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKDepthStencilCommandEncoderState
|
#pragma mark MVKDepthStencilCommandEncoderState
|
||||||
@ -363,12 +345,6 @@ void MVKDepthStencilCommandEncoderState::encodeImpl(uint32_t stage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKDepthStencilCommandEncoderState::resetImpl() {
|
|
||||||
_depthStencilData = kMVKMTLDepthStencilDescriptorDataDefault;
|
|
||||||
_hasDepthAttachment = false;
|
|
||||||
_hasStencilAttachment = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKStencilReferenceValueCommandEncoderState
|
#pragma mark MVKStencilReferenceValueCommandEncoderState
|
||||||
@ -406,11 +382,6 @@ void MVKStencilReferenceValueCommandEncoderState::encodeImpl(uint32_t stage) {
|
|||||||
backReferenceValue: _backFaceValue];
|
backReferenceValue: _backFaceValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKStencilReferenceValueCommandEncoderState::resetImpl() {
|
|
||||||
_frontFaceValue = 0;
|
|
||||||
_backFaceValue = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKDepthBiasCommandEncoderState
|
#pragma mark MVKDepthBiasCommandEncoderState
|
||||||
@ -453,13 +424,6 @@ void MVKDepthBiasCommandEncoderState::encodeImpl(uint32_t stage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKDepthBiasCommandEncoderState::resetImpl() {
|
|
||||||
_depthBiasConstantFactor = 0;
|
|
||||||
_depthBiasClamp = 0;
|
|
||||||
_depthBiasSlopeFactor = 0;
|
|
||||||
_isEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKBlendColorCommandEncoderState
|
#pragma mark MVKBlendColorCommandEncoderState
|
||||||
@ -484,13 +448,6 @@ void MVKBlendColorCommandEncoderState::encodeImpl(uint32_t stage) {
|
|||||||
[_cmdEncoder->_mtlRenderEncoder setBlendColorRed: _red green: _green blue: _blue alpha: _alpha];
|
[_cmdEncoder->_mtlRenderEncoder setBlendColorRed: _red green: _green blue: _blue alpha: _alpha];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKBlendColorCommandEncoderState::resetImpl() {
|
|
||||||
_red = 0;
|
|
||||||
_green = 0;
|
|
||||||
_blue = 0;
|
|
||||||
_alpha = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKResourcesCommandEncoderState
|
#pragma mark MVKResourcesCommandEncoderState
|
||||||
@ -808,12 +765,6 @@ void MVKGraphicsResourcesCommandEncoderState::encodeImpl(uint32_t stage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKGraphicsResourcesCommandEncoderState::resetImpl() {
|
|
||||||
for (uint32_t i = kMVKShaderStageVertex; i <= kMVKShaderStageFragment; i++) {
|
|
||||||
_shaderStageResourceBindings[i].reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKComputeResourcesCommandEncoderState
|
#pragma mark MVKComputeResourcesCommandEncoderState
|
||||||
@ -908,10 +859,6 @@ void MVKComputeResourcesCommandEncoderState::encodeImpl(uint32_t) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKComputeResourcesCommandEncoderState::resetImpl() {
|
|
||||||
_resourceBindings.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKOcclusionQueryCommandEncoderState
|
#pragma mark MVKOcclusionQueryCommandEncoderState
|
||||||
@ -966,9 +913,3 @@ void MVKOcclusionQueryCommandEncoderState::encodeImpl(uint32_t stage) {
|
|||||||
[_cmdEncoder->_mtlRenderEncoder setVisibilityResultMode: _mtlVisibilityResultMode
|
[_cmdEncoder->_mtlRenderEncoder setVisibilityResultMode: _mtlVisibilityResultMode
|
||||||
offset: _mtlVisibilityResultOffset];
|
offset: _mtlVisibilityResultOffset];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MVKOcclusionQueryCommandEncoderState::resetImpl() {
|
|
||||||
_mtlVisibilityResultMode = MTLVisibilityResultModeDisabled;
|
|
||||||
_mtlVisibilityResultOffset = 0;
|
|
||||||
_mtlRenderPassQueries.clear();
|
|
||||||
}
|
|
||||||
|
@ -338,7 +338,6 @@ protected:
|
|||||||
uint32_t _tessCtlLevelBufferIndex = 0;
|
uint32_t _tessCtlLevelBufferIndex = 0;
|
||||||
|
|
||||||
bool _dynamicStateEnabled[kMVKVkDynamicStateCount];
|
bool _dynamicStateEnabled[kMVKVkDynamicStateCount];
|
||||||
bool _hasDepthStencilInfo;
|
|
||||||
bool _needsVertexSwizzleBuffer = false;
|
bool _needsVertexSwizzleBuffer = false;
|
||||||
bool _needsVertexBufferSizeBuffer = false;
|
bool _needsVertexBufferSizeBuffer = false;
|
||||||
bool _needsVertexViewRangeBuffer = false;
|
bool _needsVertexViewRangeBuffer = false;
|
||||||
|
@ -241,14 +241,9 @@ void MVKGraphicsPipeline::encode(MVKCommandEncoder* cmdEncoder, uint32_t stage)
|
|||||||
[mtlCmdEnc setRenderPipelineState: _mtlPipelineState];
|
[mtlCmdEnc setRenderPipelineState: _mtlPipelineState];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Depth stencil state
|
// Depth stencil state - Cleared _depthStencilInfo values will disable depth testing
|
||||||
if (_hasDepthStencilInfo) {
|
cmdEncoder->_depthStencilState.setDepthStencilState(_depthStencilInfo);
|
||||||
cmdEncoder->_depthStencilState.setDepthStencilState(_depthStencilInfo);
|
cmdEncoder->_stencilReferenceValueState.setReferenceValues(_depthStencilInfo);
|
||||||
cmdEncoder->_stencilReferenceValueState.setReferenceValues(_depthStencilInfo);
|
|
||||||
} else {
|
|
||||||
cmdEncoder->_depthStencilState.reset();
|
|
||||||
cmdEncoder->_stencilReferenceValueState.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rasterization
|
// Rasterization
|
||||||
cmdEncoder->_blendColorState.setBlendColor(_blendConstants[0], _blendConstants[1],
|
cmdEncoder->_blendColorState.setBlendColor(_blendConstants[0], _blendConstants[1],
|
||||||
@ -418,8 +413,8 @@ MVKGraphicsPipeline::MVKGraphicsPipeline(MVKDevice* device,
|
|||||||
// Render pipeline state
|
// Render pipeline state
|
||||||
initMTLRenderPipelineState(pCreateInfo, reflectData);
|
initMTLRenderPipelineState(pCreateInfo, reflectData);
|
||||||
|
|
||||||
// Depth stencil content
|
// Depth stencil content - clearing will disable depth and stencil testing
|
||||||
_hasDepthStencilInfo = mvkSetOrClear(&_depthStencilInfo, pCreateInfo->pDepthStencilState);
|
mvkSetOrClear(&_depthStencilInfo, pCreateInfo->pDepthStencilState);
|
||||||
|
|
||||||
// Viewports and scissors
|
// Viewports and scissors
|
||||||
auto pVPState = pCreateInfo->pViewportState;
|
auto pVPState = pCreateInfo->pViewportState;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user