Skip to content

Commit

Permalink
MVKGraphicsPipeline: Don't use _tessInfo to decide if pipeline is a t…
Browse files Browse the repository at this point in the history
…essellation pipeline.

With dynamic patch control points enabled, the pipeline does not need to be
created with tessellation info included in the create info. Store a separate
boolean flag to treat all pipelines that have tessellation shaders properly.
  • Loading branch information
js6i committed May 30, 2024
1 parent 6b9e559 commit b0d20bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class MVKGraphicsPipeline : public MVKPipeline {
bool isDynamicState(MVKRenderStateType state) { return _dynamicState.isEnabled(state); }

/** Returns whether this pipeline has tessellation shaders. */
bool isTessellationPipeline() { return _tessInfo.patchControlPoints > 0; }
bool isTessellationPipeline() { return _isTessellationPipeline; }

/** Returns the number of output tessellation patch control points. */
uint32_t getOutputControlPointCount() { return _outputControlPointCount; }
Expand Down Expand Up @@ -455,6 +455,7 @@ class MVKGraphicsPipeline : public MVKPipeline {
bool _isRasterizing = false;
bool _isRasterizingColor = false;
bool _sampleLocationsEnable = false;
bool _isTessellationPipeline = false;
};


Expand Down
4 changes: 3 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@
SPIRVTessReflectionData reflectData;
std::string reflectErrorLog;
if (pTessCtlSS && pTessEvalSS) {
_isTessellationPipeline = true;

if (!getTessReflectionData(((MVKShaderModule*)pTessCtlSS->module)->getSPIRV(), pTessCtlSS->pName, ((MVKShaderModule*)pTessEvalSS->module)->getSPIRV(), pTessEvalSS->pName, reflectData, reflectErrorLog) ) {
setConfigurationResult(reportError(VK_ERROR_INITIALIZATION_FAILED, "Failed to reflect tessellation shaders: %s", reflectErrorLog.c_str()));
return;
Expand All @@ -502,7 +504,7 @@

// Tessellation - must ignore allowed bad pTessellationState pointer if not tess pipeline
_outputControlPointCount = reflectData.numControlPoints;
mvkSetOrClear(&_tessInfo, (pTessCtlSS && pTessEvalSS) ? pCreateInfo->pTessellationState : nullptr);
mvkSetOrClear(&_tessInfo, _isTessellationPipeline ? pCreateInfo->pTessellationState : nullptr);

// Render pipeline state. Do this as early as possible, to fail fast if pipeline requires a fail on cache-miss.
initMTLRenderPipelineState(pCreateInfo, reflectData, pPipelineFB, pVertexSS, pVertexFB, pTessCtlSS, pTessCtlFB, pTessEvalSS, pTessEvalFB, pFragmentSS, pFragmentFB);
Expand Down

0 comments on commit b0d20bb

Please sign in to comment.