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 instance index in forward clustered shader #54405

Merged
merged 1 commit into from
Oct 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ void main() {
#endif

uint instance_index = draw_call.instance_index;
instance_index_interp = instance_index;

bool is_multimesh = bool(instances.data[instance_index].flags & INSTANCE_FLAGS_MULTIMESH);
if (!is_multimesh) {
instance_index += gl_InstanceIndex;
}

instance_index_interp = instance_index;

mat4 world_matrix = instances.data[instance_index].transform;

mat3 world_normal_matrix;
Expand Down Expand Up @@ -565,12 +566,8 @@ void main() {
discard;
#endif

#ifdef USE_SUBGROUPS
//ensures instance_index is in sgpr
uint instance_index = subgroupBroadcastFirst(instance_index_interp);
#else
uint instance_index = instance_index_interp;
#endif

//lay out everything, whathever is unused is optimized away anyway
vec3 vertex = vertex_interp;
vec3 view = -normalize(vertex_interp);
Expand Down