dawn_native/vulkan: Use EmitVertexPointSize transform

Fixes validation errors when drawing with point topologies, and without explicitly writing to the PointSize builtin.

Fixed: tint:321
Change-Id: I3c00c5ee56966a82d9e3024cb277eae8921a9af2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35800
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Ben Clayton 2020-12-22 18:10:58 +00:00 committed by Commit Bot service account
parent 03d0309255
commit 58ce2745cd
4 changed files with 20 additions and 1 deletions

View File

@ -837,12 +837,28 @@ namespace dawn_native {
} else { } else {
tint::ast::Module module; tint::ast::Module module;
DAWN_TRY_ASSIGN(module, ParseWGSL(wgslDesc->source)); DAWN_TRY_ASSIGN(module, ParseWGSL(wgslDesc->source));
{
tint::transform::Manager transformManager;
transformManager.append(
std::make_unique<tint::transform::EmitVertexPointSize>());
DAWN_TRY_ASSIGN(module, RunTransforms(&transformManager, &module));
}
if (device->IsValidationEnabled()) { if (device->IsValidationEnabled()) {
DAWN_TRY(ValidateModule(&module)); DAWN_TRY(ValidateModule(&module));
} }
// Keep the Tint module around. The Metal backend will use it for vertex
// pulling since we can't go WGSL->point size transform->spirv->Tint.
// Tint's spirv reader doesn't understand point size. crbug.com/tint/412.
auto tintModule = std::make_unique<tint::ast::Module>(module.Clone());
std::vector<uint32_t> spirv; std::vector<uint32_t> spirv;
DAWN_TRY_ASSIGN(spirv, ModuleToSPIRV(std::move(module))); DAWN_TRY_ASSIGN(spirv, ModuleToSPIRV(std::move(module)));
DAWN_TRY(ValidateSpirv(spirv.data(), spirv.size())); DAWN_TRY(ValidateSpirv(spirv.data(), spirv.size()));
parseResult.tintModule = std::move(tintModule);
parseResult.spirv = std::move(spirv); parseResult.spirv = std::move(spirv);
} }
break; break;
@ -1026,6 +1042,7 @@ namespace dawn_native {
tint::transform::Manager transformManager; tint::transform::Manager transformManager;
transformManager.append( transformManager.append(
MakeVertexPullingTransform(vertexState, entryPoint, pullingBufferBindingSet)); MakeVertexPullingTransform(vertexState, entryPoint, pullingBufferBindingSet));
transformManager.append(std::make_unique<tint::transform::EmitVertexPointSize>());
if (GetDevice()->IsRobustnessEnabled()) { if (GetDevice()->IsRobustnessEnabled()) {
// TODO(enga): Run the Tint BoundArrayAccessors transform instead of the SPIRV Tools // TODO(enga): Run the Tint BoundArrayAccessors transform instead of the SPIRV Tools
// one, but it appears to crash after running VertexPulling. // one, but it appears to crash after running VertexPulling.

View File

@ -123,7 +123,7 @@ namespace dawn_native { namespace metal {
std::vector<uint32_t> pullingSpirv; std::vector<uint32_t> pullingSpirv;
if (GetDevice()->IsToggleEnabled(Toggle::MetalEnableVertexPulling) && if (GetDevice()->IsToggleEnabled(Toggle::MetalEnableVertexPulling) &&
stage == SingleShaderStage::Vertex) { stage == SingleShaderStage::Vertex) {
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) { if (mTintModule) {
DAWN_TRY_ASSIGN(pullingSpirv, DAWN_TRY_ASSIGN(pullingSpirv,
GeneratePullingSpirv(mTintModule.get(), GeneratePullingSpirv(mTintModule.get(),
*renderPipeline->GetVertexStateDescriptor(), *renderPipeline->GetVertexStateDescriptor(),

View File

@ -89,6 +89,7 @@ namespace dawn_native { namespace opengl {
tint::transform::Manager transformManager; tint::transform::Manager transformManager;
transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>()); transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>());
transformManager.append(std::make_unique<tint::transform::EmitVertexPointSize>());
DAWN_TRY_ASSIGN(module, RunTransforms(&transformManager, &module)); DAWN_TRY_ASSIGN(module, RunTransforms(&transformManager, &module));

View File

@ -60,6 +60,7 @@ namespace dawn_native { namespace vulkan {
tint::transform::Manager transformManager; tint::transform::Manager transformManager;
transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>()); transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>());
transformManager.append(std::make_unique<tint::transform::EmitVertexPointSize>());
DAWN_TRY_ASSIGN(module, RunTransforms(&transformManager, &module)); DAWN_TRY_ASSIGN(module, RunTransforms(&transformManager, &module));