Metal argument buffers handle descriptor bindings with zero descriptor count.
If descriptor count is zero, don't add MTLArgumentDescriptor to MTLArgumentEncoder, and don't populate resources into shader converter. Don't update command encoder resource usage if resource is nil.
This commit is contained in:
parent
1ba6065490
commit
0e2439c3e8
@ -903,19 +903,11 @@ void MVKGraphicsResourcesCommandEncoderState::bindMetalArgumentBuffer(MVKShaderS
|
||||
bindBuffer(stage, buffBind);
|
||||
}
|
||||
|
||||
//void MVKGraphicsResourcesCommandEncoderState::encodeDynamicBufferOffset(MVKShaderStage stage,
|
||||
// uint32_t descSetIndex,
|
||||
// uint32_t descIndex,
|
||||
// uint32_t dynamicOffsetBufferIndex) {
|
||||
// uint32_t dynamicOffset = _dynamicOffsets[getDynamicOffsetKey(descSetIndex, descIndex)];
|
||||
// updateImplicitBuffer(_shaderStageResourceBindings[stage].dynamicOffsets, dynamicOffsetBufferIndex, dynamicOffset);
|
||||
//}
|
||||
|
||||
void MVKGraphicsResourcesCommandEncoderState::encodeArgumentBufferResourceUsage(id<MTLResource> mtlResource,
|
||||
MTLResourceUsage mtlUsage,
|
||||
MTLRenderStages mtlStages) {
|
||||
auto* mtlRendEnc = _cmdEncoder->_mtlRenderEncoder;
|
||||
if (mtlRendEnc && mtlStages) {
|
||||
if (mtlResource && mtlStages) {
|
||||
auto* mtlRendEnc = _cmdEncoder->_mtlRenderEncoder;
|
||||
if ([mtlRendEnc respondsToSelector: @selector(useResource:usage:stages:)]) {
|
||||
[mtlRendEnc useResource: mtlResource usage: mtlUsage stages: mtlStages];
|
||||
} else {
|
||||
@ -1042,19 +1034,13 @@ void MVKComputeResourcesCommandEncoderState::bindMetalArgumentBuffer(MVKShaderSt
|
||||
bindBuffer(buffBind);
|
||||
}
|
||||
|
||||
//void MVKComputeResourcesCommandEncoderState::encodeDynamicBufferOffset(MVKShaderStage stage,
|
||||
// uint32_t descSetIndex,
|
||||
// uint32_t descIndex,
|
||||
// uint32_t dynamicOffsetBufferIndex) {
|
||||
// uint32_t dynamicOffset = _dynamicOffsets[getDynamicOffsetKey(descSetIndex, descIndex)];
|
||||
// updateImplicitBuffer(_resourceBindings.dynamicOffsets, dynamicOffsetBufferIndex, dynamicOffset);
|
||||
//}
|
||||
|
||||
void MVKComputeResourcesCommandEncoderState::encodeArgumentBufferResourceUsage(id<MTLResource> mtlResource,
|
||||
MTLResourceUsage mtlUsage,
|
||||
MTLRenderStages mtlStages) {
|
||||
auto* mtlCompEnc = _cmdEncoder->getMTLComputeEncoder(kMVKCommandUseDispatch);
|
||||
[mtlCompEnc useResource: mtlResource usage: mtlUsage];
|
||||
if (mtlResource) {
|
||||
auto* mtlCompEnc = _cmdEncoder->getMTLComputeEncoder(kMVKCommandUseDispatch);
|
||||
[mtlCompEnc useResource: mtlResource usage: mtlUsage];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,7 +139,7 @@ public:
|
||||
/**
|
||||
* Returns the indexes into the resources, relative to the descriptor set.
|
||||
* When using Metal argument buffers, all stages have the same values, and
|
||||
* in that case the value can be withheld and a default stage will be used.
|
||||
* in that case the stage can be withheld and a default stage will be used.
|
||||
*/
|
||||
MVKShaderStageResourceBinding& getMetalResourceIndexOffsets(MVKShaderStage stage = kMVKShaderStageVertex) {
|
||||
return _mtlResourceIndexOffsets.getMetalResourceIndexs(stage);
|
||||
|
@ -500,11 +500,14 @@ void MVKDescriptorSetLayoutBinding::addMTLArgumentDescriptor(NSMutableArray<MTLA
|
||||
MTLArgumentAccess access,
|
||||
mvk::SPIRVToMSLConversionConfiguration& shaderConfig,
|
||||
uint32_t descSetIdx) {
|
||||
uint32_t descCnt = getDescriptorCount();
|
||||
if (descCnt == 0) { return; }
|
||||
|
||||
auto* argDesc = [MTLArgumentDescriptor argumentDescriptor];
|
||||
argDesc.dataType = dataType;
|
||||
argDesc.access = access;
|
||||
argDesc.index = argIndex;
|
||||
argDesc.arrayLength = getDescriptorCount();
|
||||
argDesc.arrayLength = descCnt;
|
||||
argDesc.textureType = shaderConfig.getMTLTextureType(descSetIdx, getBinding());
|
||||
|
||||
[args addObject: argDesc];
|
||||
@ -519,14 +522,15 @@ void MVKDescriptorSetLayoutBinding::populateShaderConverterContext(mvk::SPIRVToM
|
||||
// Establish the resource indices to use, by combining the offsets of the DSL and this DSL binding.
|
||||
MVKShaderResourceBinding mtlIdxs = _mtlResourceIndexOffsets + dslMTLRezIdxOffsets;
|
||||
|
||||
for (uint32_t stage = kMVKShaderStageVertex; stage < kMVKShaderStageMax; stage++) {
|
||||
if (_applyToStage[stage]) {
|
||||
uint32_t descCnt = getDescriptorCount();
|
||||
for (uint32_t stage = kMVKShaderStageVertex; stage < kMVKShaderStageMax; stage++) {
|
||||
if (_applyToStage[stage] && descCnt > 0) {
|
||||
mvkPopulateShaderConverterContext(context,
|
||||
mtlIdxs.stages[stage],
|
||||
MVKShaderStage(stage),
|
||||
dslIndex,
|
||||
_info.binding,
|
||||
getDescriptorCount(),
|
||||
descCnt,
|
||||
getDescriptorType(),
|
||||
mvkSamp);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user