mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-01 02:43:29 +00:00
Use correct Initialize call to spvc for Metal backend
BUG=dawn:292 Change-Id: I91d315d2f071cb8a25acb0d5379944ac8049deea Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14340 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
f15fc26d5b
commit
652fd5a416
@ -38,6 +38,25 @@ namespace dawn_native { namespace metal {
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shaderc_spvc::CompileOptions GetMSLCompileOptions() {
|
||||||
|
// If these options are changed, the values in DawnSPIRVCrossGLSLFastFuzzer.cpp need to
|
||||||
|
// be updated.
|
||||||
|
shaderc_spvc::CompileOptions options;
|
||||||
|
|
||||||
|
// Disable PointSize builtin for https://bugs.chromium.org/p/dawn/issues/detail?id=146
|
||||||
|
// Because 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).
|
||||||
|
options.SetMSLEnablePointSizeBuiltIn(false);
|
||||||
|
|
||||||
|
// Always use vertex buffer 30 (the last one in the vertex buffer table) to contain
|
||||||
|
// the shader storage buffer lengths.
|
||||||
|
options.SetMSLBufferSizeBufferIndex(kBufferLengthBufferSlot);
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -57,9 +76,8 @@ namespace dawn_native { namespace metal {
|
|||||||
MaybeError ShaderModule::Initialize(const ShaderModuleDescriptor* descriptor) {
|
MaybeError ShaderModule::Initialize(const ShaderModuleDescriptor* descriptor) {
|
||||||
mSpirv.assign(descriptor->code, descriptor->code + descriptor->codeSize);
|
mSpirv.assign(descriptor->code, descriptor->code + descriptor->codeSize);
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
|
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
|
||||||
shaderc_spvc::CompileOptions options;
|
shaderc_spvc_status status = mSpvcContext.InitializeForMsl(
|
||||||
shaderc_spvc_status status =
|
descriptor->code, descriptor->codeSize, GetMSLCompileOptions());
|
||||||
mSpvcContext.InitializeForGlsl(descriptor->code, descriptor->codeSize, options);
|
|
||||||
if (status != shaderc_spvc_status_success) {
|
if (status != shaderc_spvc_status_success) {
|
||||||
return DAWN_VALIDATION_ERROR("Unable to initialize instance of spvc");
|
return DAWN_VALIDATION_ERROR("Unable to initialize instance of spvc");
|
||||||
}
|
}
|
||||||
@ -80,21 +98,9 @@ namespace dawn_native { namespace metal {
|
|||||||
std::unique_ptr<spirv_cross::CompilerMSL> compiler_impl;
|
std::unique_ptr<spirv_cross::CompilerMSL> compiler_impl;
|
||||||
spirv_cross::CompilerMSL* compiler;
|
spirv_cross::CompilerMSL* compiler;
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
|
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
|
||||||
// If these options are changed, the values in DawnSPIRVCrossGLSLFastFuzzer.cpp need to
|
// Initializing the compiler is needed every call, because this method uses reflection
|
||||||
// be updated.
|
// to mutate the compiler's IR.
|
||||||
shaderc_spvc::CompileOptions options;
|
mSpvcContext.InitializeForMsl(mSpirv.data(), mSpirv.size(), GetMSLCompileOptions());
|
||||||
|
|
||||||
// Disable PointSize builtin for https://bugs.chromium.org/p/dawn/issues/detail?id=146
|
|
||||||
// Because 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).
|
|
||||||
options.SetMSLEnablePointSizeBuiltIn(false);
|
|
||||||
|
|
||||||
// Always use vertex buffer 30 (the last one in the vertex buffer table) to contain
|
|
||||||
// the shader storage buffer lengths.
|
|
||||||
options.SetMSLBufferSizeBufferIndex(kBufferLengthBufferSlot);
|
|
||||||
mSpvcContext.InitializeForMsl(mSpirv.data(), mSpirv.size(), options);
|
|
||||||
// TODO(rharrison): Handle initialize failing
|
// TODO(rharrison): Handle initialize failing
|
||||||
|
|
||||||
compiler = reinterpret_cast<spirv_cross::CompilerMSL*>(mSpvcContext.GetCompiler());
|
compiler = reinterpret_cast<spirv_cross::CompilerMSL*>(mSpvcContext.GetCompiler());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user