mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
spv-out: configure source language in debug info
This commit is contained in:
parent
c8beade187
commit
eb18854b46
@ -92,6 +92,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216).
|
|||||||
#### Naga
|
#### Naga
|
||||||
|
|
||||||
- Accept only `vec3` (not `vecN`) for the `cross` built-in. By @ErichDonGubler in [#6171](https://github.com/gfx-rs/wgpu/pull/6171).
|
- Accept only `vec3` (not `vecN`) for the `cross` built-in. By @ErichDonGubler in [#6171](https://github.com/gfx-rs/wgpu/pull/6171).
|
||||||
|
- Configure `SourceLanguage` when enabling debug info in SPV-out. By @kvark in [#6256](https://github.com/gfx-rs/wgpu/pull/6256)
|
||||||
|
|
||||||
#### General
|
#### General
|
||||||
|
|
||||||
|
@ -465,6 +465,7 @@ fn run() -> anyhow::Result<()> {
|
|||||||
let Parsed {
|
let Parsed {
|
||||||
mut module,
|
mut module,
|
||||||
input_text,
|
input_text,
|
||||||
|
language,
|
||||||
} = parse_input(input_path, input, ¶ms)?;
|
} = parse_input(input_path, input, ¶ms)?;
|
||||||
|
|
||||||
// Include debugging information if requested.
|
// Include debugging information if requested.
|
||||||
@ -477,6 +478,7 @@ fn run() -> anyhow::Result<()> {
|
|||||||
params.spv_out.debug_info = Some(naga::back::spv::DebugInfo {
|
params.spv_out.debug_info = Some(naga::back::spv::DebugInfo {
|
||||||
source_code: input_text,
|
source_code: input_text,
|
||||||
file_name: input_path,
|
file_name: input_path,
|
||||||
|
language,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
@ -579,6 +581,7 @@ fn run() -> anyhow::Result<()> {
|
|||||||
struct Parsed {
|
struct Parsed {
|
||||||
module: naga::Module,
|
module: naga::Module,
|
||||||
input_text: Option<String>,
|
input_text: Option<String>,
|
||||||
|
language: naga::back::spv::SourceLanguage,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_input(input_path: &Path, input: Vec<u8>, params: &Parameters) -> anyhow::Result<Parsed> {
|
fn parse_input(input_path: &Path, input: Vec<u8>, params: &Parameters) -> anyhow::Result<Parsed> {
|
||||||
@ -593,16 +596,26 @@ fn parse_input(input_path: &Path, input: Vec<u8>, params: &Parameters) -> anyhow
|
|||||||
.context("Unable to determine --input-kind from filename")?,
|
.context("Unable to determine --input-kind from filename")?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (module, input_text) = match input_kind {
|
Ok(match input_kind {
|
||||||
InputKind::Bincode => (bincode::deserialize(&input)?, None),
|
InputKind::Bincode => Parsed {
|
||||||
InputKind::SpirV => {
|
module: bincode::deserialize(&input)?,
|
||||||
naga::front::spv::parse_u8_slice(&input, ¶ms.spv_in).map(|m| (m, None))?
|
input_text: None,
|
||||||
}
|
language: naga::back::spv::SourceLanguage::Unknown,
|
||||||
|
},
|
||||||
|
InputKind::SpirV => Parsed {
|
||||||
|
module: naga::front::spv::parse_u8_slice(&input, ¶ms.spv_in)?,
|
||||||
|
input_text: None,
|
||||||
|
language: naga::back::spv::SourceLanguage::Unknown,
|
||||||
|
},
|
||||||
InputKind::Wgsl => {
|
InputKind::Wgsl => {
|
||||||
let input = String::from_utf8(input)?;
|
let input = String::from_utf8(input)?;
|
||||||
let result = naga::front::wgsl::parse_str(&input);
|
let result = naga::front::wgsl::parse_str(&input);
|
||||||
match result {
|
match result {
|
||||||
Ok(v) => (v, Some(input)),
|
Ok(v) => Parsed {
|
||||||
|
module: v,
|
||||||
|
input_text: Some(input),
|
||||||
|
language: naga::back::spv::SourceLanguage::WGSL,
|
||||||
|
},
|
||||||
Err(ref e) => {
|
Err(ref e) => {
|
||||||
let message = anyhow!(
|
let message = anyhow!(
|
||||||
"Could not parse WGSL:\n{}",
|
"Could not parse WGSL:\n{}",
|
||||||
@ -631,8 +644,8 @@ fn parse_input(input_path: &Path, input: Vec<u8>, params: &Parameters) -> anyhow
|
|||||||
};
|
};
|
||||||
let input = String::from_utf8(input)?;
|
let input = String::from_utf8(input)?;
|
||||||
let mut parser = naga::front::glsl::Frontend::default();
|
let mut parser = naga::front::glsl::Frontend::default();
|
||||||
(
|
Parsed {
|
||||||
parser
|
module: parser
|
||||||
.parse(
|
.parse(
|
||||||
&naga::front::glsl::Options {
|
&naga::front::glsl::Options {
|
||||||
stage: shader_stage.0,
|
stage: shader_stage.0,
|
||||||
@ -649,12 +662,11 @@ fn parse_input(input_path: &Path, input: Vec<u8>, params: &Parameters) -> anyhow
|
|||||||
error.emit_to_writer_with_path(&mut writer, &input, filename);
|
error.emit_to_writer_with_path(&mut writer, &input, filename);
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}),
|
}),
|
||||||
Some(input),
|
input_text: Some(input),
|
||||||
)
|
language: naga::back::spv::SourceLanguage::GLSL,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
})
|
||||||
|
|
||||||
Ok(Parsed { module, input_text })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_output(
|
fn write_output(
|
||||||
@ -833,7 +845,11 @@ fn bulk_validate(args: Args, params: &Parameters) -> anyhow::Result<()> {
|
|||||||
let path = Path::new(&input_path);
|
let path = Path::new(&input_path);
|
||||||
let input = fs::read(path)?;
|
let input = fs::read(path)?;
|
||||||
|
|
||||||
let Parsed { module, input_text } = match parse_input(path, input, params) {
|
let Parsed {
|
||||||
|
module,
|
||||||
|
input_text,
|
||||||
|
language: _,
|
||||||
|
} = match parse_input(path, input, params) {
|
||||||
Ok(parsed) => parsed,
|
Ok(parsed) => parsed,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
invalid.push(input_path.clone());
|
invalid.push(input_path.clone());
|
||||||
|
@ -16,7 +16,7 @@ mod selection;
|
|||||||
mod subgroup;
|
mod subgroup;
|
||||||
mod writer;
|
mod writer;
|
||||||
|
|
||||||
pub use spirv::Capability;
|
pub use spirv::{Capability, SourceLanguage};
|
||||||
|
|
||||||
use crate::arena::{Handle, HandleVec};
|
use crate::arena::{Handle, HandleVec};
|
||||||
use crate::proc::{BoundsCheckPolicies, TypeResolution};
|
use crate::proc::{BoundsCheckPolicies, TypeResolution};
|
||||||
@ -89,6 +89,7 @@ impl IdGenerator {
|
|||||||
pub struct DebugInfo<'a> {
|
pub struct DebugInfo<'a> {
|
||||||
pub source_code: &'a str,
|
pub source_code: &'a str,
|
||||||
pub file_name: &'a std::path::Path,
|
pub file_name: &'a std::path::Path,
|
||||||
|
pub language: SourceLanguage,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A SPIR-V block to which we are still adding instructions.
|
/// A SPIR-V block to which we are still adding instructions.
|
||||||
|
@ -1967,7 +1967,7 @@ impl Writer {
|
|||||||
source_file_id,
|
source_file_id,
|
||||||
});
|
});
|
||||||
self.debugs.append(&mut Instruction::source_auto_continued(
|
self.debugs.append(&mut Instruction::source_auto_continued(
|
||||||
spirv::SourceLanguage::Unknown,
|
debug_info.language,
|
||||||
0,
|
0,
|
||||||
&debug_info_inner,
|
&debug_info_inner,
|
||||||
));
|
));
|
||||||
|
@ -358,6 +358,10 @@ fn check_targets(
|
|||||||
let debug_info = source_code.map(|code| naga::back::spv::DebugInfo {
|
let debug_info = source_code.map(|code| naga::back::spv::DebugInfo {
|
||||||
source_code: code,
|
source_code: code,
|
||||||
file_name: name.as_ref(),
|
file_name: name.as_ref(),
|
||||||
|
// wgpu#6266: we technically know all the information here to
|
||||||
|
// produce the valid language but it's not too important for
|
||||||
|
// validation purposes
|
||||||
|
language: naga::back::spv::SourceLanguage::Unknown,
|
||||||
});
|
});
|
||||||
|
|
||||||
if targets.contains(Targets::SPIRV) {
|
if targets.contains(Targets::SPIRV) {
|
||||||
|
@ -769,6 +769,7 @@ impl super::Device {
|
|||||||
temp_options.debug_info = Some(naga::back::spv::DebugInfo {
|
temp_options.debug_info = Some(naga::back::spv::DebugInfo {
|
||||||
source_code: &debug.source_code,
|
source_code: &debug.source_code,
|
||||||
file_name: debug.file_name.as_ref().as_ref(),
|
file_name: debug.file_name.as_ref().as_ref(),
|
||||||
|
language: naga::back::spv::SourceLanguage::WGSL,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if !stage.zero_initialize_workgroup_memory {
|
if !stage.zero_initialize_workgroup_memory {
|
||||||
@ -1742,6 +1743,7 @@ impl crate::Device for super::Device {
|
|||||||
.map(|d| naga::back::spv::DebugInfo {
|
.map(|d| naga::back::spv::DebugInfo {
|
||||||
source_code: d.source_code.as_ref(),
|
source_code: d.source_code.as_ref(),
|
||||||
file_name: d.file_name.as_ref().as_ref(),
|
file_name: d.file_name.as_ref().as_ref(),
|
||||||
|
language: naga::back::spv::SourceLanguage::WGSL,
|
||||||
});
|
});
|
||||||
if !desc.runtime_checks {
|
if !desc.runtime_checks {
|
||||||
naga_options.bounds_check_policies = naga::proc::BoundsCheckPolicies {
|
naga_options.bounds_check_policies = naga::proc::BoundsCheckPolicies {
|
||||||
|
Loading…
Reference in New Issue
Block a user