ded icon indicating copy to clipboard operation
ded copied to clipboard

opengl can't compile the shader

Open GmosNM opened this issue 3 years ago • 9 comments

GL version 3.3 GL CALLBACK: type = 0x8251, severity = 0x826b, message = Buffer detailed info: Buffer object 1 (bound to GL_ARRAY_BUFFER_ARB, usage hint is GL_STATIC_DRAW) will use VIDEO memory as the source for buffer object operations. ERROR: could not compile GL_VERTEX_SHADER 0(28) : error C0000: syntax error, unexpected $undefined at token ""

ERROR: failed to compile ./shaders/free_glyph.vert shader file

GmosNM avatar Jan 07 '23 22:01 GmosNM

I think this is due to the fact that the read_entire_file does not zero out the remaining space if for instance you load a shader of 100 bytes and after that a shader of 90 bytes the last 10 bytes will still be of the old shader. The count in the SB will be correctly set to 90, but only the .items pointer is passed to the compile_shader function https://github.com/tsoding/ded/blob/983c71135214353f6c6b7544ea112cd3afd696a9/src/simple_renderer.c#L55 which apparently does not take into account null terminators halfway in the chararray.

So memsetting the full SB to 0 before reading the file helps https://github.com/tsoding/ded/blob/983c71135214353f6c6b7544ea112cd3afd696a9/src/common.c#L105

Note there is a PR with a working windows build (both local and CI) if you're interested https://github.com/tsoding/ded/pull/42

IRooc avatar Jan 13 '23 14:01 IRooc

I think this is due to the fact that the read_entire_file does not zero out the remaining space if for instance you load a shader of 100 bytes and after that a shader of 90 bytes the last 10 bytes will still be of the old shader. The count in the SB will be correctly set to 90, but only the .items pointer is passed to the compile_shader function

https://github.com/tsoding/ded/blob/983c71135214353f6c6b7544ea112cd3afd696a9/src/simple_renderer.c#L55

which apparently does not take into account null terminators halfway in the chararray. So memsetting the full SB to 0 before reading the file helps

https://github.com/tsoding/ded/blob/983c71135214353f6c6b7544ea112cd3afd696a9/src/common.c#L105

Note there is a PR with a working windows build (both local and CI) if you're interested #42

yo thank you but its not working for me image

GmosNM avatar Jan 13 '23 23:01 GmosNM

Are you trying to run the build_msvc file or the ded.exe?

The ded.exe needs the SDL2.dll and freetype.dll and it's the 64 bit version that is build maybe that's the issue.

Could you try to run from the commandline to see if there is some extra logging?

IRooc avatar Jan 14 '23 09:01 IRooc

image

GmosNM avatar Jan 14 '23 17:01 GmosNM

image

GmosNM avatar Jan 14 '23 17:01 GmosNM

Weird indeed, the good news is it builds 👍 What machine are you trying to run it on? 32bit vs 64bit?

Maybe this will have some guidance? https://www.passfab.com/windows-10/this-app-cant-run-on-your-pc.html

IRooc avatar Jan 15 '23 12:01 IRooc

I think this is due to the fact that the read_entire_file does not zero out the remaining space if for instance you load a shader of 100 bytes and after that a shader of 90 bytes the last 10 bytes will still be of the old shader. The count in the SB will be correctly set to 90, but only the .items pointer is passed to the compile_shader function

https://github.com/tsoding/ded/blob/983c71135214353f6c6b7544ea112cd3afd696a9/src/simple_renderer.c#L55

which apparently does not take into account null terminators halfway in the chararray. So memsetting the full SB to 0 before reading the file helps

https://github.com/tsoding/ded/blob/983c71135214353f6c6b7544ea112cd3afd696a9/src/common.c#L105

Note there is a PR with a working windows build (both local and CI) if you're interested #42

I am having the same issue as OP. I tried memset(sb, 0, size) before line 105 but I just get a crash. C isn't really my strength. Any thoughts on how to fix the shader compile error or am I just memsetting wrong?

drwbns avatar Aug 22 '23 05:08 drwbns

Hi maybe you memset to early? I have it on line 109 and that seems to work https://github.com/tsoding/ded/pull/42/files#diff-f6c5883a603e481644b9ef028b158acace9eabf59598f164dbec7b97d8da231fL109

IRooc avatar Aug 22 '23 11:08 IRooc

Hi maybe you memset to early? I have it on line 109 and that seems to work https://github.com/tsoding/ded/pull/42/files#diff-f6c5883a603e481644b9ef028b158acace9eabf59598f164dbec7b97d8da231fL109

That made it start working for me. I was memsetting the entire var, not just the items. Thanks!

drwbns avatar Aug 22 '23 14:08 drwbns