Init PointSize value when pipeline topology is PointList in end2end

When pipeline topology is set to Point_List, PointSize must be written
in vertex shader for Vulkan backend.

BUG=dawn:146

Change-Id: Id5aac73bb7e60646503f1ea06c2aa0d39c8384b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7820
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Li, Hao 2019-06-21 10:56:35 +00:00 committed by Commit Bot service account
parent a92f83b725
commit 4ec2c1060e
5 changed files with 25 additions and 2 deletions

View File

@ -42,6 +42,13 @@ namespace dawn_native { namespace d3d12 {
spirv_cross::CompilerHLSL::Options options_hlsl;
options_hlsl.shader_model = 51;
// PointCoord and PointSize are not supported in HLSL
// TODO (hao.x.li@intel.com): The point_coord_compat and point_size_compat are
// required temporarily for https://bugs.chromium.org/p/dawn/issues/detail?id=146,
// but should be removed once WebGPU requires there is no gl_PointSize builtin.
// See https://github.com/gpuweb/gpuweb/issues/332
options_hlsl.point_coord_compat = true;
options_hlsl.point_size_compat = true;
compiler.set_hlsl_options(options_hlsl);
const ModuleBindingInfo& moduleBindingInfo = GetBindingInfo();

View File

@ -58,6 +58,15 @@ namespace dawn_native { namespace metal {
options_glsl.vertex.flip_vert_y = true;
compiler.spirv_cross::CompilerGLSL::set_common_options(options_glsl);
// Disable PointSize builtin for https://bugs.chromium.org/p/dawn/issues/detail?id=146
// Becuase Metal will reject PointSize builtin if the shader is compiled into a render
// pipeline that uses a non-point topology.
// TODO (hao.x.li@intel.com): Remove this once WebGPU requires there is no
// gl_PointSize builtin (https://github.com/gpuweb/gpuweb/issues/332).
spirv_cross::CompilerMSL::Options options_msl;
options_msl.enable_point_size_builtin = false;
compiler.set_msl_options(options_msl);
// By default SPIRV-Cross will give MSL resources indices in increasing order.
// To make the MSL indices match the indices chosen in the PipelineLayout, we build
// a table of MSLResourceBinding to give to SPIRV-Cross.

View File

@ -34,6 +34,12 @@ namespace {
// Using the options that are used by Dawn, they appear in ShaderModuleD3D12.cpp
options.SetFlipVertY(true);
options.SetHLSLShaderModel(51);
// TODO (hao.x.li@intel.com): The HLSLPointCoordCompat and HLSLPointSizeCompat are
// required temporarily for https://bugs.chromium.org/p/dawn/issues/detail?id=146,
// but should be removed once WebGPU requires there is no gl_PointSize builtin.
// See https://github.com/gpuweb/gpuweb/issues/332
options.SetHLSLPointCoordCompat(true);
options.SetHLSLPointSizeCompat(true);
compiler.CompileSpvToHlsl(input.data(), input.size(), options);
});

View File

@ -155,8 +155,8 @@ class PrimitiveTopologyTest : public DawnTest {
layout(location = 0) in vec4 pos;
void main() {
gl_Position = pos;
})"
);
gl_PointSize = 1.0;
})");
fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450

View File

@ -27,6 +27,7 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) {
#version 450
void main() {
gl_Position = vec4(-0.5f, -0.5f, 0.0f, 1.0f);
gl_PointSize = 1.0;
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(