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

crash with 1-float attribute vertex stream #1175

Closed
CedricGuillemet opened this issue Dec 1, 2022 · 4 comments
Closed

crash with 1-float attribute vertex stream #1175

CedricGuillemet opened this issue Dec 1, 2022 · 4 comments
Assignees
Milestone

Comments

@CedricGuillemet
Copy link
Contributor

forum thread : https://forum.babylonjs.com/t/bgfx-babylon-native-bug-when-using-float-vertex-buffer-shader-attribute/36158

Vertex stream with 1 float stream crashes BN (in shader creation as it looks) whereas using a vec2 instead works fine.

@sebavan
Copy link
Member

sebavan commented Dec 3, 2022

This does not crash on Windows FYI, but we reproed on another project on Android. (did not had a chance to test on IOS) but just to let you know it might be platform specific.

@bghgary bghgary added this to the 6.0 milestone Dec 7, 2022
@bghgary
Copy link
Contributor

bghgary commented Dec 7, 2022

At least investigate what the problem is.

@SergioRZMasson
Copy link
Contributor

The problem seems to be related to a bug when glslang parsers an "AssignmentMultiplicationVectorByFloat" operation. The problem is not related to the usage of a float buffer itself, but to the instruction where the UV vec2 gets multiplied by a float.

Replacing the shader code with the code below make the code work and also uses a float vertex buffer:

BABYLON.Effect.ShadersStore["customVertexShader"]= "\r\n"+   
		"precision highp float;\r\n"+

    	"// Attributes\r\n"+
    	"attribute vec3 position;\r\n"+
    	"attribute vec2 uv;\r\n"+
        "attribute float side;\r\n"+

    	"// Uniforms\r\n"+
    	"uniform mat4 worldViewProjection;\r\n"+

    	"// Varying\r\n"+
    	"varying vec2 vUV;\r\n"+

    	"void main(void) {\r\n"+
    	"    gl_Position = worldViewProjection * vec4(position, 1.0);\r\n"+

    	"    vec2 sidev = vec2(side, side);\r\n"+
        "    vUV = uv * sidev;\r\n"+
    	"}\r\n";

This bug seems to be related to glslang, maybe updating to a more recent version might fix it.

@thomlucc thomlucc modified the milestones: 6.0, 7.0 Mar 22, 2023
@SergioRZMasson
Copy link
Contributor

After updating glslang and SPIRV-Cross this issue was fixed. PR #1285

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

No branches or pull requests

5 participants