summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-03-14 12:52:59 -0700
committerGitHub <noreply@github.com>2018-03-14 12:52:59 -0700
commite69c0bd31c9d6af4937e8f9ffdb9c1bef4bd9d66 (patch)
tree47a91fc06e5195560fab873ca0e3f624e453206d
parent972dda6621f60b9b6d893e04c8f5e133be27b0a1 (diff)
When emitting from IR, skip structured types with `__builtin` modifier (#442)
This allows users who call `spAddBuiltins` to specify `struct` types that are provided for a target, and that should not be part of the generated HLSL/GLSL from Slang. The existing emit logic already skips emitting any basic, vector, matrix, or resource types, so this case really only triggers when the standard library needs to declare a completely ordinary `struct`. No provision is made right now for a `struct` type that might be builtin on one target, but need to be declared on another. That is a clear next step for this feature.
-rw-r--r--source/slang/emit.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index fa090121f..58c917fe7 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -7889,6 +7889,15 @@ emitDeclImpl(decl, nullptr);
emitIRUsedType(ctx, fieldType);
}
+ // Don't emit declarations for types that should be built-in on the target.
+ //
+ // TODO: This should really be checking if the type is a target intrinsic
+ // for the chosen target, and not just whether it is globally declared
+ // as a builtin (so that we can have types that are builtin in some cases,
+ // but not others).
+ if(declRef.getDecl()->HasModifier<BuiltinModifier>())
+ return;
+
Emit("struct ");
EmitDeclRef(declRef);
Emit("\n{\n");