Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix iOS 16.x version failed to pass MTLBinding's arg.used check #3271

Closed
wants to merge 1 commit into from

Conversation

junjie020
Copy link
Contributor

It failed to pass this check:

bgfx/src/renderer_mtl.mm

Lines 1956 to 1957 in 4cb7b71

if (arg.used)
{

on:

  • iOS 16.x version(won't be happend in iOS 17.x version)
  • Queue Debugging option disable in XCode Scheme or launch App by touch the APP on the screen

My test devices are :
iPhone X with iOS version 16.7.6 and iPhone 8 Plus with iOS version 16.7.6
iPhone 15 pro with iOS version 17.2/17.4
iPhone SE3 with iOS version 17.2/17.4

image

The option Queue Debugging enable or not will affect MTLBinding's used value. If disable, it will always false; ortherwise true.

But in iOS 17.x, this value(MTLBinding.used) are always true.

This problem also relate to this issue:
##3116

I write this code to locate this problom:

bool findArgument(id<MTLBinding> b, NSArray<MTLArgument*>* arguments){
	const char* name = utf8String(b.name);
	for (MTLArgument *a in arguments){
		if (a.active && 0 == strcmp(utf8String(a.name), name)){
			return true;
		}
	}
	return false;
}

void checkArguments(NSArray<id<MTLBinding>> *bindings, NSArray<MTLArgument*>* arguments) {
	for (id<MTLBinding> b in bindings){
		assert(findArgument(b, arguments));
	}
}
void checkRelfectionArguments(RenderPipelineReflection reflection){
	checkArguments(reflection.vertexBindings, reflection.vertexArguments);
	checkArguments(reflection.fragmentBindings, reflection.fragmentArguments);
}

add this code before this line:

checkRelfectionArguments(reflection);

https://github.com/bkaradzic/bgfx/blob/master/src/renderer_mtl.mm#L2361

I found that reflection.vertexBindings / reflection.fragmentBindings is equal to reflection.vertexArgumens/reflection.fragmentArguments's MTLArgument with active is true

So, I think it's no need to check MTLBinding's used in ProcessArguments function.

@junjie020
Copy link
Contributor Author

After few more test, this assumption is wrong:

So, I think it's no need to check MTLBinding's used in ProcessArguments function.

That test is: create a metal shader with a buffer, but not use it in this shader.
That not use value in MTLBinding.used will return false, also MTLArgument.active is the same value in iOS 17.x version.

That's my fault.

@junjie020 junjie020 closed this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant