mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Remove usages of SPVC
Remove all usages of SPVC from the code and update the fuzzers. Some of the include paths and deps came transitively from spvc, so needed to update build rules. This patch does NOT remove the flags related to spvc usage, they are just no-ops as the moment. After this patch lands I will remove the usage of those flags from the bots, then remove the flags. BUG=dawn:521 Change-Id: I0d7c3e28f79354c78f00c48b6a383b823094a069 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/27900 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
a1758eef07
commit
c35e2ba379
@@ -74,110 +74,47 @@ namespace dawn_native { namespace opengl {
|
||||
DAWN_TRY(InitializeBase());
|
||||
const std::vector<uint32_t>& spirv = GetSpirv();
|
||||
|
||||
std::unique_ptr<spirv_cross::CompilerGLSL> compilerImpl;
|
||||
spirv_cross::CompilerGLSL* compiler;
|
||||
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
|
||||
// If these options are changed, the values in DawnSPIRVCrossGLSLFastFuzzer.cpp need to
|
||||
// be updated.
|
||||
shaderc_spvc::CompileOptions options = GetCompileOptions();
|
||||
// If these options are changed, the values in DawnSPIRVCrossGLSLFastFuzzer.cpp need to
|
||||
// be updated.
|
||||
spirv_cross::CompilerGLSL::Options options;
|
||||
|
||||
// The range of Z-coordinate in the clipping volume of OpenGL is [-w, w], while it is
|
||||
// [0, w] in D3D12, Metal and Vulkan, so we should normalize it in shaders in all
|
||||
// backends. See the documentation of
|
||||
// spirv_cross::CompilerGLSL::Options::vertex::fixup_clipspace for more details.
|
||||
options.SetFlipVertY(true);
|
||||
options.SetFixupClipspace(true);
|
||||
// The range of Z-coordinate in the clipping volume of OpenGL is [-w, w], while it is
|
||||
// [0, w] in D3D12, Metal and Vulkan, so we should normalize it in shaders in all
|
||||
// backends. See the documentation of
|
||||
// spirv_cross::CompilerGLSL::Options::vertex::fixup_clipspace for more details.
|
||||
options.vertex.flip_vert_y = true;
|
||||
options.vertex.fixup_clipspace = true;
|
||||
|
||||
// TODO(cwallez@chromium.org): discover the backing context version and use that.
|
||||
// TODO(cwallez@chromium.org): discover the backing context version and use that.
|
||||
#if defined(DAWN_PLATFORM_APPLE)
|
||||
options.SetGLSLLanguageVersion(410);
|
||||
options.version = 410;
|
||||
#else
|
||||
options.SetGLSLLanguageVersion(440);
|
||||
#endif
|
||||
DAWN_TRY(CheckSpvcSuccess(
|
||||
mSpvcContext.InitializeForGlsl(spirv.data(), spirv.size(), options),
|
||||
"Unable to initialize instance of spvc"));
|
||||
DAWN_TRY(CheckSpvcSuccess(mSpvcContext.GetCompiler(reinterpret_cast<void**>(&compiler)),
|
||||
"Unable to get cross compiler"));
|
||||
} else {
|
||||
// If these options are changed, the values in DawnSPIRVCrossGLSLFastFuzzer.cpp need to
|
||||
// be updated.
|
||||
spirv_cross::CompilerGLSL::Options options;
|
||||
|
||||
// The range of Z-coordinate in the clipping volume of OpenGL is [-w, w], while it is
|
||||
// [0, w] in D3D12, Metal and Vulkan, so we should normalize it in shaders in all
|
||||
// backends. See the documentation of
|
||||
// spirv_cross::CompilerGLSL::Options::vertex::fixup_clipspace for more details.
|
||||
options.vertex.flip_vert_y = true;
|
||||
options.vertex.fixup_clipspace = true;
|
||||
|
||||
// TODO(cwallez@chromium.org): discover the backing context version and use that.
|
||||
#if defined(DAWN_PLATFORM_APPLE)
|
||||
options.version = 410;
|
||||
#else
|
||||
options.version = 440;
|
||||
options.version = 440;
|
||||
#endif
|
||||
|
||||
compilerImpl = std::make_unique<spirv_cross::CompilerGLSL>(spirv);
|
||||
compiler = compilerImpl.get();
|
||||
compiler->set_common_options(options);
|
||||
}
|
||||
spirv_cross::CompilerGLSL compiler(spirv);
|
||||
compiler.set_common_options(options);
|
||||
|
||||
DAWN_TRY(ExtractSpirvInfo(*compiler));
|
||||
DAWN_TRY(ExtractSpirvInfo(compiler));
|
||||
|
||||
// Extract bindings names so that it can be used to get its location in program.
|
||||
// Now translate the separate sampler / textures into combined ones and store their info.
|
||||
// We need to do this before removing the set and binding decorations.
|
||||
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
|
||||
mSpvcContext.BuildCombinedImageSamplers();
|
||||
} else {
|
||||
compiler->build_combined_image_samplers();
|
||||
}
|
||||
compiler.build_combined_image_samplers();
|
||||
|
||||
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
|
||||
std::vector<shaderc_spvc_combined_image_sampler> samplers;
|
||||
mSpvcContext.GetCombinedImageSamplers(&samplers);
|
||||
for (auto sampler : samplers) {
|
||||
mCombinedInfo.emplace_back();
|
||||
auto& info = mCombinedInfo.back();
|
||||
for (const auto& combined : compiler.get_combined_image_samplers()) {
|
||||
mCombinedInfo.emplace_back();
|
||||
|
||||
uint32_t samplerGroup;
|
||||
mSpvcContext.GetDecoration(sampler.sampler_id,
|
||||
shaderc_spvc_decoration_descriptorset, &samplerGroup);
|
||||
info.samplerLocation.group = BindGroupIndex(samplerGroup);
|
||||
|
||||
uint32_t samplerBinding;
|
||||
mSpvcContext.GetDecoration(sampler.sampler_id, shaderc_spvc_decoration_binding,
|
||||
&samplerBinding);
|
||||
info.samplerLocation.binding = BindingNumber(samplerBinding);
|
||||
|
||||
uint32_t textureGroup;
|
||||
mSpvcContext.GetDecoration(sampler.image_id, shaderc_spvc_decoration_descriptorset,
|
||||
&textureGroup);
|
||||
info.textureLocation.group = BindGroupIndex(textureGroup);
|
||||
|
||||
uint32_t textureBinding;
|
||||
mSpvcContext.GetDecoration(sampler.image_id, shaderc_spvc_decoration_binding,
|
||||
&textureBinding);
|
||||
info.textureLocation.binding = BindingNumber(textureBinding);
|
||||
|
||||
mSpvcContext.SetName(sampler.combined_id, info.GetName());
|
||||
}
|
||||
} else {
|
||||
for (const auto& combined : compiler->get_combined_image_samplers()) {
|
||||
mCombinedInfo.emplace_back();
|
||||
|
||||
auto& info = mCombinedInfo.back();
|
||||
info.samplerLocation.group = BindGroupIndex(
|
||||
compiler->get_decoration(combined.sampler_id, spv::DecorationDescriptorSet));
|
||||
info.samplerLocation.binding = BindingNumber(
|
||||
compiler->get_decoration(combined.sampler_id, spv::DecorationBinding));
|
||||
info.textureLocation.group = BindGroupIndex(
|
||||
compiler->get_decoration(combined.image_id, spv::DecorationDescriptorSet));
|
||||
info.textureLocation.binding = BindingNumber(
|
||||
compiler->get_decoration(combined.image_id, spv::DecorationBinding));
|
||||
compiler->set_name(combined.combined_id, info.GetName());
|
||||
}
|
||||
auto& info = mCombinedInfo.back();
|
||||
info.samplerLocation.group = BindGroupIndex(
|
||||
compiler.get_decoration(combined.sampler_id, spv::DecorationDescriptorSet));
|
||||
info.samplerLocation.binding =
|
||||
BindingNumber(compiler.get_decoration(combined.sampler_id, spv::DecorationBinding));
|
||||
info.textureLocation.group = BindGroupIndex(
|
||||
compiler.get_decoration(combined.image_id, spv::DecorationDescriptorSet));
|
||||
info.textureLocation.binding =
|
||||
BindingNumber(compiler.get_decoration(combined.image_id, spv::DecorationBinding));
|
||||
compiler.set_name(combined.combined_id, info.GetName());
|
||||
}
|
||||
|
||||
const EntryPointMetadata::BindingInfo& bindingInfo =
|
||||
@@ -205,27 +142,14 @@ namespace dawn_native { namespace opengl {
|
||||
break;
|
||||
}
|
||||
|
||||
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
|
||||
mSpvcContext.SetName(resourceId, GetBindingName(group, bindingNumber));
|
||||
mSpvcContext.UnsetDecoration(info.id, shaderc_spvc_decoration_binding);
|
||||
mSpvcContext.UnsetDecoration(info.id, shaderc_spvc_decoration_descriptorset);
|
||||
} else {
|
||||
compiler->set_name(resourceId, GetBindingName(group, bindingNumber));
|
||||
compiler->unset_decoration(info.id, spv::DecorationBinding);
|
||||
compiler->unset_decoration(info.id, spv::DecorationDescriptorSet);
|
||||
}
|
||||
compiler.set_name(resourceId, GetBindingName(group, bindingNumber));
|
||||
compiler.unset_decoration(info.id, spv::DecorationBinding);
|
||||
compiler.unset_decoration(info.id, spv::DecorationDescriptorSet);
|
||||
}
|
||||
}
|
||||
|
||||
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
|
||||
shaderc_spvc::CompilationResult result;
|
||||
DAWN_TRY(CheckSpvcSuccess(mSpvcContext.CompileShader(&result),
|
||||
"Unable to compile GLSL shader using spvc"));
|
||||
DAWN_TRY(CheckSpvcSuccess(result.GetStringOutput(&mGlslSource),
|
||||
"Unable to get GLSL shader text"));
|
||||
} else {
|
||||
mGlslSource = compiler->compile();
|
||||
}
|
||||
mGlslSource = compiler.compile();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user