Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Make SpirvValue contain an enum for its value#219

Merged
khyperia merged 1 commit intomainfrom
rich-spirvvalue
Nov 11, 2020
Merged

Make SpirvValue contain an enum for its value#219
khyperia merged 1 commit intomainfrom
rich-spirvvalue

Conversation

@khyperia
Copy link
Copy Markdown
Contributor

This is a prerequisite for all sorts of work (panics, printf extension, builtin functions, nested constants, all sorts of fun stuff) - SpirvValueKind is eventually going to have a decent number of cases. However, just for a proof-of-concept, I've added one "extra" case: ConstantPointer. Not only does this work towards my goal of removing the horrible zombie_even_in_user_code hack, it significantly improves error messages, since we're able to report violations of using the constant pointer directly in the compiler, not the linker, and so we have span information.

Before:

  error: dynamic use of address of constant
    |
    = note: Stack:
            main_fs
            Unnamed function ID %343

After:

  error: Cannot use this pointer directly, it must be dereferenced first
     --> examples/shaders/sky-shader/src/lib.rs:184:5
      |
  184 |     f(&2);
      |     ^^^^^

@khyperia
Copy link
Copy Markdown
Contributor Author

Because this is such a huge change, it's going to merge conflict with pretty much any compiler change, so I'm going to just merge this now.

@khyperia khyperia merged commit 9c8cec3 into main Nov 11, 2020
@khyperia khyperia deleted the rich-spirvvalue branch November 11, 2020 08:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant