diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 123dc6dba7b..a3f0d172781 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -2940,14 +2940,6 @@ fs_visitor::allocate_registers(bool allow_spilling) debug_optimizer(nir, "lowered_vgrfs_to_fixed_grfs", 96, 3); if (last_scratch > 0) { - ASSERTED unsigned max_scratch_size = 2 * 1024 * 1024; - - /* Take the max of any previously compiled variant of the shader. In the - * case of bindless shaders with return parts, this will also take the - * max of all parts. - */ - prog_data->total_scratch = MAX2(brw_get_scratch_size(last_scratch), - prog_data->total_scratch); /* We currently only support up to 2MB of scratch space. If we * need to support more eventually, the documentation suggests @@ -2959,9 +2951,21 @@ fs_visitor::allocate_registers(bool allow_spilling) * See 3D-Media-GPGPU Engine > Media GPGPU Pipeline > * Thread Group Tracking > Local Memory/Scratch Space. */ - assert(prog_data->total_scratch < max_scratch_size); + if (last_scratch <= devinfo->max_scratch_size_per_thread) { + /* Take the max of any previously compiled variant of the shader. In the + * case of bindless shaders with return parts, this will also take the + * max of all parts. + */ + prog_data->total_scratch = MAX2(brw_get_scratch_size(last_scratch), + prog_data->total_scratch); + } else { + fail("Scratch space required is larger than supported"); + } } + if (failed) + return; + brw_fs_lower_scoreboard(*this); } diff --git a/src/intel/dev/intel_device_info.c b/src/intel/dev/intel_device_info.c index f8eca0cca85..c0f87653eaf 100644 --- a/src/intel/dev/intel_device_info.c +++ b/src/intel/dev/intel_device_info.c @@ -1615,6 +1615,20 @@ intel_device_info_init_common(int pci_id, bool building, devinfo->max_constant_urb_size_kb / 2; } + /* + * Gfx 12.5 moved scratch to a surface and SURFTYPE_SCRATCH has this pitch + * restriction: + * + * BSpec 43862 (r52666) + * RENDER_SURFACE_STATE::Surface Pitch + * For surfaces of type SURFTYPE_SCRATCH, valid range of pitch is: + * [63,262143] -> [64B, 256KB] + * + * The pitch of the surface is the scratch size per thread and the surface + * should be large enough to accommodate every physical thread. + */ + devinfo->max_scratch_size_per_thread = devinfo->verx10 >= 125 ? + (256 * 1024) : (2 * 1024 * 1024); intel_device_info_update_cs_workgroup_threads(devinfo); return true; diff --git a/src/intel/dev/intel_device_info.py b/src/intel/dev/intel_device_info.py index 39d42edb9c7..0f0bec49b7b 100644 --- a/src/intel/dev/intel_device_info.py +++ b/src/intel/dev/intel_device_info.py @@ -467,6 +467,8 @@ Struct("intel_device_info", implementation details, the range of scratch ids may be larger than the number of subslices.""")), + Member("uint32_t", "max_scratch_size_per_thread", compiler_field=True), + Member("intel_device_info_urb_desc", "urb"), Member("unsigned", "max_constant_urb_size_kb"), Member("unsigned", "mesh_max_constant_urb_size_kb"),