GithubHelp home page GithubHelp logo

Comments (8)

kvark avatar kvark commented on August 20, 2024 1

The check should be a part of #59, but it's not there yet

from naga.

pjoe avatar pjoe commented on August 20, 2024 1

Sounds simple enough, will try adding to glsl-in

from naga.

Napokue avatar Napokue commented on August 20, 2024

Thank you for the issue! I tested it, and found out that this is an issue not at the SPIR-V back-end, but rather at the front-end and/or IR.

SPIR-V always requires a termination at the end of a block. So in this case it is a void return, which is simply just return at the end of a function. However, for now you need to explicitly specify the return in the function.

A long term fix would be for the IR to check if a function has an explicit return, if not implicitly add it.

from naga.

pjoe avatar pjoe commented on August 20, 2024

Ok, so should we add explicit return in the Rosetta test until this is fixed?

FYI: I added return support for glsl-new in #179

from naga.

Napokue avatar Napokue commented on August 20, 2024

I say for now that would be the best thing to do, as the validation pass is not yet implemented. But first we need #179 for that, then it would be trivial to add the explicit return.

from naga.

kristoff3r avatar kristoff3r commented on August 20, 2024

I don't know spirv well at all, but why can't we just do something like

block
    .termination
    .as_ref()
    .unwrap_or(&super::instructions::instruction_return())
    .to_words(sink);

Is it just to benefit the other backends as well that it needs to be a validator pass, or should it sometimes do something else than a simple return?

from naga.

Napokue avatar Napokue commented on August 20, 2024

Yes that is possible, but the point is that it should never reach a back-end whenever a terminate isn't present. So there will probably be two options as far as I can think of now:

  1. We check it at the validator pass and throw an compiler error.
  2. We add a check to the optimization pass and "magically" add a return, when the source code does not contain it. The problem is when the return is not a void return, and requires a value. Do we assign it the default value or still throw a compiler error?

from naga.

kvark avatar kvark commented on August 20, 2024

The IR has to have a non-valued return regardless of what we do here. So we might as well require this at IR level that all control flow paths from a function end up in this return. I suppose the changes to frontends would be fairly trivial?

from naga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.