mirror of
https://github.com/ivall/xcl.git
synced 2026-11-24 05:14:57 +01:00
Olympus: share geometry wave selection
This commit is contained in:
@@ -964,6 +964,17 @@ pub fn geometry_wave32_hazards(code: &[u8]) -> BTreeSet<&'static str> {
|
||||
out
|
||||
}
|
||||
|
||||
/// Translate a complete ES+GS program for the adapter-selected geometry path.
|
||||
pub fn translate_geometry(code: &[u8], interface: GsInterface, geometry_wave32: bool) -> Result<Translation, String> {
|
||||
if geometry_wave32 {
|
||||
let hazards = geometry_wave32_hazards(code);
|
||||
if !hazards.is_empty() {
|
||||
return Err(format!("geometry program requires unsupported cross-half wave64 semantics: {hazards:?}"));
|
||||
}
|
||||
}
|
||||
translate(code, &Options { mode: Mode::Geometry(interface), wave64: true, geometry_wave32, ..Default::default() })
|
||||
}
|
||||
|
||||
/// Wave size the program was compiled for: 64-bit EXEC/VCC writes mean wave64.
|
||||
pub fn detect_wave64(code: &[u8]) -> bool {
|
||||
let mut off = 0;
|
||||
|
||||
@@ -99,6 +99,10 @@ pub struct TwoPass {
|
||||
|
||||
fn two_pass(code: &[u8], mode: Mode, wave64: bool, geometry_wave32: bool, record: super::MsInterface, ps: Option<&[u8]>) -> Result<TwoPass, String> {
|
||||
let t = translate(code, &Options { mode, wave64, geometry_wave32, ..Default::default() })?;
|
||||
finish_two_pass(t, record, ps)
|
||||
}
|
||||
|
||||
fn finish_two_pass(t: super::Translation, record: super::MsInterface, ps: Option<&[u8]>) -> Result<TwoPass, String> {
|
||||
if !t.complete() {
|
||||
let missing: Vec<&String> = t.unsupported.keys().collect();
|
||||
return Err(format!("incomplete translation, missing: {missing:?}"));
|
||||
@@ -128,17 +132,28 @@ pub fn geometry_uses_wave32(wave_min: u32, wave_max: u32) -> bool {
|
||||
!(wave_min <= 64 && wave_max >= 64)
|
||||
}
|
||||
|
||||
pub fn geometry_uses_wave32_for_device(device: &ID3D12Device) -> bool {
|
||||
let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS1::default();
|
||||
if unsafe {
|
||||
device.CheckFeatureSupport(
|
||||
D3D12_FEATURE_D3D12_OPTIONS1,
|
||||
&mut options as *mut _ as _,
|
||||
std::mem::size_of_val(&options) as u32,
|
||||
)
|
||||
}
|
||||
.is_err()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
geometry_uses_wave32(options.WaveLaneCountMin, options.WaveLaneCountMax)
|
||||
}
|
||||
|
||||
/// A legacy GS pipeline: the ES variant of a console VS + the GS as one program.
|
||||
pub fn console_geometry(vs: &[u8], gs: &[u8], ps: Option<&[u8]>, geometry_wave32: bool) -> Result<TwoPass, String> {
|
||||
let (code, g) = super::geometry_program(vs, gs)?;
|
||||
if geometry_wave32 {
|
||||
let hazards = super::geometry_wave32_hazards(&code);
|
||||
if !hazards.is_empty() {
|
||||
return Err(format!("geometry program requires unsupported cross-half wave64 semantics: {hazards:?}"));
|
||||
}
|
||||
}
|
||||
let record = g.record();
|
||||
two_pass(&code, Mode::Geometry(g), true, geometry_wave32, record, ps)
|
||||
let translation = super::translate_geometry(&code, g, geometry_wave32)?;
|
||||
finish_two_pass(translation, record, ps)
|
||||
}
|
||||
|
||||
/// XCL shader ABI root signature (see the module docs); `graphics` allows an input layout.
|
||||
|
||||
@@ -280,18 +280,7 @@ fn geometry_wave32_required(device: *mut c_void) -> bool {
|
||||
}
|
||||
unsafe {
|
||||
let Some(dev) = ID3D12Device::from_raw_borrowed(&device) else { return true };
|
||||
let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS1::default();
|
||||
if dev
|
||||
.CheckFeatureSupport(
|
||||
D3D12_FEATURE_D3D12_OPTIONS1,
|
||||
&mut options as *mut _ as _,
|
||||
std::mem::size_of_val(&options) as u32,
|
||||
)
|
||||
.is_err()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
crate::gpu::recomp::pso::geometry_uses_wave32(options.WaveLaneCountMin, options.WaveLaneCountMax)
|
||||
crate::gpu::recomp::pso::geometry_uses_wave32_for_device(dev)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -434,7 +434,8 @@ fn retail_es_gs_voxelize_geometry_mode() {
|
||||
use xcl::gpu::recomp::{self, dxc, IO_GS_PRIMS, IO_GS_VERTICES, MESH_HEADER};
|
||||
let (code, g) = recomp::geometry_program(&blobs[0], &blobs[1]).expect("ES + GS pair");
|
||||
assert_eq!((g.max_vertex_count, g.vertex_bytes()), (3, 64));
|
||||
let t = recomp::translate(&code, &recomp::Options { mode: recomp::Mode::Geometry(g.clone()), wave64: true, ..Default::default() }).unwrap();
|
||||
let split_wave32 = recomp::pso::geometry_uses_wave32_for_device(&_dev);
|
||||
let t = recomp::translate_geometry(&code, g.clone(), split_wave32).unwrap();
|
||||
assert!(t.complete(), "{:?}", t.unsupported_why);
|
||||
let cs = dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("{e}"));
|
||||
let rec = g.record();
|
||||
|
||||
Reference in New Issue
Block a user