Skip to content
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
3 changes: 3 additions & 0 deletions drivers/gpu/drm/asahi/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ pub(crate) const DRM_ASAHI_RENDER_SHADER_WRITES: u32 =
/// (DRM_ASAHI_RENDER_STAGE_PREFIXES), as the complete struct drm_asahi_cmd_render_m5.
pub(crate) const DRM_ASAHI_FEATURE_RENDER_STAGE_PREFIXES_V2: u64 =
uapi::DRM_ASAHI_FEATURE_RENDER_STAGE_PREFIXES_V2 as u64;
/// Render commands accept tile buffers of up to 48 KiB.
pub(crate) const DRM_ASAHI_FEATURE_TILE_BUFFER_48K: u64 =
uapi::DRM_ASAHI_FEATURE_TILE_BUFFER_48K as u64;
/// Compute commands may declare a stream that ends with a memory-scoped flush
/// (DRM_ASAHI_COMPUTE_VISIBLE_COMPLETION).
pub(crate) const DRM_ASAHI_FEATURE_COMPUTE_VISIBLE_COMPLETION: u64 =
Expand Down
5 changes: 3 additions & 2 deletions drivers/gpu/drm/asahi/g16/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const SET_COMPUTE_ATTACHMENTS: u32 = uapi::drm_asahi_cmd_type_DRM_ASAHI_SET_COMP

const MAX_DIMENSION: u16 = 16384;
const MAX_LAYERS: u16 = 2048;
const MAX_TILE_BUFFER: u32 = 32768;
const ZLS_METADATA_STRIDE: u64 = 0x80;
/// Size of a queue's USC window.
pub(crate) const USC_WINDOW: u64 = 1 << 32;
Expand Down Expand Up @@ -373,6 +372,8 @@ pub(crate) struct Context<'a> {
pub(crate) active_cores: u32,
/// The queue's reserved render scratch pages per stage (`render_scs_layout`).
pub(crate) render_scs: [u16; 2],
/// Largest tile buffer render commands may use, in bytes (`Config::max_tile_buffer`).
pub(crate) max_tile_buffer: u32,
}

