msl: Explicity validate against MSL 1.2

Fixed: tint:1327
Change-Id: I7d2e182f60c42894410500f393a1235d37efe5e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71680
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2021-12-06 13:02:36 +00:00 committed by Tint LUCI CQ
parent 05eedd81b0
commit 9c7b39f365
3 changed files with 16 additions and 5 deletions

View File

@ -38,10 +38,15 @@ Result Msl(const std::string& xcrun_path, const std::string& source) {
#ifdef _WIN32
// On Windows, we should actually be running metal.exe from the Metal
// Developer Tools for Windows
auto res = xcrun("-x", "metal", "-c", "-o", "NUL", file.Path());
auto res = xcrun("-x", "metal", //
"-o", "NUL", //
"-std=osx-metal1.2", //
"-c", file.Path());
#else
auto res =
xcrun("-sdk", "macosx", "metal", "-o", "/dev/null", "-c", file.Path());
auto res = xcrun("-sdk", "macosx", "metal", //
"-o", "/dev/null", //
"-std=osx-metal1.2", //
"-c", file.Path());
#endif
if (!res.out.empty()) {
if (!result.output.empty()) {

View File

@ -40,8 +40,11 @@ Result MslUsingMetalAPI(const std::string& src) {
NSString* source = [NSString stringWithCString:src.c_str()
encoding:NSUTF8StringEncoding];
MTLCompileOptions* compileOptions = [MTLCompileOptions new];
compileOptions.languageVersion = MTLLanguageVersion1_2;
id<MTLLibrary> library = [device newLibraryWithSource:source
options:nil
options:compileOptions
error:&error];
if (!library) {
NSString* output = [error localizedDescription];

View File

@ -38,8 +38,11 @@ CompileResult CompileMslUsingMetalAPI(const std::string& src) {
NSString* source = [NSString stringWithCString:src.c_str()
encoding:NSUTF8StringEncoding];
MTLCompileOptions* compileOptions = [MTLCompileOptions new];
compileOptions.languageVersion = MTLLanguageVersion1_2;
id<MTLLibrary> library = [device newLibraryWithSource:source
options:nil
options:compileOptions
error:&error];
if (!library) {
NSString* output = [error localizedDescription];