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 shader incorrectly expects int on uint and vice-versa in cases #95473

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Aug 13, 2024

This code will now compile correctly:

shader_type spatial;

const int iOne = 1;
const uint uOne = 1u;

void fragment() {
	
	int i; uint u;
	switch (i) {
		case iOne: break;
	}
	switch (u) {
		case uOne: break;
	}
}

Also, I've placed the case label duplication check code into case processing branch, the reason for that is that it will print an error at the case label itself:

Details

изображение

rather than

Details

изображение

Besides that, I've fixed a shader compiler failure when declaring a switch like this:

switch(1u) {
	default:
	break;

	case 1u:
	break;

	default:
	break;
}

@Chaosus Chaosus requested a review from a team as a code owner August 13, 2024 08:53
@Chaosus Chaosus added this to the 4.4 milestone Aug 13, 2024
@Chaosus Chaosus force-pushed the shader_fix_switch_bugs branch 2 times, most recently from 1006834 to 6c5c375 Compare August 13, 2024 09:10
@Chaosus Chaosus force-pushed the shader_fix_switch_bugs branch from 6c5c375 to 7d3aeea Compare September 11, 2024 06:13
@Chaosus Chaosus force-pushed the shader_fix_switch_bugs branch from 7d3aeea to b2611c1 Compare September 11, 2024 06:22
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine!

@akien-mga akien-mga merged commit 8d9a446 into godotengine:master Sep 12, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GDShader incorrectly expects int cases in switch on uint expressions
3 participants