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

sokol: shader v compiler error #21426

Open
JoeyShapiro opened this issue May 5, 2024 · 3 comments
Open

sokol: shader v compiler error #21426

JoeyShapiro opened this issue May 5, 2024 · 3 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@JoeyShapiro
Copy link
Contributor

JoeyShapiro commented May 5, 2024

Describe the bug

I was told to report this by the compiler:

C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,

Reproduction Steps

go to v/examples/sokol/07_simple_shader_glsl
open simple_shader.v and go to line 132
change one of these lines, renaming the C value.

// something like this
pipeline_desc.layout.attrs[C.ATTR_vs_position].format = .float3
// to something like this
pipeline_desc.layout.attrs[C.ATTR_vs_aposition].format = .float3

compile the code. you should get the following error. (v run .)

Expected Behavior

compiled code

Current Behavior

==================
                                                            ~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v_501/simple_shader.01HX381VZ0CFX7SD21X4M8RFT9.tmp.c:21250:43: error: use of undeclared identifier 'ATTR_vs_aposition'
        pipeline_desc.layout.attrs[v_fixed_index(ATTR_vs_aposition, 16)].format = sokol__gfx__VertexFormat__float3;
                                                 ^
/tmp/v_501/simple_shader.01HX381VZ0CFX7SD21X4M8RFT9.tmp.c:21251:73: warning: implicit conversion from enumeration type 'sokol__gfx__VertexFormat' to different enumeration type 'sg_vertex_format' (aka 'enum sg_vertex_format') [-Wenum-conversion]
        pipeline_desc.layout.attrs[v_fixed_index(ATTR_vs_color0, 16)].format = sokol__gfx__VertexFormat__float4;
                                                                             ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 warnings and 1 error generated.
...
==================
(Use `v -cg` to print the entire error message)

builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

Possible Solution

it appears to be caused by the variable being misnamed.

Additional Information/Context

No response

V version

V 0.4.5 206c0e3

Environment details (OS name and version, etc.)

V full version: V 0.4.5 206c0e3
OS: macos, macOS, 14.4, 23E214
Processor: 14 cpus, 64bit, little endian, Apple M3 Max

getwd: /Users/oniichan/Downloads/v/examples/sokol/07_simple_shader_glsl
vexe: /Users/oniichan/Downloads/v/v
vexe mtime: 2024-04-26 00:31:07

vroot: OK, value: /Users/oniichan/Downloads/v
VMODULES: OK, value: /Users/oniichan/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.39.3 (Apple Git-146)
Git vroot status: Error: fatal: not a git repository (or any of the parent directories): .git
.git/config present: false

CC version: Apple clang version 15.0.0 (clang-1500.3.9.4)
thirdparty/tcc status: thirdparty-macos-arm64 5c1d002f

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@JoeyShapiro JoeyShapiro added the Bug This tag is applied to issues which reports bugs. label May 5, 2024
@spytheman
Copy link
Member

spytheman commented May 5, 2024

If you change one of the names there, you have to also change the corresponding name in simple_shader.glsl:
in vec4 aposition;

@JoeyShapiro
Copy link
Contributor Author

yeah, its a pretty simple fix, and didn't take long to notice. but the compiler said I should report it as a bug. granted this isn't pure v code. I just thought I should report it.

@spytheman
Copy link
Member

Yes. Thank you for reporting it.

We should think of a way to handle those better (since V can know about the shader variables from its v shader tool, it should be able to offer more useful errors for that specific situation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

2 participants