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:
parent
d90748b256
commit
0fa2feb96a
|
@ -18,7 +18,7 @@
|
||||||
url = https://github.com/KhronosGroup/SPIRV-Headers.git
|
url = https://github.com/KhronosGroup/SPIRV-Headers.git
|
||||||
[submodule "external/spirv-cross"]
|
[submodule "external/spirv-cross"]
|
||||||
path = third_party/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"]
|
[submodule "external/stb"]
|
||||||
path = third_party/stb
|
path = third_party/stb
|
||||||
url = https://github.com/nothings/stb.git
|
url = https://github.com/nothings/stb.git
|
||||||
|
|
2
DEPS
2
DEPS
|
@ -43,7 +43,7 @@ deps = {
|
||||||
|
|
||||||
# SPIRV-Cross
|
# SPIRV-Cross
|
||||||
'{dawn_root}/third_party/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',
|
'condition': 'dawn_standalone',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,9 @@ namespace dawn_native {
|
||||||
ASSERT(blockType.basetype == spirv_cross::SPIRType::Struct);
|
ASSERT(blockType.basetype == spirv_cross::SPIRType::Struct);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < blockType.member_types.size(); i++) {
|
for (uint32_t i = 0; i < blockType.member_types.size(); i++) {
|
||||||
ASSERT(compiler.get_member_decoration_mask(blockType.self, i) &
|
ASSERT(compiler.get_member_decoration_bitset(blockType.self, i)
|
||||||
1ull << spv::DecorationOffset);
|
.get(spv::DecorationOffset));
|
||||||
|
|
||||||
uint32_t offset =
|
uint32_t offset =
|
||||||
compiler.get_member_decoration(blockType.self, i, spv::DecorationOffset);
|
compiler.get_member_decoration(blockType.self, i, spv::DecorationOffset);
|
||||||
ASSERT(offset % 4 == 0);
|
ASSERT(offset % 4 == 0);
|
||||||
|
@ -114,12 +115,11 @@ namespace dawn_native {
|
||||||
auto ExtractResourcesBinding = [this](const std::vector<spirv_cross::Resource>& resources,
|
auto ExtractResourcesBinding = [this](const std::vector<spirv_cross::Resource>& resources,
|
||||||
const spirv_cross::Compiler& compiler,
|
const spirv_cross::Compiler& compiler,
|
||||||
dawn::BindingType bindingType) {
|
dawn::BindingType bindingType) {
|
||||||
constexpr uint64_t requiredBindingDecorationMask =
|
|
||||||
(1ull << spv::DecorationBinding) | (1ull << spv::DecorationDescriptorSet);
|
|
||||||
|
|
||||||
for (const auto& resource : resources) {
|
for (const auto& resource : resources) {
|
||||||
ASSERT((compiler.get_decoration_mask(resource.id) &
|
ASSERT(compiler.get_decoration_bitset(resource.id).get(spv::DecorationBinding));
|
||||||
requiredBindingDecorationMask) == requiredBindingDecorationMask);
|
ASSERT(
|
||||||
|
compiler.get_decoration_bitset(resource.id).get(spv::DecorationDescriptorSet));
|
||||||
|
|
||||||
uint32_t binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
|
uint32_t binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
|
||||||
uint32_t set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
|
uint32_t set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ namespace dawn_native {
|
||||||
// Extract the vertex attributes
|
// Extract the vertex attributes
|
||||||
if (mExecutionModel == dawn::ShaderStage::Vertex) {
|
if (mExecutionModel == dawn::ShaderStage::Vertex) {
|
||||||
for (const auto& attrib : resources.stage_inputs) {
|
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);
|
uint32_t location = compiler.get_decoration(attrib.id, spv::DecorationLocation);
|
||||||
|
|
||||||
if (location >= kMaxVertexAttributes) {
|
if (location >= kMaxVertexAttributes) {
|
||||||
|
@ -161,8 +161,7 @@ namespace dawn_native {
|
||||||
// Without a location qualifier on vertex outputs, spirv_cross::CompilerMSL gives them
|
// Without a location qualifier on vertex outputs, spirv_cross::CompilerMSL gives them
|
||||||
// all the location 0, causing a compile error.
|
// all the location 0, causing a compile error.
|
||||||
for (const auto& attrib : resources.stage_outputs) {
|
for (const auto& attrib : resources.stage_outputs) {
|
||||||
if (!(compiler.get_decoration_mask(attrib.id) &
|
if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) {
|
||||||
(1ull << spv::DecorationLocation))) {
|
|
||||||
mDevice->HandleError("Need location qualifier on vertex output");
|
mDevice->HandleError("Need location qualifier on vertex output");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +172,7 @@ namespace dawn_native {
|
||||||
// Without a location qualifier on vertex inputs, spirv_cross::CompilerMSL gives them
|
// Without a location qualifier on vertex inputs, spirv_cross::CompilerMSL gives them
|
||||||
// all the location 0, causing a compile error.
|
// all the location 0, causing a compile error.
|
||||||
for (const auto& attrib : resources.stage_inputs) {
|
for (const auto& attrib : resources.stage_inputs) {
|
||||||
if (!(compiler.get_decoration_mask(attrib.id) &
|
if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) {
|
||||||
(1ull << spv::DecorationLocation))) {
|
|
||||||
mDevice->HandleError("Need location qualifier on fragment input");
|
mDevice->HandleError("Need location qualifier on fragment input");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,11 @@ namespace dawn_native { namespace d3d12 {
|
||||||
spirv_cross::CompilerGLSL::Options options_glsl;
|
spirv_cross::CompilerGLSL::Options options_glsl;
|
||||||
options_glsl.vertex.fixup_clipspace = true;
|
options_glsl.vertex.fixup_clipspace = true;
|
||||||
options_glsl.vertex.flip_vert_y = 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;
|
spirv_cross::CompilerHLSL::Options options_hlsl;
|
||||||
options_hlsl.shader_model = 51;
|
options_hlsl.shader_model = 51;
|
||||||
compiler.spirv_cross::CompilerHLSL::set_options(options_hlsl);
|
compiler.set_hlsl_options(options_hlsl);
|
||||||
|
|
||||||
ExtractSpirvInfo(compiler);
|
ExtractSpirvInfo(compiler);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ namespace dawn_native { namespace metal {
|
||||||
const auto& module = ToBackend(builder->GetStageInfo(dawn::ShaderStage::Compute).module);
|
const auto& module = ToBackend(builder->GetStageInfo(dawn::ShaderStage::Compute).module);
|
||||||
const auto& entryPoint = builder->GetStageInfo(dawn::ShaderStage::Compute).entryPoint;
|
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;
|
NSError* error = nil;
|
||||||
mMtlComputePipelineState =
|
mMtlComputePipelineState =
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
const auto& entryPoint = builder->GetStageInfo(stage).entryPoint;
|
const auto& entryPoint = builder->GetStageInfo(stage).entryPoint;
|
||||||
ShaderModule::MetalFunctionData data =
|
ShaderModule::MetalFunctionData data =
|
||||||
module->GetFunction(entryPoint.c_str(), ToBackend(GetLayout()));
|
module->GetFunction(entryPoint.c_str(), stage, ToBackend(GetLayout()));
|
||||||
id<MTLFunction> function = data.function;
|
id<MTLFunction> function = data.function;
|
||||||
|
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
|
|
|
@ -39,7 +39,9 @@ namespace dawn_native { namespace metal {
|
||||||
[function release];
|
[function release];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
MetalFunctionData GetFunction(const char* functionName, const PipelineLayout* layout) const;
|
MetalFunctionData GetFunction(const char* functionName,
|
||||||
|
dawn::ShaderStage functionStage,
|
||||||
|
const PipelineLayout* layout) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Calling compile on CompilerMSL somehow changes internal state that makes subsequent
|
// Calling compile on CompilerMSL somehow changes internal state that makes subsequent
|
||||||
|
|
|
@ -48,12 +48,13 @@ namespace dawn_native { namespace metal {
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderModule::MetalFunctionData ShaderModule::GetFunction(const char* functionName,
|
ShaderModule::MetalFunctionData ShaderModule::GetFunction(const char* functionName,
|
||||||
|
dawn::ShaderStage functionStage,
|
||||||
const PipelineLayout* layout) const {
|
const PipelineLayout* layout) const {
|
||||||
spirv_cross::CompilerMSL compiler(mSpirv);
|
spirv_cross::CompilerMSL compiler(mSpirv);
|
||||||
|
|
||||||
spirv_cross::CompilerGLSL::Options options_glsl;
|
spirv_cross::CompilerGLSL::Options options_glsl;
|
||||||
options_glsl.vertex.flip_vert_y = true;
|
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.
|
// 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
|
// 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;
|
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);
|
result.localWorkgroupSize = MTLSizeMake(size.x, size.y, size.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace dawn_native { namespace opengl {
|
||||||
#else
|
#else
|
||||||
options.version = 440;
|
options.version = 440;
|
||||||
#endif
|
#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
|
// 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.
|
// names don't match between the FS and the VS.
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 694cad533296df02b4562f4a5a20cba1d1a9dbaf
|
Subproject commit a7697446b12666da353bb2bdafa792d988fb268c
|
Loading…
Reference in New Issue