Skip to content

Commit

Permalink
Regenerate on sdk-1.3.268 (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
exrook committed Dec 1, 2023
1 parent a3b41ed commit c16591f
Show file tree
Hide file tree
Showing 21 changed files with 2,136 additions and 53 deletions.
11 changes: 4 additions & 7 deletions autogen/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ fn get_decode_method(kind: &str) -> Ident {
return as_ident("id");
}

let mut kind = kind;
if kind.starts_with("Literal") {
kind = &kind["Literal".len()..];
if kind == "Integer" {
return as_ident("bit32");
}
match kind.strip_prefix("Literal") {
Some("Integer" | "Float") => as_ident("bit32"),
Some(kind) => as_ident(&kind.to_snake_case()),
None => as_ident(&kind.to_snake_case()),
}
as_ident(&kind.to_snake_case())
}

/// Returns the generated operand decoding errors for binary::Decoder by
Expand Down
1 change: 1 addition & 0 deletions autogen/src/dr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ pub fn gen_dr_operand_kinds(grammar: &[structs::OperandKind]) -> TokenStream {
| "LiteralInteger"
| "IdResult"
| "IdResultType"
| "LiteralFloat"
))
})
.map(as_ident)
Expand Down
5 changes: 5 additions & 0 deletions autogen/src/sr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ impl OperandTokens {
quote! { *value },
OperandTy::Single("LiteralBit32"),
),
"LiteralFloat" => (
quote! { u32 },
quote! { *value },
OperandTy::Single("LiteralBit32"),
),
"LiteralExtInstInteger" => (
quote! { u32 },
quote! { *value },
Expand Down
12 changes: 10 additions & 2 deletions autogen/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ pub fn as_ident(ident: &str) -> Ident {
/// given operand `kind` in the grammar.
pub fn get_dr_operand_kind(kind: &str) -> Ident {
as_ident(
if matches!(kind, "LiteralInteger" | "LiteralContextDependentNumber") {
if matches!(
kind,
"LiteralInteger" | "LiteralContextDependentNumber" | "LiteralFloat"
) {
// TODO: LiteralContextDependentNumber should use the correct type to decode
"LiteralBit32"
} else {
Expand All @@ -41,7 +44,8 @@ pub fn get_dr_operand_kind(kind: &str) -> Ident {
pub fn get_enum_underlying_type(kind: &str, generic_string: bool) -> TokenStream {
if kind.starts_with("Id") {
quote! { spirv::Word }
} else if kind == "LiteralInteger" || kind == "LiteralExtInstInteger" {
} else if kind == "LiteralInteger" || kind == "LiteralExtInstInteger" || kind == "LiteralFloat"
{
quote! { u32 }
} else if kind == "LiteralSpecConstantOpInteger" {
quote! { spirv::Op }
Expand Down Expand Up @@ -92,9 +96,13 @@ pub fn get_param_name(params: &[structs::Operand], param_index: usize) -> Ident

let mut name = raw_name.to_snake_case();

// Rename/remap rust reserved keywords
if name == "type" {
name = "ty".to_owned();
}
if name == "use" {
name = "usage".to_owned();
}

if duplicate_count > 0 {
name = format!("{}_{}", name, duplicate_count + 1);
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+sdk-1.3.243.0"
version = "0.11.0+sdk-1.3.268.0"
authors = ["Lei Zhang <antiagainst@gmail.com>"]
edition = "2018"

Expand Down
7 changes: 7 additions & 0 deletions rspirv/binary/assemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl Assemble for dr::Operand {
Self::MemorySemantics(v) => result.push(v.bits()),
Self::MemoryAccess(v) => result.push(v.bits()),
Self::KernelProfilingInfo(v) => result.push(v.bits()),
Self::CooperativeMatrixOperands(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),
Expand Down Expand Up @@ -87,6 +88,12 @@ impl Assemble for dr::Operand {
Self::FPOperationMode(v) => result.push(v as u32),
Self::OverflowModes(v) => result.push(v as u32),
Self::PackedVectorFormat(v) => result.push(v as u32),
Self::HostAccessQualifier(v) => result.push(v as u32),
Self::CooperativeMatrixLayout(v) => result.push(v as u32),
Self::CooperativeMatrixUse(v) => result.push(v as u32),
Self::InitializationModeQualifier(v) => result.push(v as u32),
Self::LoadCacheControl(v) => result.push(v as u32),
Self::StoreCacheControl(v) => result.push(v as u32),
}
}
}
Expand Down
74 changes: 74 additions & 0 deletions rspirv/binary/autogen_decode_operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,17 @@ impl<'a> Decoder<'a> {
Err(Error::StreamExpected(self.offset))
}
}
#[doc = "Decodes and returns the next SPIR-V word as\na SPIR-V HostAccessQualifier value."]
pub fn host_access_qualifier(&mut self) -> Result<spirv::HostAccessQualifier> {
if let Ok(word) = self.word() {
spirv::HostAccessQualifier::from_u32(word).ok_or(Error::HostAccessQualifierUnknown(
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 FunctionParameterAttribute value."]
pub fn function_parameter_attribute(&mut self) -> Result<spirv::FunctionParameterAttribute> {
if let Ok(word) = self.word() {
Expand Down Expand Up @@ -431,4 +442,67 @@ impl<'a> Decoder<'a> {
Err(Error::StreamExpected(self.offset))
}
}
#[doc = "Decodes and returns the next SPIR-V word as\na SPIR-V CooperativeMatrixOperands value."]
pub fn cooperative_matrix_operands(&mut self) -> Result<spirv::CooperativeMatrixOperands> {
if let Ok(word) = self.word() {
spirv::CooperativeMatrixOperands::from_bits(word).ok_or(
Error::CooperativeMatrixOperandsUnknown(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 CooperativeMatrixLayout value."]
pub fn cooperative_matrix_layout(&mut self) -> Result<spirv::CooperativeMatrixLayout> {
if let Ok(word) = self.word() {
spirv::CooperativeMatrixLayout::from_u32(word).ok_or(
Error::CooperativeMatrixLayoutUnknown(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 CooperativeMatrixUse value."]
pub fn cooperative_matrix_use(&mut self) -> Result<spirv::CooperativeMatrixUse> {
if let Ok(word) = self.word() {
spirv::CooperativeMatrixUse::from_u32(word).ok_or(Error::CooperativeMatrixUseUnknown(
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 InitializationModeQualifier value."]
pub fn initialization_mode_qualifier(&mut self) -> Result<spirv::InitializationModeQualifier> {
if let Ok(word) = self.word() {
spirv::InitializationModeQualifier::from_u32(word).ok_or(
Error::InitializationModeQualifierUnknown(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 LoadCacheControl value."]
pub fn load_cache_control(&mut self) -> Result<spirv::LoadCacheControl> {
if let Ok(word) = self.word() {
spirv::LoadCacheControl::from_u32(word).ok_or(Error::LoadCacheControlUnknown(
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 StoreCacheControl value."]
pub fn store_cache_control(&mut self) -> Result<spirv::StoreCacheControl> {
if let Ok(word) = self.word() {
spirv::StoreCacheControl::from_u32(word).ok_or(Error::StoreCacheControlUnknown(
self.offset - WORD_NUM_BYTES,
word,
))
} else {
Err(Error::StreamExpected(self.offset))
}
}
}
24 changes: 24 additions & 0 deletions rspirv/binary/autogen_disas_operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,27 @@ impl Disassemble for spirv::FragmentShadingRate {
bits.join("|")
}
}
impl Disassemble for spirv::CooperativeMatrixOperands {
fn disassemble(&self) -> String {
if self.is_empty() {
return "None".to_string();
}
let mut bits = vec![];
if self.contains(spirv::CooperativeMatrixOperands::MATRIX_A_SIGNED_COMPONENTS_KHR) {
bits.push("MatrixASignedComponentsKHR")
}
if self.contains(spirv::CooperativeMatrixOperands::MATRIX_B_SIGNED_COMPONENTS_KHR) {
bits.push("MatrixBSignedComponentsKHR")
}
if self.contains(spirv::CooperativeMatrixOperands::MATRIX_C_SIGNED_COMPONENTS_KHR) {
bits.push("MatrixCSignedComponentsKHR")
}
if self.contains(spirv::CooperativeMatrixOperands::MATRIX_RESULT_SIGNED_COMPONENTS_KHR) {
bits.push("MatrixResultSignedComponentsKHR")
}
if self.contains(spirv::CooperativeMatrixOperands::SATURATING_ACCUMULATION_KHR) {
bits.push("SaturatingAccumulationKHR")
}
bits.join("|")
}
}
42 changes: 42 additions & 0 deletions rspirv/binary/autogen_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum Error {
OverflowModesUnknown(usize, spirv::Word),
LinkageTypeUnknown(usize, spirv::Word),
AccessQualifierUnknown(usize, spirv::Word),
HostAccessQualifierUnknown(usize, spirv::Word),
FunctionParameterAttributeUnknown(usize, spirv::Word),
DecorationUnknown(usize, spirv::Word),
BuiltInUnknown(usize, spirv::Word),
Expand All @@ -49,6 +50,12 @@ pub enum Error {
RayQueryCommittedIntersectionTypeUnknown(usize, spirv::Word),
RayQueryCandidateIntersectionTypeUnknown(usize, spirv::Word),
PackedVectorFormatUnknown(usize, spirv::Word),
CooperativeMatrixOperandsUnknown(usize, spirv::Word),
CooperativeMatrixLayoutUnknown(usize, spirv::Word),
CooperativeMatrixUseUnknown(usize, spirv::Word),
InitializationModeQualifierUnknown(usize, spirv::Word),
LoadCacheControlUnknown(usize, spirv::Word),
StoreCacheControlUnknown(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 @@ -208,6 +215,11 @@ impl fmt::Display for Error {
"unknown value {} for operand kind AccessQualifier at index {}",
word, index
),
Error::HostAccessQualifierUnknown(index, word) => write!(
f,
"unknown value {} for operand kind HostAccessQualifier at index {}",
word, index
),
Error::FunctionParameterAttributeUnknown(index, word) => write!(
f,
"unknown value {} for operand kind FunctionParameterAttribute at index {}",
Expand Down Expand Up @@ -263,6 +275,36 @@ impl fmt::Display for Error {
"unknown value {} for operand kind PackedVectorFormat at index {}",
word, index
),
Error::CooperativeMatrixOperandsUnknown(index, word) => write!(
f,
"unknown value {} for operand kind CooperativeMatrixOperands at index {}",
word, index
),
Error::CooperativeMatrixLayoutUnknown(index, word) => write!(
f,
"unknown value {} for operand kind CooperativeMatrixLayout at index {}",
word, index
),
Error::CooperativeMatrixUseUnknown(index, word) => write!(
f,
"unknown value {} for operand kind CooperativeMatrixUse at index {}",
word, index
),
Error::InitializationModeQualifierUnknown(index, word) => write!(
f,
"unknown value {} for operand kind InitializationModeQualifier at index {}",
word, index
),
Error::LoadCacheControlUnknown(index, word) => write!(
f,
"unknown value {} for operand kind LoadCacheControl at index {}",
word, index
),
Error::StoreCacheControlUnknown(index, word) => write!(
f,
"unknown value {} for operand kind StoreCacheControl at index {}",
word, index
),
Error::DecodeStringFailed(index, ref e) => {
write!(f, "cannot decode string at index {}: {}", index, e)
}
Expand Down
Loading

0 comments on commit c16591f

Please sign in to comment.