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

Handle possibility of bad types in varying input/output signature. #161

Merged
merged 1 commit into from
Aug 15, 2017

Conversation

tangent-vector
Copy link
Contributor

Fixes #160

If the front-end runs into a type it doesn't understand in the parameter list of an entry point, it will create an ErrorType for that parameter, but then the parameter binding/layout rules will fail to create a TypeLayout for the prameter (and return NULL).
There were some places where the code was expecting that operation to succeed unconditionally, and so would crash when there was a bad type.

The specific case in the bug report was when the return type of a shader entry point was bad:

// `vec4` is not an HLSL type
vec4 main(...) { ... }

Note that the specific case in the buf report only manifests in "rewriter" mode (when the Slang compiler isn't allowed to issue error messages from the front-end), but the same basic thing would happen if the varying parameter/output had used a type that is invalid for varying input/output:

Texture2D main(...) { ... }

I'm not 100% happy with just adding more NULL checks for this, because there is no easy way to tell if they are exhaustive.
A better solution in the longer term might be to construct a kind of ErrorTypeLayout to represent cases where we wanted a type layout, but none could be constructed.

Fixes shader-slang#160

If the front-end runs into a type it doesn't understand in the parameter list of an entry point, it will create an `ErrorType` for that parameter, but then the parameter binding/layout rules will fail to create a `TypeLayout` for the prameter (and return `NULL`).
There were some places where the code was expecting that operation to succeed unconditionally, and so would crash when there was a bad type.

The specific case in the bug report was when the return type of a shader entry point was bad:

    // `vec4` is not an HLSL type
    vec4 main(...) { ... }

Note that the specific case in the buf report only manifests in "rewriter" mode (when the Slang compiler isn't allowed to issue error messages from the front-end), but the same basic thing would happen if the varying parameter/output had used a type that is invalid for varying input/output:

    Texture2D main(...) { ... }

I'm not 100% happy with just adding more `NULL` checks for this, because there is no easy way to tell if they are exhaustive.
A better solution in the longer term might be to construct a kind of `ErrorTypeLayout` to represent cases where we wanted a type layout, but none could be constructed.
@tangent-vector tangent-vector merged commit 4a9b281 into shader-slang:master Aug 15, 2017
@nbentyNV
Copy link
Collaborator

Are you preparing a new package for me? It will go into the dev branch, I'm not concerned about new features.

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

Successfully merging this pull request may close these issues.

2 participants