Add ifdefs for Tint API usage that may not be available
Fixed Kokoro failures when building Tint with all readers and writers disabled. Change-Id: I9bd041339236488dd563bbe687da883035f2a4b7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86181 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
a3b3b43162
commit
e0bee791cb
|
@ -380,6 +380,7 @@ namespace dawn::native {
|
|||
|
||||
ResultOrError<tint::Program> ParseWGSL(const tint::Source::File* file,
|
||||
OwnedCompilationMessages* outMessages) {
|
||||
#if TINT_BUILD_WGSL_READER
|
||||
tint::Program program = tint::reader::wgsl::Parse(file);
|
||||
if (outMessages != nullptr) {
|
||||
outMessages->AddMessages(program.Diagnostics());
|
||||
|
@ -391,10 +392,14 @@ namespace dawn::native {
|
|||
}
|
||||
|
||||
return std::move(program);
|
||||
#else
|
||||
return DAWN_FORMAT_VALIDATION_ERROR("TINT_BUILD_WGSL_READER is not defined.");
|
||||
#endif
|
||||
}
|
||||
|
||||
ResultOrError<tint::Program> ParseSPIRV(const std::vector<uint32_t>& spirv,
|
||||
OwnedCompilationMessages* outMessages) {
|
||||
#if TINT_BUILD_SPV_READER
|
||||
tint::Program program = tint::reader::spirv::Parse(spirv);
|
||||
if (outMessages != nullptr) {
|
||||
outMessages->AddMessages(program.Diagnostics());
|
||||
|
@ -405,6 +410,10 @@ namespace dawn::native {
|
|||
}
|
||||
|
||||
return std::move(program);
|
||||
#else
|
||||
return DAWN_FORMAT_VALIDATION_ERROR("TINT_BUILD_SPV_READER is not defined.");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
std::vector<uint64_t> GetBindGroupMinBufferSizes(const BindingGroupInfoMap& shaderBindings,
|
||||
|
@ -997,6 +1006,7 @@ namespace dawn::native {
|
|||
ShaderModuleWGSLDescriptor newWgslDesc;
|
||||
std::string newWgslCode;
|
||||
if (spirvDesc && device->IsToggleEnabled(Toggle::ForceWGSLStep)) {
|
||||
#if TINT_BUILD_WGSL_WRITER
|
||||
std::vector<uint32_t> spirv(spirvDesc->code, spirvDesc->code + spirvDesc->codeSize);
|
||||
tint::Program program;
|
||||
DAWN_TRY_ASSIGN(program, ParseSPIRV(spirv, outMessages));
|
||||
|
@ -1010,6 +1020,11 @@ namespace dawn::native {
|
|||
|
||||
spirvDesc = nullptr;
|
||||
wgslDesc = &newWgslDesc;
|
||||
#else
|
||||
device->EmitLog(
|
||||
WGPULoggingType_Info,
|
||||
"Toggle::ForceWGSLStep skipped because TINT_BUILD_WGSL_WRITER is not defined\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (spirvDesc) {
|
||||
|
|
|
@ -203,6 +203,7 @@ namespace dawn::native::vulkan {
|
|||
transformInputs, nullptr, nullptr));
|
||||
}
|
||||
|
||||
#if TINT_BUILD_SPV_WRITER
|
||||
tint::writer::spirv::Options options;
|
||||
options.emit_vertex_point_size = true;
|
||||
options.disable_workgroup_init = GetDevice()->IsToggleEnabled(Toggle::DisableWorkgroupInit);
|
||||
|
@ -249,6 +250,9 @@ namespace dawn::native::vulkan {
|
|||
GetLabel());
|
||||
|
||||
return std::move(moduleAndSpirv);
|
||||
#else
|
||||
return DAWN_INTERNAL_ERROR("TINT_BUILD_SPV_WRITER is not defined.");
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace dawn::native::vulkan
|
||||
|
|
Loading…
Reference in New Issue