/// A stream whose timestamps and ordinals are resolved ([`ParsedStream::prepare`]), before its
Expand Down Expand Up @@ -1277,7 +1278,7 @@ fn check_render_for(
|| !matches!(cmd.samples, 1 | 2 | 4)
|| !matches!(cmd.utile_width_px, 16 | 32)
|| !matches!(cmd.utile_height_px, 16 | 32)
|| tile_buffer > MAX_TILE_BUFFER
|| tile_buffer > context.max_tile_buffer
|| cmd.sampler_heap != 0
|| cmd.sampler_count != 0
|| cmd.ppp_ctrl & !0x203 != 0
Expand Down
11 changes: 11 additions & 0 deletions drivers/gpu/drm/asahi/g16/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ pub(crate) struct Config {
pub(crate) supports_render_scs: bool,
/// Whether FS->compute cross-engine barriers require `BarrierType::Hold` (type 1), as on G15.
pub(crate) cross_engine_hold: bool,
/// Largest tile buffer a render command may use, in bytes per tile (sample size times
/// utile width, utile height and samples). Reported as DRM_ASAHI_FEATURE_TILE_BUFFER_48K
/// when it reaches [`sizes::TILE_BUFFER_48K`].
pub(crate) max_tile_buffer: u32,
}

impl Config {
Expand Down Expand Up @@ -242,6 +246,8 @@ pub(crate) mod t8132 {
deep_sleep: true,
supports_render_scs: true,
cross_engine_hold: false,
// macOS 26B123 programs 48 KiB tiles (MSAA4, 32x16 utiles) on this GPU.
max_tile_buffer: super::sizes::TILE_BUFFER_48K,
};

/// What iBoot writes into the 25G83 build b000 TEXT it loads, in TEXT order:
Expand Down Expand Up @@ -401,6 +407,7 @@ pub(crate) mod t6030 {
deep_sleep: false,
supports_render_scs: false,
cross_engine_hold: true,
max_tile_buffer: super::sizes::TILE_BUFFER_32K,
};

const LAYOUT: FwLayout = FwLayout {
Expand Down Expand Up @@ -541,6 +548,7 @@ pub(crate) mod t8122 {
deep_sleep: false,
supports_render_scs: false,
cross_engine_hold: true,
max_tile_buffer: super::sizes::TILE_BUFFER_32K,
};

/// 26B123 G15G: __TEXT 0x64000 as on G16G, __DATA 0xb4000 and the 0x8000 __DATA_SHARED_RO
Expand Down Expand Up @@ -1101,6 +1109,9 @@ pub(crate) mod client {

/// Sizes and counts of the engine's objects.
pub(crate) mod sizes {
/// Tile buffer limits of [`super::Config::max_tile_buffer`].
pub(crate) const TILE_BUFFER_32K: u32 = 32 * 1024;
pub(crate) const TILE_BUFFER_48K: u32 = 48 * 1024;
pub(crate) const POOLS: usize = 16;
pub(crate) const POOL_SIZE: u64 = 0x200000;
pub(crate) const FREELIST_SEED: u32 = 8192;
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/asahi/g16/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ pub(crate) fn fill(gpu: &Gpu, params: &mut uapi::drm_asahi_params_global) -> Res
} else {
0
}
| if gpu.cfg.max_tile_buffer >= hw::sizes::TILE_BUFFER_48K {
crate::file::DRM_ASAHI_FEATURE_TILE_BUFFER_48K
} else {
0
}
| crate::g17::sync_output::FEATURE_CUMULATIVE_SIGNALS
| crate::file::DRM_ASAHI_FEATURE_RENDER_STAGE_PREFIXES_V2;
params.gpu_generation = gpu.cfg.gpu_generation;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/asahi/g16/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ impl Queue {
usc_base: self.state.usc_base,
active_cores: self.active_cores,
render_scs: self.render_scs,
max_tile_buffer: self.cfg.max_tile_buffer,
},
&mut self.proof,
)?;
Expand Down
8 changes: 8 additions & 0 deletions include/uapi/drm/asahi_drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,14 @@ enum drm_asahi_feature {
*/
#define DRM_ASAHI_FEATURE_ORDERED_PARTIAL_RENDERS ((1ULL) << 45)

/*
* DRM_ASAHI_FEATURE_TILE_BUFFER_48K: render commands on this GPU accept tile
* buffers of up to 48 KiB (sample_size_B * utile_width_px * utile_height_px *
* samples <= 49152). Without it, 32 KiB is the portable limit. A feature bit
* like those of enum drm_asahi_feature, defined here like bit 32.
*/
#define DRM_ASAHI_FEATURE_TILE_BUFFER_48K ((1ULL) << 46)

#define DRM_ASAHI_PARAM_GROUP_VM_STATUS 1
#define DRM_ASAHI_PARAM_GROUP_QUEUE_LIMITS 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@
mod render_admission_tests {
use super::{
check_render_helpers, hw, uapi, Result, DBIAS_IS_INT, EINVAL, FEW_PRIMITIVES,
FRAGMENT_BARRIERS, MAX_DIMENSION, MAX_LAYERS, MAX_TILE_BUFFER, PROCESS_EMPTY_TILES,
FRAGMENT_BARRIERS, MAX_DIMENSION, MAX_LAYERS, PROCESS_EMPTY_TILES,
RSRC_SPEC_HI, STAGE_PREFIXES, ZLS_METADATA_STRIDE,
};
const ENOENT: i32 = -2;
Expand Down Expand Up @@ -700,6 +700,7 @@
pub(crate) usc_base: u64,
pub(crate) active_cores: u32,
pub(crate) render_scs: [u16; 2],
pub(crate) max_tile_buffer: u32,
}
use super::MAX_COMMANDS;
RENDER_ADMISSION
Expand Down Expand Up @@ -749,7 +750,7 @@
#[test]
fn compressed_zls_1x_layered_and_2x_accepted() {
let vm = base_vm();
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0] };
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0], max_tile_buffer: 32 * 1024 };
// 1x compressed D32F depth + stencil.
let mut cmd = base_cmd();
cmd.zls_ctrl = Z_COMP | S_COMP;
Expand Down Expand Up @@ -779,10 +780,32 @@
assert_eq!(check_render_one(&ctx, &layered, &[], &[]), Ok(()));
}

