mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-15 11:51:22 +00:00
Pass preserveInvariance to MSL compiler if necessary
Fixed: dawn:977 Change-Id: I7df2080424a4af0b7155ee24f61bb37f0674de82 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57741 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
726d17947a
commit
2103fa629e
@ -58,7 +58,8 @@ namespace dawn_native { namespace metal {
|
|||||||
const RenderPipeline* renderPipeline,
|
const RenderPipeline* renderPipeline,
|
||||||
const VertexState* vertexState,
|
const VertexState* vertexState,
|
||||||
std::string* remappedEntryPointName,
|
std::string* remappedEntryPointName,
|
||||||
bool* needsStorageBufferLength);
|
bool* needsStorageBufferLength,
|
||||||
|
bool* hasInvariantAttribute);
|
||||||
ResultOrError<std::string> TranslateToMSLWithSPIRVCross(
|
ResultOrError<std::string> TranslateToMSLWithSPIRVCross(
|
||||||
const char* entryPointName,
|
const char* entryPointName,
|
||||||
SingleShaderStage stage,
|
SingleShaderStage stage,
|
||||||
|
@ -59,7 +59,8 @@ namespace dawn_native { namespace metal {
|
|||||||
const RenderPipeline* renderPipeline,
|
const RenderPipeline* renderPipeline,
|
||||||
const VertexState* vertexState,
|
const VertexState* vertexState,
|
||||||
std::string* remappedEntryPointName,
|
std::string* remappedEntryPointName,
|
||||||
bool* needsStorageBufferLength) {
|
bool* needsStorageBufferLength,
|
||||||
|
bool* hasInvariantAttribute) {
|
||||||
ScopedTintICEHandler scopedICEHandler(GetDevice());
|
ScopedTintICEHandler scopedICEHandler(GetDevice());
|
||||||
|
|
||||||
std::ostringstream errorStream;
|
std::ostringstream errorStream;
|
||||||
@ -160,6 +161,7 @@ namespace dawn_native { namespace metal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
*needsStorageBufferLength = result.needs_storage_buffer_sizes;
|
*needsStorageBufferLength = result.needs_storage_buffer_sizes;
|
||||||
|
*hasInvariantAttribute = result.has_invariant_attribute;
|
||||||
|
|
||||||
return std::move(result.msl);
|
return std::move(result.msl);
|
||||||
}
|
}
|
||||||
@ -292,11 +294,12 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
std::string remappedEntryPointName;
|
std::string remappedEntryPointName;
|
||||||
std::string msl;
|
std::string msl;
|
||||||
|
bool hasInvariantAttribute = false;
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
||||||
DAWN_TRY_ASSIGN(
|
DAWN_TRY_ASSIGN(msl, TranslateToMSLWithTint(
|
||||||
msl, TranslateToMSLWithTint(entryPointName, stage, layout, sampleMask,
|
entryPointName, stage, layout, sampleMask, renderPipeline,
|
||||||
renderPipeline, vertexState, &remappedEntryPointName,
|
vertexState, &remappedEntryPointName,
|
||||||
&out->needsStorageBufferLength));
|
&out->needsStorageBufferLength, &hasInvariantAttribute));
|
||||||
} else {
|
} else {
|
||||||
DAWN_TRY_ASSIGN(msl, TranslateToMSLWithSPIRVCross(entryPointName, stage, layout,
|
DAWN_TRY_ASSIGN(msl, TranslateToMSLWithSPIRVCross(entryPointName, stage, layout,
|
||||||
sampleMask, renderPipeline,
|
sampleMask, renderPipeline,
|
||||||
@ -322,11 +325,17 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
NSRef<NSString> mslSource = AcquireNSRef([[NSString alloc] initWithUTF8String:msl.c_str()]);
|
NSRef<NSString> mslSource = AcquireNSRef([[NSString alloc] initWithUTF8String:msl.c_str()]);
|
||||||
|
|
||||||
|
NSRef<MTLCompileOptions> compileOptions = AcquireNSRef([[MTLCompileOptions alloc] init]);
|
||||||
|
if (hasInvariantAttribute) {
|
||||||
|
if (@available(macOS 11.0, iOS 13.0, *)) {
|
||||||
|
(*compileOptions).preserveInvariance = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice();
|
auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice();
|
||||||
NSError* error = nullptr;
|
NSError* error = nullptr;
|
||||||
NSPRef<id<MTLLibrary>> library =
|
NSPRef<id<MTLLibrary>> library =
|
||||||
AcquireNSPRef([mtlDevice newLibraryWithSource:mslSource.Get()
|
AcquireNSPRef([mtlDevice newLibraryWithSource:mslSource.Get()
|
||||||
options:nullptr
|
options:compileOptions.Get()
|
||||||
error:&error]);
|
error:&error]);
|
||||||
if (error != nullptr) {
|
if (error != nullptr) {
|
||||||
if (error.code != MTLLibraryErrorCompileWarning) {
|
if (error.code != MTLLibraryErrorCompileWarning) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user