mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-04 08:48:14 +02:00
v3d: sub-allocate sampler view texture state from state uploader
Previously, each sampler view allocated a dedicated BO for its, TEXTURE_SHADER_STATE packet (~24 bytes), which got rounded up to a full 4KB page. This wastes memory and inflates the per-job BO handle count. Use u_upload_alloc_ref() to sub-allocate texture shader state from the shared state_uploader, matching the pattern already used by image views. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Signed-off-by: Maíra Canal <mcanal@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40496>
This commit is contained in:
parent
751e0d26ec
commit
bfe92d50ce
3 changed files with 9 additions and 7 deletions
|
|
@ -173,7 +173,8 @@ struct v3d_sampler_view {
|
|||
|
||||
uint8_t texture_shader_state[32];
|
||||
/* V3D 4.x: Texture state struct. */
|
||||
struct v3d_bo *bo;
|
||||
struct pipe_resource *tex_state;
|
||||
uint32_t tex_state_offset;
|
||||
|
||||
enum v3d_sampler_state_variant sampler_variant;
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,9 @@ write_tmu_p0(struct v3d_job *job,
|
|||
|
||||
struct v3d_resource *rsc = v3d_resource(sview->texture);
|
||||
|
||||
cl_aligned_reloc(&job->indirect, uniforms, sview->bo,
|
||||
cl_aligned_reloc(&job->indirect, uniforms,
|
||||
v3d_resource(sview->tex_state)->bo,
|
||||
sview->tex_state_offset |
|
||||
v3d_unit_data_get_offset(data));
|
||||
v3d_job_add_bo(job, rsc->bo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -993,10 +993,9 @@ v3dX(create_texture_shader_state_bo)(struct v3d_context *v3d,
|
|||
|
||||
assert(so->serial_id != rsc->serial_id);
|
||||
|
||||
v3d_bo_unreference(&so->bo);
|
||||
so->bo = v3d_bo_alloc(v3d->screen,
|
||||
cl_packet_length(TEXTURE_SHADER_STATE), "sampler");
|
||||
map = v3d_bo_map(so->bo);
|
||||
u_upload_alloc_ref(v3d->state_uploader, 0,
|
||||
cl_packet_length(TEXTURE_SHADER_STATE), 32,
|
||||
&so->tex_state_offset, &so->tex_state, &map);
|
||||
|
||||
v3dx_pack(map, TEXTURE_SHADER_STATE, tex) {
|
||||
if (prsc->target != PIPE_BUFFER) {
|
||||
|
|
@ -1194,7 +1193,7 @@ v3d_sampler_view_destroy(struct pipe_context *pctx,
|
|||
{
|
||||
struct v3d_sampler_view *sview = v3d_sampler_view(psview);
|
||||
|
||||
v3d_bo_unreference(&sview->bo);
|
||||
pipe_resource_reference(&sview->tex_state, NULL);
|
||||
pipe_resource_reference(&psview->texture, NULL);
|
||||
pipe_resource_reference(&sview->texture, NULL);
|
||||
free(psview);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue