Remove SPIRV-Cross support from Vulkan backend.

Bug: dawn:1036

Change-Id: I463d067af03fbcd732402fd0e0cc7045669e13b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61220
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Stephen White 2021-08-10 02:56:03 +00:00 committed by Dawn LUCI CQ
parent c61a24b5fd
commit a03e847227
11 changed files with 76 additions and 135 deletions

View File

@ -134,14 +134,14 @@ namespace dawn_native {
mFormatTable = BuildFormatTable(this);
SetDefaultToggles();
#if defined(DAWN_PLATFORM_MACOS)
if (!IsToggleEnabled(Toggle::UseTintGenerator)) {
if ((adapter->GetBackendType() == wgpu::BackendType::Metal ||
adapter->GetBackendType() == wgpu::BackendType::Vulkan) &&
!IsToggleEnabled(Toggle::UseTintGenerator)) {
EmitLog(
WGPULoggingType_Warning,
"Non-tint generator is not available on this platform; toggle disable ignored.\n");
"Non-tint generator is not available on this backend; toggle disable ignored.\n");
ForceSetToggle(Toggle::UseTintGenerator, true);
}
#endif
}
DeviceBase::~DeviceBase() = default;

View File

@ -192,7 +192,7 @@ namespace dawn_native { namespace metal {
// Vertex buffer robustness is implemented by using programmable vertex pulling. Enable
// that code path if it isn't explicitly disabled.
if (IsToggleEnabled(Toggle::UseTintGenerator) && IsRobustnessEnabled()) {
if (IsRobustnessEnabled()) {
SetToggle(Toggle::MetalEnableVertexPulling, true);
}

View File

@ -83,10 +83,8 @@ namespace dawn_native { namespace opengl {
DAWN_TRY(InitializeBase(parseResult));
// Tint currently does not support emitting GLSL, so when provided a Tint program need to
// generate SPIRV and SPIRV-Cross reflection data to be used in this backend.
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
tint::writer::spirv::Options options;
options.disable_workgroup_init =
GetDevice()->IsToggleEnabled(Toggle::DisableWorkgroupInit);
options.disable_workgroup_init = GetDevice()->IsToggleEnabled(Toggle::DisableWorkgroupInit);
auto result = tint::writer::spirv::Generate(GetTintProgram(), options);
if (!result.success) {
std::ostringstream errorStream;
@ -94,9 +92,7 @@ namespace dawn_native { namespace opengl {
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
DAWN_TRY_ASSIGN(mGLEntryPoints,
ReflectShaderUsingSPIRVCross(GetDevice(), result.spirv));
}
DAWN_TRY_ASSIGN(mGLEntryPoints, ReflectShaderUsingSPIRVCross(GetDevice(), result.spirv));
return {};
}
@ -126,7 +122,6 @@ namespace dawn_native { namespace opengl {
options.version = version.GetMajor() * 100 + version.GetMinor() * 10;
std::vector<uint32_t> spirv;
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
tint::transform::SingleEntryPoint singleEntryPointTransform;
tint::transform::DataMap transformInputs;
@ -136,10 +131,10 @@ namespace dawn_native { namespace opengl {
DAWN_TRY_ASSIGN(program, RunTransforms(&singleEntryPointTransform, GetTintProgram(),
transformInputs, nullptr, nullptr));
tint::writer::spirv::Options options;
options.disable_workgroup_init =
tint::writer::spirv::Options tintOptions;
tintOptions.disable_workgroup_init =
GetDevice()->IsToggleEnabled(Toggle::DisableWorkgroupInit);
auto result = tint::writer::spirv::Generate(&program, options);
auto result = tint::writer::spirv::Generate(&program, tintOptions);
if (!result.success) {
std::ostringstream errorStream;
errorStream << "Generator: " << result.error << std::endl;
@ -147,9 +142,6 @@ namespace dawn_native { namespace opengl {
}
spirv = std::move(result.spirv);
} else {
spirv = GetSpirv();
}
if (GetDevice()->IsToggleEnabled(Toggle::DumpShaders)) {
spvtools::SpirvTools spirvTools(SPV_ENV_VULKAN_1_1);
@ -204,9 +196,7 @@ namespace dawn_native { namespace opengl {
}
const EntryPointMetadata::BindingInfoArray& bindingInfo =
GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)
? (*mGLEntryPoints.at(entryPointName)).bindings
: GetEntryPoint(entryPointName).bindings;
(*mGLEntryPoints.at(entryPointName)).bindings;
// Change binding names to be "dawn_binding_<group>_<binding>".
// Also unsets the SPIRV "Binding" decoration as it outputs "layout(binding=)" which

View File

@ -91,16 +91,12 @@ namespace dawn_native { namespace vulkan {
ityp::vector<BindingIndex, VkDescriptorSetLayoutBinding> bindings;
bindings.reserve(GetBindingCount());
bool useBindingIndex = GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator);
for (const auto& it : GetBindingMap()) {
BindingNumber bindingNumber = it.first;
BindingIndex bindingIndex = it.second;
const BindingInfo& bindingInfo = GetBindingInfo(bindingIndex);
VkDescriptorSetLayoutBinding vkBinding;
vkBinding.binding = useBindingIndex ? static_cast<uint32_t>(bindingIndex)
: static_cast<uint32_t>(bindingNumber);
vkBinding.binding = static_cast<uint32_t>(bindingIndex);
// TODO(dawn:728) In the future, special handling will be needed for external textures
// here because they encompass multiple views.
vkBinding.descriptorType = VulkanDescriptorType(bindingInfo);

View File

@ -43,10 +43,6 @@ namespace dawn_native { namespace vulkan {
// the pools are reused when no longer used. Minimizing the number of descriptor pool allocation
// is important because creating them can incur GPU memory allocation which is usually an
// expensive syscall.
//
// The Vulkan BindGroupLayout is dependent on UseTintGenerator or not.
// When UseTintGenerator is on, VkDescriptorSetLayoutBinding::binding is set to BindingIndex,
// otherwise it is set to BindingNumber.
class BindGroupLayout final : public BindGroupLayoutBase {
public:
static ResultOrError<Ref<BindGroupLayout>> Create(

View File

@ -48,11 +48,8 @@ namespace dawn_native { namespace vulkan {
ityp::stack_vec<uint32_t, VkDescriptorImageInfo, kMaxOptimalBindingsPerGroup>
writeImageInfo(bindingCount);
bool useBindingIndex = device->IsToggleEnabled(Toggle::UseTintGenerator);
uint32_t numWrites = 0;
for (const auto& it : GetLayout()->GetBindingMap()) {
BindingNumber bindingNumber = it.first;
BindingIndex bindingIndex = it.second;
const BindingInfo& bindingInfo = GetLayout()->GetBindingInfo(bindingIndex);
@ -60,8 +57,7 @@ namespace dawn_native { namespace vulkan {
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
write.pNext = nullptr;
write.dstSet = GetHandle();
write.dstBinding = useBindingIndex ? static_cast<uint32_t>(bindingIndex)
: static_cast<uint32_t>(bindingNumber);
write.dstBinding = static_cast<uint32_t>(bindingIndex);
write.dstArrayElement = 0;
write.descriptorCount = 1;
write.descriptorType = VulkanDescriptorType(bindingInfo);

View File

@ -26,9 +26,6 @@ namespace dawn_native { namespace vulkan {
class Device;
// The Vulkan BindGroup is dependent on UseTintGenerator or not.
// When UseTintGenerator is on, VkWriteDescriptorSet::dstBinding is set to BindingIndex,
// otherwise it is set to BindingNumber.
class BindGroup final : public BindGroupBase, public PlacementAllocated {
public:
static ResultOrError<Ref<BindGroup>> Create(Device* device,

View File

@ -46,15 +46,11 @@ namespace dawn_native { namespace vulkan {
createInfo.stage.pNext = nullptr;
createInfo.stage.flags = 0;
createInfo.stage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
// Generate a new VkShaderModule with BindingRemapper tint transform for each pipeline
DAWN_TRY_ASSIGN(createInfo.stage.module,
ToBackend(descriptor->compute.module)
->GetTransformedModuleHandle(descriptor->compute.entryPoint,
ToBackend(GetLayout())));
} else {
createInfo.stage.module = ToBackend(descriptor->compute.module)->GetHandle();
}
createInfo.stage.pName = descriptor->compute.entryPoint;
createInfo.stage.pSpecializationInfo = nullptr;

View File

@ -341,7 +341,6 @@ namespace dawn_native { namespace vulkan {
VkPipelineShaderStageCreateInfo shaderStages[2];
{
if (device->IsToggleEnabled(Toggle::UseTintGenerator)) {
// Generate a new VkShaderModule with BindingRemapper tint transform for each
// pipeline
DAWN_TRY_ASSIGN(shaderStages[0].module,
@ -352,11 +351,6 @@ namespace dawn_native { namespace vulkan {
ToBackend(descriptor->fragment->module)
->GetTransformedModuleHandle(descriptor->fragment->entryPoint,
ToBackend(GetLayout())));
} else {
shaderStages[0].module = ToBackend(descriptor->vertex.module)->GetHandle();
shaderStages[1].module = ToBackend(descriptor->fragment->module)->GetHandle();
}
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[0].pNext = nullptr;
shaderStages[0].flags = 0;

View File

@ -21,12 +21,6 @@
#include "dawn_native/vulkan/PipelineLayoutVk.h"
#include "dawn_native/vulkan/VulkanError.h"
#include <spirv_cross.hpp>
// Tint include must be after spirv_hlsl.hpp, because spirv-cross has its own
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
// is at 3 while spirv-headers is at 4.
#undef SPV_REVISION
#include <tint/tint.h>
namespace dawn_native { namespace vulkan {
@ -89,7 +83,6 @@ namespace dawn_native { namespace vulkan {
ScopedTintICEHandler scopedICEHandler(GetDevice());
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
std::ostringstream errorStream;
errorStream << "Tint SPIR-V writer failure:" << std::endl;
@ -101,14 +94,12 @@ namespace dawn_native { namespace vulkan {
tint::transform::DataMap transformInputs;
tint::Program program;
DAWN_TRY_ASSIGN(program,
RunTransforms(&transformManager, parseResult->tintProgram.get(),
DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, parseResult->tintProgram.get(),
transformInputs, nullptr, nullptr));
tint::writer::spirv::Options options;
options.emit_vertex_point_size = true;
options.disable_workgroup_init =
GetDevice()->IsToggleEnabled(Toggle::DisableWorkgroupInit);
options.disable_workgroup_init = GetDevice()->IsToggleEnabled(Toggle::DisableWorkgroupInit);
auto result = tint::writer::spirv::Generate(&program, options);
if (!result.success) {
errorStream << "Generator: " << result.error << std::endl;
@ -120,13 +111,8 @@ namespace dawn_native { namespace vulkan {
// Rather than use a new ParseResult object, we just reuse the original parseResult
parseResult->tintProgram = std::make_unique<tint::Program>(std::move(program));
parseResult->spirv = spirv;
DAWN_TRY(InitializeBase(parseResult));
} else {
DAWN_TRY(InitializeBase(parseResult));
spirvPtr = &GetSpirv();
}
VkShaderModuleCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
@ -151,18 +137,11 @@ namespace dawn_native { namespace vulkan {
}
}
VkShaderModule ShaderModule::GetHandle() const {
ASSERT(!GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator));
return mHandle;
}
ResultOrError<VkShaderModule> ShaderModule::GetTransformedModuleHandle(
const char* entryPointName,
PipelineLayout* layout) {
ScopedTintICEHandler scopedICEHandler(GetDevice());
ASSERT(GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator));
auto cacheKey = std::make_pair(layout, entryPointName);
VkShaderModule cachedShaderModule =
mTransformedShaderModuleCache.FindShaderModule(cacheKey);

View File

@ -33,9 +33,6 @@ namespace dawn_native { namespace vulkan {
const ShaderModuleDescriptor* descriptor,
ShaderModuleParseResult* parseResult);
VkShaderModule GetHandle() const;
// This is only called when UseTintGenerator is on
ResultOrError<VkShaderModule> GetTransformedModuleHandle(const char* entryPointName,
PipelineLayout* layout);