#[test]
fn tile_buffer_limit_follows_the_context() {
let vm = base_vm();
let k32 = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0], max_tile_buffer: 32 * 1024 };
let k48 = Context { max_tile_buffer: 48 * 1024, ..k32 };
// 8 B x 32x32 x 4 samples = 32 KiB: accepted by both.
let mut k32_tile = base_cmd();
k32_tile.samples = 4;
assert_eq!(check_render_one(&k32, &k32_tile, &[], &[]), Ok(()));
assert_eq!(check_render_one(&k48, &k32_tile, &[], &[]), Ok(()));
// 24 B x 32x16 x 4 samples = 48 KiB, the MSAA4 tile macOS programs on the M4.
let mut k48_tile = k32_tile;
k48_tile.utile_height_px = 16;
k48_tile.sample_size_B = 24;
assert_eq!(check_render_one(&k32, &k48_tile, &[], &[]), Err(EINVAL));
assert_eq!(check_render_one(&k48, &k48_tile, &[], &[]), Ok(()));
// 28 B x 32x16 x 4 samples = 56 KiB: over both limits.
let mut over = k48_tile;
over.sample_size_B = 28;
assert_eq!(check_render_one(&k48, &over, &[], &[]), Err(EINVAL));
}

#[test]
fn compressed_zls_invalid_ctrl_alignment_and_vm_spans_rejected() {
let vm = base_vm();
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0] };
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0], max_tile_buffer: 32 * 1024 };
let valid = || {
let mut cmd = base_cmd();
cmd.zls_ctrl = Z_COMP | S_COMP;
Expand Down Expand Up @@ -839,7 +862,7 @@
#[test]
fn submit_wide_span_batch_dedups_and_flushes_once_across_passes() {
let vm = base_vm();
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0] };
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0], max_tile_buffer: 32 * 1024 };
let mut batch = SpanBatch::new();
for pass in 0..4u64 {
let mut cmd = base_cmd();
Expand Down Expand Up @@ -879,7 +902,7 @@
#[test]
fn few_primitives_flag_admitted_in_parse_and_render_check() {
let vm = base_vm();
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0] };
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0], max_tile_buffer: 32 * 1024 };
let mut r = super::render();
r.flags = FEW_PRIMITIVES;
assert!(super::check_stream(
Expand Down Expand Up @@ -916,7 +939,7 @@

// First flush populates the proof for epoch 1.
let mut batch = SpanBatch::new();
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0] };
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0], max_tile_buffer: 32 * 1024 };
check_render(&mut batch, &ctx, &cmd, &[], &[]).unwrap();
assert_eq!(batch.flush_with_proof(&vm, &mut proof), Ok(()));
assert_eq!(vm.batch_calls.get(), 1);
Expand Down Expand Up @@ -962,7 +985,7 @@
vm.maps.remove(1);
vm.epoch.set(Some(2));
let mut batch = SpanBatch::new();
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0] };
let ctx = Context { vm: &vm, usc_base: 1 << 40, active_cores: 10, render_scs: [0, 0], max_tile_buffer: 32 * 1024 };
check_render(&mut batch, &ctx, &cmd, &[att], &[]).unwrap();
assert_eq!(batch.flush_with_proof(&vm, &mut proof), Err(ENOENT));

Expand Down
Loading