[spirv] warn {row|col}_major on standalone matrix. (#935)

This commit is contained in:
Ehsan 2017-12-18 16:48:16 -05:00 коммит произвёл GitHub
Родитель 1c498f3743
Коммит cb4e570b82
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -2335,3 +2335,6 @@ either because of no Vulkan equivalents at the moment, or because of deprecation
``RWByteAddressBuffer`` are not represented as image types in SPIR-V, using the
output unsigned integer ``status`` argument in their ``Load*`` methods is not
supported. Using these methods with the ``status`` argument will cause a compiler error.
* Applying ``row_major`` or ``column_major`` attributes to a stand-alone matrix will be
ignored by the compiler because ``RowMajor`` and ``ColMajor`` decorations in SPIR-V are
only allowed to be applied to members of structures. A warning will be issued by the compiler.

Просмотреть файл

@ -821,6 +821,16 @@ void SPIRVEmitter::doRecordDecl(const RecordDecl *recordDecl) {
void SPIRVEmitter::doVarDecl(const VarDecl *decl) {
validateVKAttributes(decl);
if (decl->hasAttr<HLSLRowMajorAttr>()) {
emitWarning("row_major attribute for stand-alone matrix is not supported",
decl->getAttr<HLSLRowMajorAttr>()->getLocation());
}
if (decl->hasAttr<HLSLColumnMajorAttr>()) {
emitWarning(
"column_major attribute for stand-alone matrix is not supported",
decl->getAttr<HLSLColumnMajorAttr>()->getLocation());
}
if (decl->hasAttr<VKPushConstantAttr>()) {
// This is a VarDecl for PushConstant block.
(void)declIdMapper.createPushConstant(decl);

Просмотреть файл

@ -0,0 +1,18 @@
// Run: %dxc -T ps_6_0 -E main
// CHECK: 4:1: warning: row_major attribute for stand-alone matrix is not supported
row_major float2x3 grMajorMat;
// CHECK: 6:1: warning: column_major attribute for stand-alone matrix is not supported
column_major float2x3 gcMajorMat;
// CHECK: 9:8: warning: row_major attribute for stand-alone matrix is not supported
static row_major float2x3 gsrMajorMat;
// CHECK: 11:8: warning: column_major attribute for stand-alone matrix is not supported
static column_major float2x3 gscMajorMat;
void main() {
// CHECK: 15:3: warning: row_major attribute for stand-alone matrix is not supported
row_major float2x3 rMajorMat;
// CHECK: 17:3: warning: column_major attribute for stand-alone matrix is not supported
column_major float2x3 cMajorMat;
}

Просмотреть файл

@ -45,6 +45,9 @@ TEST_F(WholeFileTest, EmptyStructInterfaceVS) {
TEST_F(FileTest, ScalarTypes) { runFileTest("type.scalar.hlsl"); }
TEST_F(FileTest, VectorTypes) { runFileTest("type.vector.hlsl"); }
TEST_F(FileTest, MatrixTypes) { runFileTest("type.matrix.hlsl"); }
TEST_F(FileTest, MatrixTypesMajorness) {
runFileTest("type.matrix.majorness.hlsl", FileTest::Expect::Warning);
}
TEST_F(FileTest, StructTypes) { runFileTest("type.struct.hlsl"); }
TEST_F(FileTest, ClassTypes) { runFileTest("type.class.hlsl"); }
TEST_F(FileTest, ArrayTypes) { runFileTest("type.array.hlsl"); }