svga: Replace shared surface flag and simplify surface creation

The shared flag vmw_svga_winsys_surface was used to create shareable surfaces
and these surfaces are not discarded.
Since all surfaces created right now are shareable, there is no need for this
flag except to mark surfaces which should not be discarded. Renaming it to
nodiscard accordingly.
This also simplifies surface creation.

Signed-off-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Reviewed-by: Martin Krastev <martin.krastev@broadcom.com>
Reviewed-by: Ian Forbes <ian.forbes@broadcom.com>
Reviewed-by: Jose Fonseca <jose.fonseca@broadcom.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29948>
This commit is contained in:
Maaz Mombasawala 2024-02-14 14:36:35 -08:00 committed by Marge Bot
parent 8b8f347e4b
commit 8b756a0d0e
3 changed files with 18 additions and 62 deletions

View file

@ -486,8 +486,8 @@ vmw_svga_winsys_surface_create(struct svga_winsys_screen *sws,
p_atomic_set(&surface->validated, 0);
surface->screen = vws;
(void) mtx_init(&surface->mutex, mtx_plain);
surface->shared = !!(usage & SVGA_SURFACE_USAGE_SHARED);
provider = (surface->shared) ? vws->pools.dma_base : vws->pools.dma_fenced;
surface->nodiscard = !!(usage & SVGA_SURFACE_USAGE_SHARED);
provider = (surface->nodiscard) ? vws->pools.dma_base : vws->pools.dma_fenced;
/*
* When multisampling is not supported sample count received is 0,
@ -517,75 +517,31 @@ vmw_svga_winsys_surface_create(struct svga_winsys_screen *sws,
}
if (sws->have_gb_objects) {
SVGAGuestPtr ptr = {0,0};
/*
* If the backing buffer size is small enough, try to allocate a
* buffer out of the buffer cache. Otherwise, let the kernel allocate
* a suitable buffer for us.
*/
if (buffer_size < VMW_TRY_CACHED_SIZE && !surface->shared) {
struct pb_buffer *pb_buf;
surface->size = buffer_size;
desc.pb_desc.alignment = 4096;
desc.pb_desc.usage = 0;
pb_buf = provider->create_buffer(provider, buffer_size, &desc.pb_desc);
surface->buf = vmw_svga_winsys_buffer_wrap(pb_buf);
if (surface->buf && !vmw_dma_bufmgr_region_ptr(pb_buf, &ptr))
assert(0);
}
struct pb_buffer *pb_buf;
surface->sid = vmw_ioctl_gb_surface_create(vws, flags, format, usage,
size, numLayers,
numMipLevels, sampleCount,
ptr.gmrId,
numMipLevels, sampleCount, 0,
multisample_pattern,
quality_level,
surface->buf ? NULL :
&desc.region);
if (surface->sid == SVGA3D_INVALID_ID) {
if (surface->buf == NULL) {
goto no_sid;
} else {
/*
* Kernel refused to allocate a surface for us.
* Perhaps something was wrong with our buffer?
* This is really a guard against future new size requirements
* on the backing buffers.
*/
vmw_svga_winsys_buffer_destroy(sws, surface->buf);
surface->buf = NULL;
surface->sid = vmw_ioctl_gb_surface_create(vws, flags, format, usage,
size, numLayers,
numMipLevels, sampleCount,
0, multisample_pattern,
quality_level,
&desc.region);
if (surface->sid == SVGA3D_INVALID_ID)
goto no_sid;
}
}
if (surface->sid == SVGA3D_INVALID_ID)
goto no_sid;
/*
* If the kernel created the buffer for us, wrap it into a
* The kernel created the buffer for us, wrap it into a
* vmw_svga_winsys_buffer.
*/
surface->size = vmw_region_size(desc.region);
desc.pb_desc.alignment = 4096;
desc.pb_desc.usage = VMW_BUFFER_USAGE_SHARED;
pb_buf = provider->create_buffer(provider, surface->size,
&desc.pb_desc);
surface->buf = vmw_svga_winsys_buffer_wrap(pb_buf);
if (surface->buf == NULL) {
struct pb_buffer *pb_buf;
surface->size = vmw_region_size(desc.region);
desc.pb_desc.alignment = 4096;
desc.pb_desc.usage = VMW_BUFFER_USAGE_SHARED;
pb_buf = provider->create_buffer(provider, surface->size,
&desc.pb_desc);
surface->buf = vmw_svga_winsys_buffer_wrap(pb_buf);
if (surface->buf == NULL) {
vmw_ioctl_region_destroy(desc.region);
vmw_ioctl_surface_destroy(vws, surface->sid);
goto no_sid;
}
vmw_ioctl_region_destroy(desc.region);
vmw_ioctl_surface_destroy(vws, surface->sid);
goto no_sid;
}
} else {
/* Legacy surface only support 32-bit svga3d flags */

View file

@ -108,7 +108,7 @@ vmw_svga_winsys_surface_map(struct svga_winsys_context *swc,
* If we intend to read, there's no point discarding the
* data if busy.
*/
if (flags & PIPE_MAP_READ || vsrf->shared)
if (flags & PIPE_MAP_READ || vsrf->nodiscard)
flags &= ~PIPE_MAP_DISCARD_WHOLE_RESOURCE;
/*

View file

@ -44,7 +44,7 @@ struct vmw_svga_winsys_surface
uint32_t mapcount; /* Number of mappers */
uint32_t map_mode; /* PIPE_MAP_[READ|WRITE] */
void *data; /* Pointer to data if mapcount != 0*/
bool shared; /* Shared surface. Never discard */
bool nodiscard; /* Never discard */
uint32_t size; /* Size of backing buffer */
bool rebind; /* Surface needs a rebind after next unmap */
};