anv: Increase max VBs to 33 on Gen11+

Prior to Gen 11, we had to upload a bunch of SGVs
(FirstVertex, BaseVertex, BaseInstance, DrawID) via
3DSTATE_VERTEX_BUFFERS.

For Gen11+, we upload via 3DSTATE_SGVS_2 instead.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35376>
(cherry picked from commit 111005066d)
This commit is contained in:
Caleb Callaway 2025-06-05 00:31:47 +00:00 committed by Eric Engestrom
parent 6b39d86847
commit beab312508
5 changed files with 25 additions and 11 deletions

View file

@ -22504,7 +22504,7 @@
"description": "anv: Increase max VBs to 33 on Gen11+",
"nominated": false,
"nomination_type": 0,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -1082,7 +1082,7 @@ void anv_CmdBindVertexBuffers2(
/* We have to defer setting up vertex buffer since we need the buffer
* stride from the pipeline. */
assert(firstBinding + bindingCount <= MAX_VBS);
assert(firstBinding + bindingCount <= get_max_vbs(cmd_buffer->device->info));
for (uint32_t i = 0; i < bindingCount; i++) {
ANV_FROM_HANDLE(anv_buffer, buffer, pBuffers[i]);

View file

@ -1276,7 +1276,7 @@ get_properties(const struct anv_physical_device *pdevice,
.maxDescriptorSetStorageImages = desc_limits.max_images,
.maxDescriptorSetInputAttachments = MAX_DESCRIPTOR_SET_INPUT_ATTACHMENTS,
.maxVertexInputAttributes = MAX_VES,
.maxVertexInputBindings = MAX_VBS,
.maxVertexInputBindings = get_max_vbs(devinfo),
/* Broadwell PRMs: Volume 2d: Command Reference: Structures:
*
* VERTEX_ELEMENT_STATE::Source Element Offset: [0,2047]

View file

@ -158,8 +158,14 @@ struct intel_perf_query_result;
#define BINDING_TABLE_POOL_BLOCK_SIZE (65536)
/* 3DSTATE_VERTEX_BUFFER supports 33 VBs, we use 2 for base & drawid SGVs */
#define MAX_VBS (33 - 2)
#define HW_MAX_VBS 33
/* 3DSTATE_VERTEX_BUFFER supports 33 VBs, but before Gen11 we used 2
* for base & drawid SGVs */
static inline int
get_max_vbs(const struct intel_device_info *devinfo) {
return devinfo->ver >= 11 ? HW_MAX_VBS : (HW_MAX_VBS - 2);
}
/* 3DSTATE_VERTEX_ELEMENTS supports up to 34 VEs, but our backend compiler
* only supports the push model of VS inputs, and we only have 128 GRFs,
@ -210,8 +216,11 @@ struct intel_perf_query_result;
*/
#define MAX_BINDING_TABLE_SIZE 240
#define ANV_SVGS_VB_INDEX MAX_VBS
#define ANV_DRAWID_VB_INDEX (MAX_VBS + 1)
/* 3DSTATE_VERTEX_BUFFER supports 33 VBs, but these limits are applied on Gen9
* graphics, where 2 VBs are reserved for base & drawid SGVs.
*/
#define ANV_SVGS_VB_INDEX (HW_MAX_VBS - 2)
#define ANV_DRAWID_VB_INDEX (ANV_SVGS_VB_INDEX + 1)
/* We reserve this MI ALU register for the purpose of handling predication.
* Other code which uses the MI ALU should leave it alone.
@ -4031,8 +4040,8 @@ struct anv_cmd_graphics_state {
struct anv_vb_cache_range ib_bound_range;
struct anv_vb_cache_range ib_dirty_range;
struct anv_vb_cache_range vb_bound_ranges[33];
struct anv_vb_cache_range vb_dirty_ranges[33];
struct anv_vb_cache_range vb_bound_ranges[HW_MAX_VBS];
struct anv_vb_cache_range vb_dirty_ranges[HW_MAX_VBS];
uint32_t restart_index;
@ -4192,7 +4201,12 @@ struct anv_cmd_state {
uint64_t address[MAX_SETS];
} descriptor_buffers;
struct anv_vertex_binding vertex_bindings[MAX_VBS];
/* For Gen 9, this allocation is 2 greater than the maximum allowed
* number of vertex buffers; see comment on get_max_vbs definition.
* Specializing this allocation seems needlessly complicated when we can
* enforce the VB limit elsewhere.
*/
struct anv_vertex_binding vertex_bindings[HW_MAX_VBS];
bool xfb_enabled;
struct anv_xfb_binding xfb_bindings[MAX_XFB_BUFFERS];
struct anv_state binding_tables[MESA_VULKAN_SHADER_STAGES];

View file

@ -220,7 +220,7 @@ emit_ves_vf_instancing(struct anv_batch *batch,
assume(format < ISL_NUM_FORMATS);
uint32_t binding = vi->attributes[a].binding;
assert(binding < MAX_VBS);
assert(binding < get_max_vbs(device->info));
if ((elements & (1 << a)) == 0)
continue; /* Binding unused */