https://github.com/shader-slang/slang
Revision 10190da440cd1c85c62c3d537f83893802deaff6 authored by Tim Foley on 21 May 2018, 22:53:01 UTC, committed by GitHub on 21 May 2018, 22:53:01 UTC
Fixes #566

The basic problem here is that the front-end translates a structure initializer-list expression into a `makeStruct` instruction (with one argument per field), but the IR type legalization logic wasn't handling the case where a `makeStruct` is used to construct a struct value that needs to get split by legalization.

The implementation is relatively straightforward, and like the other cases of instruction legalization for compound types, it follows the shape of the `LegalType`/`LegalVal` cases. The one interesting bit is that we need to be a bit careful and filter the single argument list for `makeStruct` into two in the case where we generate a "pair" type for something that has both "ordinary" and "special" (resource) fields. Luckily the `PairInfo` data that was generated by type legalization has exactly the information we need (by design).

This change does not address several issues that could be handled in follow-on changes:

* The `makeArray` instruction will face similar issues if it is applied to a type that requires legalization: we'd need to turn an array of `LegalVal`s into a bunch of distinct arrays.

* The error message when we hit the unimplemented case here isn't great. Ideally we should provide the line number of the instruction that fails in an error message when legalization fails.

This change tries to focus narrowly on the bug at hand, and leave these issues for later changes.
1 parent e2c2c22
History
Tip revision: 10190da440cd1c85c62c3d537f83893802deaff6 authored by Tim Foley on 21 May 2018, 22:53:01 UTC
Handle structure initializers in IR type legalization (#567)
Tip revision: 10190da
File Mode Size
docs
examples
external
source
tests
tools
.editorconfig -rw-r--r-- 937 bytes
.gitattributes -rw-r--r-- 95 bytes
.gitignore -rw-r--r-- 398 bytes
.gitmodules -rw-r--r-- 107 bytes
.travis.yml -rw-r--r-- 1.6 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.1 KB
LICENSE -rw-r--r-- 1.1 KB
Makefile -rw-r--r-- 6.3 KB
README.md -rw-r--r-- 4.9 KB
appveyor.yml -rw-r--r-- 3.5 KB
premake5.lua -rw-r--r-- 20.1 KB
slang.h -rw-r--r-- 41.4 KB
slang.sln -rw-r--r-- 8.9 KB
test.bat -rw-r--r-- 1.4 KB

README.md

back to top