mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 09:20:13 +01:00
svga: update svga_winsys interface for GBS
This adds new interface functions for guest-backed surfaces and adds a mobid parameter to the surface_relocation() function. Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Cc: "10.1" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
parent
024711385e
commit
d993ada50c
6 changed files with 141 additions and 13 deletions
|
|
@ -62,12 +62,12 @@ surface_to_surfaceid(struct svga_winsys_context *swc, // IN
|
|||
{
|
||||
if (surface) {
|
||||
struct svga_surface *s = svga_surface(surface);
|
||||
swc->surface_relocation(swc, &id->sid, s->handle, flags);
|
||||
swc->surface_relocation(swc, &id->sid, NULL, s->handle, flags);
|
||||
id->face = s->real_face; /* faces have the same order */
|
||||
id->mipmap = s->real_level;
|
||||
}
|
||||
else {
|
||||
swc->surface_relocation(swc, &id->sid, NULL, flags);
|
||||
swc->surface_relocation(swc, &id->sid, NULL, NULL, flags);
|
||||
id->face = 0;
|
||||
id->mipmap = 0;
|
||||
}
|
||||
|
|
@ -280,7 +280,7 @@ SVGA3D_BeginDefineSurface(struct svga_winsys_context *swc,
|
|||
if (!cmd)
|
||||
return PIPE_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
swc->surface_relocation(swc, &cmd->sid, sid, SVGA_RELOC_WRITE);
|
||||
swc->surface_relocation(swc, &cmd->sid, NULL, sid, SVGA_RELOC_WRITE);
|
||||
cmd->surfaceFlags = flags;
|
||||
cmd->format = format;
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ SVGA3D_DestroySurface(struct svga_winsys_context *swc,
|
|||
if (!cmd)
|
||||
return PIPE_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
swc->surface_relocation(swc, &cmd->sid, sid, SVGA_RELOC_READ);
|
||||
swc->surface_relocation(swc, &cmd->sid, NULL, sid, SVGA_RELOC_READ);
|
||||
swc->commit(swc);;
|
||||
|
||||
return PIPE_OK;
|
||||
|
|
@ -453,7 +453,8 @@ SVGA3D_SurfaceDMA(struct svga_winsys_context *swc,
|
|||
swc->region_relocation(swc, &cmd->guest.ptr, st->hwbuf, 0, region_flags);
|
||||
cmd->guest.pitch = st->base.stride;
|
||||
|
||||
swc->surface_relocation(swc, &cmd->host.sid, texture->handle, surface_flags);
|
||||
swc->surface_relocation(swc, &cmd->host.sid, NULL,
|
||||
texture->handle, surface_flags);
|
||||
cmd->host.face = st->face; /* PIPE_TEX_FACE_* and SVGA3D_CUBEFACE_* match */
|
||||
cmd->host.mipmap = st->base.level;
|
||||
|
||||
|
|
@ -511,7 +512,8 @@ SVGA3D_BufferDMA(struct svga_winsys_context *swc,
|
|||
swc->region_relocation(swc, &cmd->guest.ptr, guest, 0, region_flags);
|
||||
cmd->guest.pitch = 0;
|
||||
|
||||
swc->surface_relocation(swc, &cmd->host.sid, host, surface_flags);
|
||||
swc->surface_relocation(swc, &cmd->host.sid,
|
||||
NULL, host, surface_flags);
|
||||
cmd->host.face = 0;
|
||||
cmd->host.mipmap = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ svga_hwtnl_flush(struct svga_hwtnl *hwtnl)
|
|||
vdecl[i].rangeHint.last = 0;
|
||||
}
|
||||
|
||||
swc->surface_relocation(swc, &vdecl[i].array.surfaceId,
|
||||
swc->surface_relocation(swc, &vdecl[i].array.surfaceId, NULL,
|
||||
vb_handle[i], SVGA_RELOC_READ);
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ svga_hwtnl_flush(struct svga_hwtnl *hwtnl)
|
|||
hwtnl->cmd.prim_count * sizeof hwtnl->cmd.prim[0]);
|
||||
|
||||
for (i = 0; i < hwtnl->cmd.prim_count; i++) {
|
||||
swc->surface_relocation(swc, &prim[i].indexArray.surfaceId,
|
||||
swc->surface_relocation(swc, &prim[i].indexArray.surfaceId, NULL,
|
||||
ib_handle[i], SVGA_RELOC_READ);
|
||||
pipe_resource_reference(&hwtnl->cmd.prim_ib[i], NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ svga_buffer_upload_command(struct svga_context *svga,
|
|||
swc->region_relocation(swc, &cmd->guest.ptr, guest, 0, region_flags);
|
||||
cmd->guest.pitch = 0;
|
||||
|
||||
swc->surface_relocation(swc, &cmd->host.sid, host, surface_flags);
|
||||
swc->surface_relocation(swc, &cmd->host.sid, NULL, host, surface_flags);
|
||||
cmd->host.face = 0;
|
||||
cmd->host.mipmap = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ update_tss_binding(struct svga_context *svga,
|
|||
}
|
||||
svga->swc->surface_relocation(svga->swc,
|
||||
&ts[i].value,
|
||||
NULL,
|
||||
handle,
|
||||
SVGA_RELOC_READ);
|
||||
|
||||
|
|
@ -220,6 +221,7 @@ svga_reemit_tss_bindings(struct svga_context *svga)
|
|||
handle = queue.bind[i].view->v->handle;
|
||||
svga->swc->surface_relocation(svga->swc,
|
||||
&ts[i].value,
|
||||
NULL,
|
||||
handle,
|
||||
SVGA_RELOC_READ);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,18 +56,39 @@ struct winsys_handle;
|
|||
|
||||
#define SVGA_BUFFER_USAGE_PINNED (1 << 0)
|
||||
#define SVGA_BUFFER_USAGE_WRAPPED (1 << 1)
|
||||
#define SVGA_BUFFER_USAGE_SHADER (1 << 2)
|
||||
|
||||
|
||||
#define SVGA_RELOC_WRITE 0x1
|
||||
#define SVGA_RELOC_READ 0x2
|
||||
/**
|
||||
* Relocation flags to help with dirty tracking
|
||||
* SVGA_RELOC_WRITE - The command will cause a GPU write to this
|
||||
* resource.
|
||||
* SVGA_RELOC_READ - The command will cause a GPU read from this
|
||||
* resource.
|
||||
* SVGA_RELOC_INTERNAL The command will only transfer data internally
|
||||
* within the resource, and optionally clear
|
||||
* dirty bits
|
||||
* SVGA_RELOC_DMA - Only set for resource buffer DMA uploads for winsys
|
||||
* implementations that want to track the amount
|
||||
* of such data referenced in the command stream.
|
||||
*/
|
||||
#define SVGA_RELOC_WRITE (1 << 0)
|
||||
#define SVGA_RELOC_READ (1 << 1)
|
||||
#define SVGA_RELOC_INTERNAL (1 << 2)
|
||||
#define SVGA_RELOC_DMA (1 << 3)
|
||||
|
||||
#define SVGA_FENCE_FLAG_EXEC (1 << 0)
|
||||
#define SVGA_FENCE_FLAG_QUERY (1 << 1)
|
||||
|
||||
|
||||
/** Opaque surface handle */
|
||||
struct svga_winsys_surface;
|
||||
|
||||
|
||||
/** Opaque guest-backed objects */
|
||||
struct svga_winsys_gb_shader;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SVGA per-context winsys interface.
|
||||
*/
|
||||
|
|
@ -90,7 +111,8 @@ struct svga_winsys_context
|
|||
*/
|
||||
void
|
||||
(*surface_relocation)(struct svga_winsys_context *swc,
|
||||
uint32 *sid,
|
||||
uint32 *sid,
|
||||
uint32 *mobid,
|
||||
struct svga_winsys_surface *surface,
|
||||
unsigned flags);
|
||||
|
||||
|
|
@ -109,6 +131,47 @@ struct svga_winsys_context
|
|||
uint32 offset,
|
||||
unsigned flags);
|
||||
|
||||
/**
|
||||
* Emit a relocation for a guest-backed shader object.
|
||||
*
|
||||
* NOTE: Order of this call does matter. It should be the same order
|
||||
* as relocations appear in the command buffer.
|
||||
*/
|
||||
void
|
||||
(*shader_relocation)(struct svga_winsys_context *swc,
|
||||
uint32 *shid,
|
||||
uint32 *mobid,
|
||||
uint32 *offset,
|
||||
struct svga_winsys_gb_shader *shader);
|
||||
|
||||
/**
|
||||
* Emit a relocation for a guest-backed context.
|
||||
*
|
||||
* NOTE: Order of this call does matter. It should be the same order
|
||||
* as relocations appear in the command buffer.
|
||||
*/
|
||||
void
|
||||
(*context_relocation)(struct svga_winsys_context *swc, uint32 *cid);
|
||||
|
||||
/**
|
||||
* Emit a relocation for a guest Memory OBject.
|
||||
*
|
||||
* @param flags bitmask of SVGA_RELOC_* flags
|
||||
* @param offset_into_mob Buffer starts at this offset into the MOB.
|
||||
*
|
||||
* Note that not all commands accept an offset into the MOB and
|
||||
* those commands can't use suballocated buffer pools. To trap
|
||||
* errors from improper buffer pool usage, set the offset_into_mob
|
||||
* pointer to NULL.
|
||||
*/
|
||||
void
|
||||
(*mob_relocation)(struct svga_winsys_context *swc,
|
||||
SVGAMobId *id,
|
||||
uint32 *offset_into_mob,
|
||||
struct svga_winsys_buffer *buffer,
|
||||
uint32 offset,
|
||||
unsigned flags);
|
||||
|
||||
void
|
||||
(*commit)(struct svga_winsys_context *swc);
|
||||
|
||||
|
|
@ -123,6 +186,38 @@ struct svga_winsys_context
|
|||
* global to the entire SVGA device.
|
||||
*/
|
||||
uint32 cid;
|
||||
|
||||
/**
|
||||
** BEGIN new functions for guest-backed surfaces.
|
||||
**/
|
||||
|
||||
boolean have_gb_objects;
|
||||
|
||||
/**
|
||||
* Map a guest-backed surface.
|
||||
* \param flags bitmaks of PIPE_TRANSFER_x flags
|
||||
*
|
||||
* The surface_map() member is allowed to fail due to a
|
||||
* shortage of command buffer space, if the
|
||||
* PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE bit is set in flags.
|
||||
* In that case, the caller must flush the current command
|
||||
* buffer and reissue the map.
|
||||
*/
|
||||
void *
|
||||
(*surface_map)(struct svga_winsys_context *swc,
|
||||
struct svga_winsys_surface *surface,
|
||||
unsigned flags, boolean *retry);
|
||||
|
||||
/**
|
||||
* Unmap a guest-backed surface.
|
||||
* \param rebind returns a flag indicating whether the caller should
|
||||
* issue a SVGA3D_BindGBSurface() call.
|
||||
*/
|
||||
void
|
||||
(*surface_unmap)(struct svga_winsys_context *swc,
|
||||
struct svga_winsys_surface *surface,
|
||||
boolean *rebind);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -286,6 +381,34 @@ struct svga_winsys_screen
|
|||
struct pipe_fence_handle *fence,
|
||||
unsigned flag );
|
||||
|
||||
|
||||
/**
|
||||
** BEGIN new functions for guest-backed surfaces.
|
||||
**/
|
||||
|
||||
/** Are guest-backed objects enabled? */
|
||||
bool have_gb_objects;
|
||||
|
||||
/** Can we do DMA with guest-backed objects enabled? */
|
||||
bool have_gb_dma;
|
||||
|
||||
/**
|
||||
* Create and define a GB shader.
|
||||
*/
|
||||
struct svga_winsys_gb_shader *
|
||||
(*shader_create)(struct svga_winsys_screen *sws,
|
||||
SVGA3dShaderType type,
|
||||
const uint32 *bytecode,
|
||||
uint32 bytecodeLen);
|
||||
|
||||
/**
|
||||
* Destroy a GB shader. It's safe to call this function even
|
||||
* if the shader is referenced in a context's command stream.
|
||||
*/
|
||||
void
|
||||
(*shader_destroy)(struct svga_winsys_screen *sws,
|
||||
struct svga_winsys_gb_shader *shader);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -245,6 +245,7 @@ vmw_swc_reserve(struct svga_winsys_context *swc,
|
|||
static void
|
||||
vmw_swc_surface_relocation(struct svga_winsys_context *swc,
|
||||
uint32 *where,
|
||||
uint32 *mobid,
|
||||
struct svga_winsys_surface *surface,
|
||||
unsigned flags)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue