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

internal/graphicsdriver/directx: crash when compiling a regular shader #2694

Open
1 of 10 tasks
hajimehoshi opened this issue Jul 7, 2023 · 2 comments
Open
1 of 10 tasks

Comments

@hajimehoshi
Copy link
Owner

Ebitengine Version

v2.6.0-alpha.3

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • Xbox
  • Web Browsers

Go Version (go version)

1.20.4

What steps will reproduce the problem?

Just launch a game on Windows?

What is the expected result?

No crash when compiling a shader

What happens instead?

directx: D3DCompile for PSMain failed, original source: struct Varyings {
	float4 Position : SV_POSITION;
	float2 M0 : TEXCOORD0;
	float4 M1 : COLOR;
};

float mod(float x, float y) {
	return x - y * floor(x/y);
}

float2 mod(float2 x, float2 y) {
	return x - y * floor(x/y);
}

float3 mod(float3 x, float3 y) {
	return x - y * floor(x/y);
}

float4 mod(float4 x, float4 y) {
	return x - y * floor(x/y);
}

float2x2 float2x2FromScalar(float x) {
	return float2x2(x, 0, 0, x);
}

float3x3 float3x3FromScalar(float x) {
	return float3x3(x, 0, 0, 0, x, 0, 0, 0, x);
}

float4x4 float4x4FromScalar(float x) {
	return float4x4(x, 0, 0, 0, 0, x, 0, 0, 0, 0, x, 0, 0, 0, 0, x);
}

cbuffer Uniforms : register(b0) {
	float2 U0 : packoffset(c0);
	float2 U1[4] : packoffset(c1);
	float2 U2 : packoffset(c4.z);
	float2 U3 : packoffset(c5);
	float2 U4[3] : packoffset(c6);
	float2 U5 : packoffset(c8.z);
	float2 U6 : packoffset(c9);
	float4x4 U7 : packoffset(c10);
}

Texture2D T0 : register(t0);
Texture2D T1 : register(t1);
Texture2D T2 : register(t2);
Texture2D T3 : register(t3);

float4 F4(in float2 l0);

float4 F4(in float2 l0) {
	return T0.Load(int3(l0, 0));
}

float4 PSMain(Varyings varyings) : SV_TARGET {
	float4 l0 = 0.0;
	l0 = F4(varyings.M0);
	l0 = (l0) * (varyings.M1);
	return l0;
}
, directx: D3DCompile failed: shader:36:24: E5000: syntax error, unexpected '(', expecting ';' or ','
: HANDLE(2147500037)

Anything else you feel useful to add?

This was reported from a game with Ebitengine.

/CC @wasedaigo

@hajimehoshi hajimehoshi added the bug label Jul 7, 2023
@hajimehoshi hajimehoshi added this to the v2.5.6 milestone Jul 7, 2023
@hajimehoshi
Copy link
Owner Author

DirectX 11: 78d7694
v2.6.0-alpha.3: e3ab7b9

@hajimehoshi
Copy link
Owner Author

packoffset should be available in the shader model v4 https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-constants so this is pretty odd.

@hajimehoshi hajimehoshi removed this from the v2.5.6 milestone Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant