Roll SPIRV-Cross and use upstream repo.

In the DEPS file we are going to use Chromium's mirror of
github.com/KhronosGroup/SPIRV-Cross so we need to adjust .gitmodules to
point to it instead of Kangz/SPIRV-Cross. Also take that opportunity to
roll SPIRV-Cross.

Change-Id: I4f53a4fc54f5b1b9a754ac55e976c81e5eeabeb2
This commit is contained in:
Corentin Wallez 2018-08-24 14:51:21 +02:00 committed by Corentin Wallez
parent d90748b256
commit 0fa2feb96a
10 changed files with 26 additions and 23 deletions

2
.gitmodules vendored
View File

@ -18,7 +18,7 @@
url = https://github.com/KhronosGroup/SPIRV-Headers.git
[submodule "external/spirv-cross"]
path = third_party/spirv-cross
url = https://github.com/Kangz/SPIRV-Cross.git
url = https://github.com/KhronosGroup/SPIRV-Cross.git
[submodule "external/stb"]
path = third_party/stb
url = https://github.com/nothings/stb.git

2
DEPS
View File

@ -43,7 +43,7 @@ deps = {
# SPIRV-Cross
'{dawn_root}/third_party/spirv-cross': {
'url': '{github_git}/Kangz/SPIRV-Cross.git@694cad533296df02b4562f4a5a20cba1d1a9dbaf',
'url': '{github_git}/KhronosGroup/SPIRV-Cross.git@a7697446b12666da353bb2bdafa792d988fb268c',
'condition': 'dawn_standalone',
},

View File

@ -71,8 +71,9 @@ namespace dawn_native {
ASSERT(blockType.basetype == spirv_cross::SPIRType::Struct);
for (uint32_t i = 0; i < blockType.member_types.size(); i++) {
ASSERT(compiler.get_member_decoration_mask(blockType.self, i) &
1ull << spv::DecorationOffset);
ASSERT(compiler.get_member_decoration_bitset(blockType.self, i)
.get(spv::DecorationOffset));
uint32_t offset =
compiler.get_member_decoration(blockType.self, i, spv::DecorationOffset);
ASSERT(offset % 4 == 0);
@ -114,12 +115,11 @@ namespace dawn_native {
auto ExtractResourcesBinding = [this](const std::vector<spirv_cross::Resource>& resources,
const spirv_cross::Compiler& compiler,
dawn::BindingType bindingType) {
constexpr uint64_t requiredBindingDecorationMask =
(1ull << spv::DecorationBinding) | (1ull << spv::DecorationDescriptorSet);
for (const auto& resource : resources) {
ASSERT((compiler.get_decoration_mask(resource.id) &
requiredBindingDecorationMask) == requiredBindingDecorationMask);
ASSERT(compiler.get_decoration_bitset(resource.id).get(spv::DecorationBinding));
ASSERT(
compiler.get_decoration_bitset(resource.id).get(spv::DecorationDescriptorSet));
uint32_t binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
uint32_t set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
@ -147,7 +147,7 @@ namespace dawn_native {
// Extract the vertex attributes
if (mExecutionModel == dawn::ShaderStage::Vertex) {
for (const auto& attrib : resources.stage_inputs) {
ASSERT(compiler.get_decoration_mask(attrib.id) & (1ull << spv::DecorationLocation));
ASSERT(compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation));
uint32_t location = compiler.get_decoration(attrib.id, spv::DecorationLocation);
if (location >= kMaxVertexAttributes) {
@ -161,8 +161,7 @@ namespace dawn_native {
// Without a location qualifier on vertex outputs, spirv_cross::CompilerMSL gives them
// all the location 0, causing a compile error.
for (const auto& attrib : resources.stage_outputs) {
if (!(compiler.get_decoration_mask(attrib.id) &
(1ull << spv::DecorationLocation))) {
if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) {
mDevice->HandleError("Need location qualifier on vertex output");
return;
}
@ -173,8 +172,7 @@ namespace dawn_native {
// Without a location qualifier on vertex inputs, spirv_cross::CompilerMSL gives them
// all the location 0, causing a compile error.
for (const auto& attrib : resources.stage_inputs) {
if (!(compiler.get_decoration_mask(attrib.id) &
(1ull << spv::DecorationLocation))) {
if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) {
mDevice->HandleError("Need location qualifier on fragment input");
return;
}

View File

@ -52,11 +52,11 @@ namespace dawn_native { namespace d3d12 {
spirv_cross::CompilerGLSL::Options options_glsl;
options_glsl.vertex.fixup_clipspace = true;
options_glsl.vertex.flip_vert_y = true;
compiler.spirv_cross::CompilerGLSL::set_options(options_glsl);
compiler.set_common_options(options_glsl);
spirv_cross::CompilerHLSL::Options options_hlsl;
options_hlsl.shader_model = 51;
compiler.spirv_cross::CompilerHLSL::set_options(options_hlsl);
compiler.set_hlsl_options(options_hlsl);
ExtractSpirvInfo(compiler);

View File

@ -26,7 +26,8 @@ namespace dawn_native { namespace metal {
const auto& module = ToBackend(builder->GetStageInfo(dawn::ShaderStage::Compute).module);
const auto& entryPoint = builder->GetStageInfo(dawn::ShaderStage::Compute).entryPoint;
auto compilationData = module->GetFunction(entryPoint.c_str(), ToBackend(GetLayout()));
auto compilationData = module->GetFunction(entryPoint.c_str(), dawn::ShaderStage::Compute,
ToBackend(GetLayout()));
NSError* error = nil;
mMtlComputePipelineState =

View File

@ -77,7 +77,7 @@ namespace dawn_native { namespace metal {
const auto& entryPoint = builder->GetStageInfo(stage).entryPoint;
ShaderModule::MetalFunctionData data =
module->GetFunction(entryPoint.c_str(), ToBackend(GetLayout()));
module->GetFunction(entryPoint.c_str(), stage, ToBackend(GetLayout()));
id<MTLFunction> function = data.function;
switch (stage) {

View File

@ -39,7 +39,9 @@ namespace dawn_native { namespace metal {
[function release];
}
};
MetalFunctionData GetFunction(const char* functionName, const PipelineLayout* layout) const;
MetalFunctionData GetFunction(const char* functionName,
dawn::ShaderStage functionStage,
const PipelineLayout* layout) const;
private:
// Calling compile on CompilerMSL somehow changes internal state that makes subsequent

View File

@ -48,12 +48,13 @@ namespace dawn_native { namespace metal {
}
ShaderModule::MetalFunctionData ShaderModule::GetFunction(const char* functionName,
dawn::ShaderStage functionStage,
const PipelineLayout* layout) const {
spirv_cross::CompilerMSL compiler(mSpirv);
spirv_cross::CompilerGLSL::Options options_glsl;
options_glsl.vertex.flip_vert_y = true;
compiler.spirv_cross::CompilerGLSL::set_options(options_glsl);
compiler.spirv_cross::CompilerGLSL::set_common_options(options_glsl);
// 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
@ -92,7 +93,8 @@ namespace dawn_native { namespace metal {
MetalFunctionData result;
{
auto size = compiler.get_entry_point(functionName).workgroup_size;
spv::ExecutionModel executionModel = SpirvExecutionModelForStage(functionStage);
auto size = compiler.get_entry_point(functionName, executionModel).workgroup_size;
result.localWorkgroupSize = MTLSizeMake(size.x, size.y, size.z);
}

View File

@ -58,7 +58,7 @@ namespace dawn_native { namespace opengl {
#else
options.version = 440;
#endif
compiler.set_options(options);
compiler.set_common_options(options);
// Rename the push constant block to be prefixed with the shader stage type so that uniform
// names don't match between the FS and the VS.

@ -1 +1 @@
Subproject commit 694cad533296df02b4562f4a5a20cba1d1a9dbaf
Subproject commit a7697446b12666da353bb2bdafa792d988fb268c