Make all backend::ShaderModule get SPIRV from the frontend

This will make it easier to support SPIRV as a chained sub-descriptor of
ShaderModuleDescriptor in follow-up CLs.

Also fix a couple style and formatting issues.

Bug: dawn:22
Change-Id: Iddaf1f87edee65687e17670b70024835918a0382
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19864
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez
2020-04-21 07:57:30 +00:00
committed by Commit Bot service account
parent 3966eb1175
commit 21744d0fb8
11 changed files with 70 additions and 63 deletions

View File

@@ -125,14 +125,14 @@ namespace dawn_native { namespace null {
}
ResultOrError<ShaderModuleBase*> Device::CreateShaderModuleImpl(
const ShaderModuleDescriptor* descriptor) {
auto module = new ShaderModule(this, descriptor);
Ref<ShaderModule> module = AcquireRef(new ShaderModule(this, descriptor));
if (IsToggleEnabled(Toggle::UseSpvc)) {
shaderc_spvc::CompileOptions options;
options.SetValidate(IsValidationEnabled());
shaderc_spvc::Context* context = module->GetContext();
shaderc_spvc_status status =
context->InitializeForGlsl(descriptor->code, descriptor->codeSize, options);
shaderc_spvc_status status = context->InitializeForGlsl(
module->GetSpirv().data(), module->GetSpirv().size(), options);
if (status != shaderc_spvc_status_success) {
return DAWN_VALIDATION_ERROR("Unable to initialize instance of spvc");
}
@@ -144,10 +144,10 @@ namespace dawn_native { namespace null {
}
DAWN_TRY(module->ExtractSpirvInfo(*compiler));
} else {
spirv_cross::Compiler compiler(descriptor->code, descriptor->codeSize);
spirv_cross::Compiler compiler(module->GetSpirv());
DAWN_TRY(module->ExtractSpirvInfo(compiler));
}
return module;
return module.Detach();
}
ResultOrError<SwapChainBase*> Device::CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) {