Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regenerate with SPIRV-Headers sdk-1.2.198 #226

Merged
merged 4 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 36 additions & 28 deletions autogen/src/dr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,13 @@ pub fn gen_dr_operand_kinds(grammar: &[structs::OperandKind]) -> TokenStream {
// LiteralInteger is replaced by LiteralInt32.
// IdResult and IdResultType are not stored as operands in `dr`.
!(element.starts_with("Pair")
|| *element == "LiteralContextDependentNumber"
|| *element == "LiteralInteger"
|| *element == "IdResult"
|| *element == "IdResultType")
|| matches!(
*element,
"LiteralContextDependentNumber"
| "LiteralInteger"
| "IdResult"
| "IdResultType"
))
})
.map(as_ident)
.collect();
Expand Down Expand Up @@ -654,17 +657,19 @@ pub fn gen_dr_builder_types(grammar: &structs::Grammar) -> TokenStream {
let kinds = &grammar.operand_kinds;
// Generate build methods for all types.
let elements = grammar.instructions.iter().filter(|inst| {
inst.class == Some(structs::Class::Type) && inst.opname != "OpTypeForwardPointer" &&
inst.opname != "OpTypePointer" && inst.opname != "OpTypeOpaque"
inst.class == Some(structs::Class::Type)
&& !matches!(
inst.opname.as_str(),
"OpTypeForwardPointer" | "OpTypePointer" | "OpTypeOpaque"
)
}).map(|inst| {
// Parameter list for this build method.
let param_list = get_param_list(&inst.operands, false, kinds);
let arg_list = get_arg_list(&inst.operands, false, kinds);
// Initializer list for constructing the operands parameter
// for Instruction.
let init_list = get_init_list(&inst.operands[1..]);
// Parameters that are not single values thus need special treatment.
let extras = get_push_extras(&inst.operands[1..],
let init_list = get_init_list(&inst.operands);
let extras = get_push_extras(&inst.operands,
kinds,
quote! { inst.operands });
let opcode = as_ident(&inst.opname[2..]);
Expand Down Expand Up @@ -771,24 +776,22 @@ pub fn gen_dr_builder_normal_insts(grammar: &structs::Grammar) -> TokenStream {
// Generate build methods for all normal instructions (instructions must be
// in some block).
let elements = grammar.instructions.iter().filter(|inst| {
let skip =
inst.class == Some(Type) ||
inst.class == Some(Constant) ||
inst.class == Some(ExtensionDecl) ||
(inst.class == Some(FunctionStruct) && inst.opname != "OpFunctionCall") ||
inst.class == Some(Debug) ||
inst.class == Some(Annotation) ||
is_terminator_instruction(inst) ||
let skip = matches!(
inst.class,
Some(Type | Constant | ExtensionDecl | Debug | Annotation | ModeSetting | Exclude)
) || matches!(
inst.opname.as_str(),
// Labels should not be inserted but attached instead.
inst.opname == "OpLabel" ||
inst.class == Some(ModeSetting) ||
inst.class == Some(Exclude) ||
inst.opname == "OpTypeForwardPointer" ||
inst.opname == "OpTypePointer" ||
inst.opname == "OpTypeOpaque" ||
inst.opname == "OpUndef" ||
inst.opname == "OpVariable" ||
inst.opname.starts_with("OpType");
"OpLabel"
| "OpTypeForwardPointer"
| "OpTypePointer"
| "OpTypeOpaque"
| "OpUndef"
| "OpVariable"
| "OpSamplerImageAddressingModeNV" // https://github.com/gfx-rs/rspirv/pull/226#issuecomment-979469790
) || (inst.class == Some(FunctionStruct) && inst.opname != "OpFunctionCall")
|| is_terminator_instruction(inst)
|| inst.opname.starts_with("OpType");
!skip
}).map(|inst| {
let params = get_param_list(&inst.operands, true, kinds);
Expand Down Expand Up @@ -866,8 +869,13 @@ pub fn gen_dr_builder_constants(grammar: &structs::Grammar) -> TokenStream {
.iter()
.filter(|inst| {
inst.class == Some(structs::Class::Constant)
&& inst.opname != "OpConstant"
&& inst.opname != "OpSpecConstant"
&& !matches!(
inst.opname.as_str(),
"OpConstant"
| "OpSpecConstant"
| "OpConstantCompositeContinuedINTEL"
| "OpSpecConstantCompositeContinuedINTEL"
)
})
.map(|inst| {
let params = get_param_list(&inst.operands, false, kinds);
Expand Down
2 changes: 1 addition & 1 deletion rspirv/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rspirv"
version = "0.11.0+1.5.4"
version = "0.11.0+sdk-1.2.198"
authors = ["Lei Zhang <antiagainst@gmail.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion rspirv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ First add to your `Cargo.toml`:

```toml
[dependencies]
rspirv = "0.11.0+1.5.4"
rspirv = "0.11.0+sdk-1.2.198"
```

Examples
Expand Down
95 changes: 50 additions & 45 deletions rspirv/binary/assemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,53 +39,58 @@ fn assemble_str(s: &str, result: &mut Vec<u32>) {
impl Assemble for dr::Operand {
fn assemble_into(&self, result: &mut Vec<u32>) {
match *self {
dr::Operand::ImageOperands(v) => result.push(v.bits()),
dr::Operand::FPFastMathMode(v) => result.push(v.bits()),
dr::Operand::SelectionControl(v) => result.push(v.bits()),
dr::Operand::LoopControl(v) => result.push(v.bits()),
dr::Operand::FunctionControl(v) => result.push(v.bits()),
dr::Operand::MemorySemantics(v) => result.push(v.bits()),
dr::Operand::MemoryAccess(v) => result.push(v.bits()),
dr::Operand::KernelProfilingInfo(v) => result.push(v.bits()),
dr::Operand::SourceLanguage(v) => result.push(v as u32),
dr::Operand::ExecutionModel(v) => result.push(v as u32),
dr::Operand::AddressingModel(v) => result.push(v as u32),
dr::Operand::MemoryModel(v) => result.push(v as u32),
dr::Operand::ExecutionMode(v) => result.push(v as u32),
dr::Operand::StorageClass(v) => result.push(v as u32),
dr::Operand::Dim(v) => result.push(v as u32),
dr::Operand::SamplerAddressingMode(v) => result.push(v as u32),
dr::Operand::SamplerFilterMode(v) => result.push(v as u32),
dr::Operand::ImageFormat(v) => result.push(v as u32),
dr::Operand::ImageChannelOrder(v) => result.push(v as u32),
dr::Operand::ImageChannelDataType(v) => result.push(v as u32),
dr::Operand::FPRoundingMode(v) => result.push(v as u32),
dr::Operand::LinkageType(v) => result.push(v as u32),
dr::Operand::AccessQualifier(v) => result.push(v as u32),
dr::Operand::FunctionParameterAttribute(v) => result.push(v as u32),
dr::Operand::Decoration(v) => result.push(v as u32),
dr::Operand::BuiltIn(v) => result.push(v as u32),
dr::Operand::Scope(v) => result.push(v as u32),
dr::Operand::GroupOperation(v) => result.push(v as u32),
dr::Operand::KernelEnqueueFlags(v) => result.push(v as u32),
dr::Operand::Capability(v) => result.push(v as u32),
dr::Operand::IdMemorySemantics(v)
| dr::Operand::IdScope(v)
| dr::Operand::IdRef(v)
| dr::Operand::LiteralInt32(v)
| dr::Operand::LiteralExtInstInteger(v) => result.push(v),
dr::Operand::LiteralInt64(v) => result.extend(&[v as u32, (v >> 32) as u32]),
dr::Operand::LiteralFloat32(v) => result.push(v.to_bits()),
dr::Operand::LiteralFloat64(v) => {
Self::ImageOperands(v) => result.push(v.bits()),
Self::FPFastMathMode(v) => result.push(v.bits()),
Self::SelectionControl(v) => result.push(v.bits()),
Self::LoopControl(v) => result.push(v.bits()),
Self::FunctionControl(v) => result.push(v.bits()),
Self::MemorySemantics(v) => result.push(v.bits()),
Self::MemoryAccess(v) => result.push(v.bits()),
Self::KernelProfilingInfo(v) => result.push(v.bits()),
Self::SourceLanguage(v) => result.push(v as u32),
Self::ExecutionModel(v) => result.push(v as u32),
Self::AddressingModel(v) => result.push(v as u32),
Self::MemoryModel(v) => result.push(v as u32),
Self::ExecutionMode(v) => result.push(v as u32),
Self::StorageClass(v) => result.push(v as u32),
Self::Dim(v) => result.push(v as u32),
Self::SamplerAddressingMode(v) => result.push(v as u32),
Self::SamplerFilterMode(v) => result.push(v as u32),
Self::ImageFormat(v) => result.push(v as u32),
Self::ImageChannelOrder(v) => result.push(v as u32),
Self::ImageChannelDataType(v) => result.push(v as u32),
Self::FPRoundingMode(v) => result.push(v as u32),
Self::LinkageType(v) => result.push(v as u32),
Self::AccessQualifier(v) => result.push(v as u32),
Self::FunctionParameterAttribute(v) => result.push(v as u32),
Self::Decoration(v) => result.push(v as u32),
Self::BuiltIn(v) => result.push(v as u32),
Self::Scope(v) => result.push(v as u32),
Self::GroupOperation(v) => result.push(v as u32),
Self::KernelEnqueueFlags(v) => result.push(v as u32),
Self::Capability(v) => result.push(v as u32),
Self::IdMemorySemantics(v)
| Self::IdScope(v)
| Self::IdRef(v)
| Self::LiteralInt32(v)
| Self::LiteralExtInstInteger(v) => result.push(v),
Self::LiteralInt64(v) => result.extend(&[v as u32, (v >> 32) as u32]),
Self::LiteralFloat32(v) => result.push(v.to_bits()),
Self::LiteralFloat64(v) => {
result.extend(&[v.to_bits() as u32, (v.to_bits() >> 32) as u32])
}
dr::Operand::LiteralSpecConstantOpInteger(v) => result.push(v as u32),
dr::Operand::LiteralString(ref v) => assemble_str(v, result),
dr::Operand::RayFlags(ref v) => result.push(v.bits()),
dr::Operand::RayQueryIntersection(v) => result.push(v as u32),
dr::Operand::RayQueryCommittedIntersectionType(v) => result.push(v as u32),
dr::Operand::RayQueryCandidateIntersectionType(v) => result.push(v as u32),
dr::Operand::FragmentShadingRate(v) => result.push(v.bits()),
Self::LiteralSpecConstantOpInteger(v) => result.push(v as u32),
Self::LiteralString(ref v) => assemble_str(v, result),
Self::RayFlags(ref v) => result.push(v.bits()),
Self::RayQueryIntersection(v) => result.push(v as u32),
Self::RayQueryCommittedIntersectionType(v) => result.push(v as u32),
Self::RayQueryCandidateIntersectionType(v) => result.push(v as u32),
Self::FragmentShadingRate(v) => result.push(v.bits()),
Self::FPDenormMode(v) => result.push(v as u32),
Self::QuantizationModes(v) => result.push(v as u32),
Self::FPOperationMode(v) => result.push(v as u32),
Self::OverflowModes(v) => result.push(v as u32),
Self::PackedVectorFormat(v) => result.push(v as u32),
}
}
}
Expand Down
55 changes: 55 additions & 0 deletions rspirv/binary/autogen_decode_operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,50 @@ impl<'a> Decoder<'a> {
Err(Error::StreamExpected(self.offset))
}
}
#[doc = "Decodes and returns the next SPIR-V word as\na SPIR-V FPDenormMode value."]
pub fn fp_denorm_mode(&mut self) -> Result<spirv::FPDenormMode> {
if let Ok(word) = self.word() {
spirv::FPDenormMode::from_u32(word).ok_or(Error::FPDenormModeUnknown(
self.offset - WORD_NUM_BYTES,
word,
))
} else {
Err(Error::StreamExpected(self.offset))
}
}
#[doc = "Decodes and returns the next SPIR-V word as\na SPIR-V QuantizationModes value."]
pub fn quantization_modes(&mut self) -> Result<spirv::QuantizationModes> {
if let Ok(word) = self.word() {
spirv::QuantizationModes::from_u32(word).ok_or(Error::QuantizationModesUnknown(
self.offset - WORD_NUM_BYTES,
word,
))
} else {
Err(Error::StreamExpected(self.offset))
}
}
#[doc = "Decodes and returns the next SPIR-V word as\na SPIR-V FPOperationMode value."]
pub fn fp_operation_mode(&mut self) -> Result<spirv::FPOperationMode> {
if let Ok(word) = self.word() {
spirv::FPOperationMode::from_u32(word).ok_or(Error::FPOperationModeUnknown(
self.offset - WORD_NUM_BYTES,
word,
))
} else {
Err(Error::StreamExpected(self.offset))
}
}
#[doc = "Decodes and returns the next SPIR-V word as\na SPIR-V OverflowModes value."]
pub fn overflow_modes(&mut self) -> Result<spirv::OverflowModes> {
if let Ok(word) = self.word() {
spirv::OverflowModes::from_u32(word).ok_or(Error::OverflowModesUnknown(
self.offset - WORD_NUM_BYTES,
word,
))
} else {
Err(Error::StreamExpected(self.offset))
}
}
#[doc = "Decodes and returns the next SPIR-V word as\na SPIR-V LinkageType value."]
pub fn linkage_type(&mut self) -> Result<spirv::LinkageType> {
if let Ok(word) = self.word() {
Expand Down Expand Up @@ -376,4 +420,15 @@ impl<'a> Decoder<'a> {
Err(Error::StreamExpected(self.offset))
}
}
#[doc = "Decodes and returns the next SPIR-V word as\na SPIR-V PackedVectorFormat value."]
pub fn packed_vector_format(&mut self) -> Result<spirv::PackedVectorFormat> {
if let Ok(word) = self.word() {
spirv::PackedVectorFormat::from_u32(word).ok_or(Error::PackedVectorFormatUnknown(
self.offset - WORD_NUM_BYTES,
word,
))
} else {
Err(Error::StreamExpected(self.offset))
}
}
}
15 changes: 15 additions & 0 deletions rspirv/binary/autogen_disas_operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ impl Disassemble for spirv::ImageOperands {
if self.contains(spirv::ImageOperands::ZERO_EXTEND) {
bits.push("ZeroExtend")
}
if self.contains(spirv::ImageOperands::OFFSETS) {
bits.push("Offsets")
}
bits.join("|")
}
}
Expand All @@ -86,6 +89,12 @@ impl Disassemble for spirv::FPFastMathMode {
if self.contains(spirv::FPFastMathMode::FAST) {
bits.push("Fast")
}
if self.contains(spirv::FPFastMathMode::ALLOW_CONTRACT_FAST_INTEL) {
bits.push("AllowContractFastINTEL")
}
if self.contains(spirv::FPFastMathMode::ALLOW_REASSOC_INTEL) {
bits.push("AllowReassocINTEL")
}
bits.join("|")
}
}
Expand Down Expand Up @@ -158,6 +167,9 @@ impl Disassemble for spirv::LoopControl {
if self.contains(spirv::LoopControl::SPECULATED_ITERATIONS_INTEL) {
bits.push("SpeculatedIterationsINTEL")
}
if self.contains(spirv::LoopControl::NO_FUSION_INTEL) {
bits.push("NoFusionINTEL")
}
bits.join("|")
}
}
Expand All @@ -179,6 +191,9 @@ impl Disassemble for spirv::FunctionControl {
if self.contains(spirv::FunctionControl::CONST) {
bits.push("Const")
}
if self.contains(spirv::FunctionControl::OPT_NONE_INTEL) {
bits.push("OptNoneINTEL")
}
bits.join("|")
}
}
Expand Down
30 changes: 30 additions & 0 deletions rspirv/binary/autogen_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ pub enum Error {
ImageChannelOrderUnknown(usize, spirv::Word),
ImageChannelDataTypeUnknown(usize, spirv::Word),
FPRoundingModeUnknown(usize, spirv::Word),
FPDenormModeUnknown(usize, spirv::Word),
QuantizationModesUnknown(usize, spirv::Word),
FPOperationModeUnknown(usize, spirv::Word),
OverflowModesUnknown(usize, spirv::Word),
LinkageTypeUnknown(usize, spirv::Word),
AccessQualifierUnknown(usize, spirv::Word),
FunctionParameterAttributeUnknown(usize, spirv::Word),
Expand All @@ -44,6 +48,7 @@ pub enum Error {
RayQueryIntersectionUnknown(usize, spirv::Word),
RayQueryCommittedIntersectionTypeUnknown(usize, spirv::Word),
RayQueryCandidateIntersectionTypeUnknown(usize, spirv::Word),
PackedVectorFormatUnknown(usize, spirv::Word),
#[doc = r"Failed to decode a string."]
#[doc = r""]
#[doc = r"For structured error handling, the second element could be"]
Expand Down Expand Up @@ -173,6 +178,26 @@ impl fmt::Display for Error {
"unknown value {} for operand kind FPRoundingMode at index {}",
word, index
),
Error::FPDenormModeUnknown(index, word) => write!(
f,
"unknown value {} for operand kind FPDenormMode at index {}",
word, index
),
Error::QuantizationModesUnknown(index, word) => write!(
f,
"unknown value {} for operand kind QuantizationModes at index {}",
word, index
),
Error::FPOperationModeUnknown(index, word) => write!(
f,
"unknown value {} for operand kind FPOperationMode at index {}",
word, index
),
Error::OverflowModesUnknown(index, word) => write!(
f,
"unknown value {} for operand kind OverflowModes at index {}",
word, index
),
Error::LinkageTypeUnknown(index, word) => write!(
f,
"unknown value {} for operand kind LinkageType at index {}",
Expand Down Expand Up @@ -233,6 +258,11 @@ impl fmt::Display for Error {
"unknown value {} for operand kind RayQueryCandidateIntersectionType at index {}",
word, index
),
Error::PackedVectorFormatUnknown(index, word) => write!(
f,
"unknown value {} for operand kind PackedVectorFormat at index {}",
word, index
),
Error::DecodeStringFailed(index, ref e) => {
write!(f, "cannot decode string at index {}: {}", index, e)
}
Expand Down
Loading