mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
Add support for SPV_KHR_non_semantic_info (#8827)
* Upload * Added changelog entry * More comments * Updated changelog to reflect SUPPORTED_EXT_SETS being removed
This commit is contained in:
1 parent
c97fe3e7c4
commit
48ba9812c2
6 files changed
+101
-4
No files matched your search
@@ -49,6 +49,10 @@ Bottom level categories:
|
||||
- Added support for obtaining `AdapterInfo` from `Device`. By @sagudev in [#8807](https://github.com/gfx-rs/wgpu/pull/8807).
|
||||
- Added `Limits::or_worse_values_from`. By @atlv24 in [#8870](https://github.com/gfx-rs/wgpu/pull/8870).
|
||||
|
||||
#### Naga
|
||||
|
||||
- Allow parsing shaders which make use of `SPV_KHR_non_semantic_info` for debug info. Also removes `naga::front::spv::SUPPORTED_EXT_SETS`. By @inner-daemons in #8827.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
#### General
|
||||
|
||||
@@ -158,6 +158,18 @@ impl<I: Iterator<Item = u32>> super::Frontend<I> {
|
||||
fun_inst.expect(1)?;
|
||||
break;
|
||||
}
|
||||
spirv::Op::ExtInst => {
|
||||
let _ = self.next()?;
|
||||
let _ = self.next()?;
|
||||
let set_id = self.next()?;
|
||||
if Some(set_id) == self.ext_non_semantic_id {
|
||||
for _ in 0..fun_inst.wc - 4 {
|
||||
self.next()?;
|
||||
}
|
||||
} else {
|
||||
return Err(Error::UnsupportedInstruction(self.state, fun_inst.op));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
return Err(Error::UnsupportedInstruction(self.state, fun_inst.op));
|
||||
}
|
||||
|
||||
@@ -96,9 +96,9 @@ pub const SUPPORTED_EXTENSIONS: &[&str] = &[
|
||||
"SPV_EXT_descriptor_indexing",
|
||||
"SPV_EXT_shader_atomic_float_add",
|
||||
"SPV_KHR_16bit_storage",
|
||||
"SPV_KHR_non_semantic_info",
|
||||
"SPV_KHR_fragment_shader_barycentric",
|
||||
];
|
||||
pub const SUPPORTED_EXT_SETS: &[&str] = &["GLSL.std.450"];
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Instruction {
|
||||
@@ -589,6 +589,7 @@ pub struct Frontend<I> {
|
||||
layouter: Layouter,
|
||||
temp_bytes: Vec<u8>,
|
||||
ext_glsl_id: Option<spirv::Word>,
|
||||
ext_non_semantic_id: Option<spirv::Word>,
|
||||
future_decor: FastHashMap<spirv::Word, Decoration>,
|
||||
future_member_decor: FastHashMap<(spirv::Word, MemberIndex), Decoration>,
|
||||
lookup_member: FastHashMap<(Handle<crate::Type>, MemberIndex), LookupMember>,
|
||||
@@ -656,6 +657,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
|
||||
layouter: Layouter::default(),
|
||||
temp_bytes: Vec::new(),
|
||||
ext_glsl_id: None,
|
||||
ext_non_semantic_id: None,
|
||||
future_decor: FastHashMap::default(),
|
||||
future_member_decor: FastHashMap::default(),
|
||||
handle_sampling: FastHashMap::default(),
|
||||
@@ -1745,6 +1747,21 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
|
||||
inst.expect(5)?;
|
||||
self.parse_function(&mut module)
|
||||
}
|
||||
Op::ExtInst => {
|
||||
// Ignore the result type and result id
|
||||
let _ = self.next()?;
|
||||
let _ = self.next()?;
|
||||
let set_id = self.next()?;
|
||||
if Some(set_id) == self.ext_non_semantic_id {
|
||||
// We've already skipped the instruction byte, result type, result id, and instruction set id
|
||||
for _ in 0..inst.wc - 4 {
|
||||
self.next()?;
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
return Err(Error::UnsupportedInstruction(self.state, inst.op));
|
||||
}
|
||||
}
|
||||
_ => Err(Error::UnsupportedInstruction(self.state, inst.op)), //TODO
|
||||
}?;
|
||||
}
|
||||
@@ -1848,10 +1865,17 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
|
||||
if left != 0 {
|
||||
return Err(Error::InvalidOperand);
|
||||
}
|
||||
if !SUPPORTED_EXT_SETS.contains(&name.as_str()) {
|
||||
if &name == "GLSL.std.450" {
|
||||
self.ext_glsl_id = Some(result_id);
|
||||
} else if &name == "NonSemantic.Shader.DebugInfo.100" {
|
||||
// We completely ignore this extension. All related instructions are
|
||||
// non-semantic and only for debug purposes, and the spec says they
|
||||
// are ignorable. Many compilers (dxc, slang, etc) will emit these
|
||||
// instructions depending on configuration.
|
||||
self.ext_non_semantic_id = Some(result_id);
|
||||
} else {
|
||||
return Err(Error::UnsupportedExtSet(name));
|
||||
}
|
||||
self.ext_glsl_id = Some(result_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1693,7 +1693,12 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
|
||||
let result_type_id = self.next()?;
|
||||
let result_id = self.next()?;
|
||||
let set_id = self.next()?;
|
||||
if Some(set_id) != self.ext_glsl_id {
|
||||
if Some(set_id) == self.ext_non_semantic_id {
|
||||
for _ in 0..inst.wc - 4 {
|
||||
self.next()?;
|
||||
}
|
||||
continue;
|
||||
} else if Some(set_id) != self.ext_glsl_id {
|
||||
return Err(Error::UnsupportedExtInstSet(set_id));
|
||||
}
|
||||
let inst_id = self.next()?;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Google spiregg; 0
|
||||
; Bound: 28
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpExtension "SPV_KHR_non_semantic_info"
|
||||
%1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
%3 = OpString "thing.hlsl"
|
||||
%4 = OpString "[numthreads(1, 1, 1)]
|
||||
void main()
|
||||
{
|
||||
}
|
||||
"
|
||||
%5 = OpString "main"
|
||||
%6 = OpString ""
|
||||
%7 = OpString "__dxc_setup"
|
||||
%8 = OpString "3f85295c"
|
||||
%9 = OpString " -E main -T cs_6_0 -spirv -fspv-debug=vulkan-with-source -Fo out.spirv -Qembed_debug"
|
||||
OpName %main "main"
|
||||
%void = OpTypeVoid
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%uint_5 = OpConstant %uint 5
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%22 = OpTypeFunction %void
|
||||
%11 = OpExtInst %void %1 DebugTypeFunction %uint_3 %void
|
||||
%13 = OpExtInst %void %1 DebugSource %3 %4
|
||||
%14 = OpExtInst %void %1 DebugCompilationUnit %uint_1 %uint_4 %13 %uint_5
|
||||
%18 = OpExtInst %void %1 DebugFunction %7 %11 %13 %uint_2 %uint_1 %14 %6 %uint_3 %uint_3
|
||||
%20 = OpExtInst %void %1 DebugEntryPoint %18 %14 %8 %9
|
||||
%main = OpFunction %void None %22
|
||||
%23 = OpLabel
|
||||
%26 = OpExtInst %void %1 DebugScope %18
|
||||
%24 = OpExtInst %void %1 DebugFunctionDefinition %18 %main
|
||||
%25 = OpExtInst %void %1 DebugLine %13 %uint_4 %uint_4 %uint_1 %uint_1
|
||||
OpReturn
|
||||
%27 = OpExtInst %void %1 DebugNoScope
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,8 @@
|
||||
fn main_1() {
|
||||
return;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1, 1, 1)
|
||||
fn main() {
|
||||
main_1();
|
||||
}
|
||||
Reference in new issue
Block a user