Does setVisibilityResultMode works for instanced rendering?

lets say if I set setVisibilityResultMode:MTLVisibilityResultModeBoolean offset:0

and then call draw with instances:

drawIndexedPrimitives: ... instanceCount:10

Is it going to write one value into visibilityResultBuffer or 10 values?

Answered by Apple Designer in 679359022

Hi, there should only be one value written to the visibilityResultBuffer as the offset is determined by calling setVisibilityMode. The number stored in this location is dependent upon the MTLVisibilityResultMode enum which can be MTLVisibilityModeNone, MTLVisibilityModeBoolean, or MTLVisibilityModeCounting. The documentation does not indicate that the offset will be changed or incremented with instanced drawing.

Accepted Answer

Hi, there should only be one value written to the visibilityResultBuffer as the offset is determined by calling setVisibilityMode. The number stored in this location is dependent upon the MTLVisibilityResultMode enum which can be MTLVisibilityModeNone, MTLVisibilityModeBoolean, or MTLVisibilityModeCounting. The documentation does not indicate that the offset will be changed or incremented with instanced drawing.

You could indirectly access the occlusion result in another buffer for each instance/model off an id. It's also a bit tough since visibility writes 8-bytes, but many of the length fields such as those in the indirect draws are 4 bytes. What I really want is a way to only write 0 if occluded, and not write 1 on a boolean query if visible.

Does setVisibilityResultMode works for instanced rendering?
 
 
Q