* Can handle null surface. Does a surface_reallocation so you need
* to have allocated the fifo space before converting.
*
+ *
+ * param flags mask of SVGA_RELOC_READ / _WRITE
+ *
* Results:
* id is filled out.
*
*----------------------------------------------------------------------
*/
-static INLINE void
+static inline void
surface_to_surfaceid(struct svga_winsys_context *swc, // IN
struct pipe_surface *surface, // IN
SVGA3dSurfaceImageId *id, // OUT
{
if (surface) {
struct svga_surface *s = svga_surface(surface);
- swc->surface_relocation(swc, &id->sid, s->handle, flags);
- id->face = s->real_face; /* faces have the same order */
+ swc->surface_relocation(swc, &id->sid, NULL, s->handle, flags);
+ id->face = s->real_layer; /* 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;
}
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 | SVGA_RELOC_INTERNAL);
cmd->surfaceFlags = flags;
cmd->format = format;
mipSizes[0].height = height;
mipSizes[0].depth = 1;
- swc->commit(swc);;
+ swc->commit(swc);
return PIPE_OK;
}
SVGA_3D_CMD_SURFACE_DESTROY, sizeof *cmd, 1);
if (!cmd)
return PIPE_ERROR_OUT_OF_MEMORY;
-
- swc->surface_relocation(swc, &cmd->sid, sid, SVGA_RELOC_READ);
- swc->commit(swc);;
+
+ swc->surface_relocation(swc, &cmd->sid, NULL, sid,
+ SVGA_RELOC_WRITE | SVGA_RELOC_INTERNAL);
+ swc->commit(swc);
return PIPE_OK;
}
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);
- cmd->host.face = st->face; /* PIPE_TEX_FACE_* and SVGA3D_CUBEFACE_* match */
+ swc->surface_relocation(swc, &cmd->host.sid, NULL,
+ texture->handle, surface_flags);
+ cmd->host.face = st->slice; /* PIPE_TEX_FACE_* and SVGA3D_CUBEFACE_* match */
cmd->host.mipmap = st->base.level;
cmd->transfer = transfer;
pSuffix->flags = flags;
swc->commit(swc);
+ swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
return PIPE_OK;
}
SVGA3dCmdSurfaceDMASuffix *pSuffix;
unsigned region_flags;
unsigned surface_flags;
+
+ assert(!swc->have_gb_objects);
if (transfer == SVGA3D_WRITE_HOST_VRAM) {
region_flags = SVGA_RELOC_READ;
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;
pSuffix->flags = flags;
swc->commit(swc);
+ swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
return PIPE_OK;
}
{
SVGA3dCmdSetShader *cmd;
+ assert(type == SVGA3D_SHADERTYPE_VS || type == SVGA3D_SHADERTYPE_PS);
+
cmd = SVGA3D_FIFOReserve(swc,
SVGA_3D_CMD_SET_SHADER, sizeof *cmd,
0);
*decls = declArray;
*ranges = rangeArray;
+ swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
+
return PIPE_OK;
}
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_BeginGBQuery--
+ *
+ * GB resource version of SVGA3D_BeginQuery.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Commits space in the FIFO memory.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static enum pipe_error
+SVGA3D_BeginGBQuery(struct svga_winsys_context *swc,
+ SVGA3dQueryType type) // IN
+{
+ SVGA3dCmdBeginGBQuery *cmd;
+
+ cmd = SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_BEGIN_GB_QUERY,
+ sizeof *cmd,
+ 1);
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ cmd->cid = swc->cid;
+ cmd->type = type;
+
+ swc->commit(swc);
+
+ return PIPE_OK;
+}
+
+
/*
*----------------------------------------------------------------------
*
{
SVGA3dCmdBeginQuery *cmd;
+ if (swc->have_gb_objects)
+ return SVGA3D_BeginGBQuery(swc, type);
+
cmd = SVGA3D_FIFOReserve(swc,
SVGA_3D_CMD_BEGIN_QUERY,
sizeof *cmd,
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_EndGBQuery--
+ *
+ * GB resource version of SVGA3D_EndQuery.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Commits space in the FIFO memory.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static enum pipe_error
+SVGA3D_EndGBQuery(struct svga_winsys_context *swc,
+ SVGA3dQueryType type, // IN
+ struct svga_winsys_buffer *buffer) // IN/OUT
+{
+ SVGA3dCmdEndGBQuery *cmd;
+
+ cmd = SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_END_GB_QUERY,
+ sizeof *cmd,
+ 2);
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ cmd->cid = swc->cid;
+ cmd->type = type;
+
+ swc->mob_relocation(swc, &cmd->mobid, &cmd->offset, buffer,
+ 0, SVGA_RELOC_READ | SVGA_RELOC_WRITE);
+
+ swc->commit(swc);
+
+ return PIPE_OK;
+}
+
+
/*
*----------------------------------------------------------------------
*
{
SVGA3dCmdEndQuery *cmd;
+ if (swc->have_gb_objects)
+ return SVGA3D_EndGBQuery(swc, type, buffer);
+
cmd = SVGA3D_FIFOReserve(swc,
SVGA_3D_CMD_END_QUERY,
sizeof *cmd,
cmd->type = type;
swc->region_relocation(swc, &cmd->guestResult, buffer, 0,
- SVGA_RELOC_WRITE);
+ SVGA_RELOC_READ | SVGA_RELOC_WRITE);
+
+ swc->commit(swc);
+
+ return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_WaitForGBQuery--
+ *
+ * GB resource version of SVGA3D_WaitForQuery.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Commits space in the FIFO memory.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static enum pipe_error
+SVGA3D_WaitForGBQuery(struct svga_winsys_context *swc,
+ SVGA3dQueryType type, // IN
+ struct svga_winsys_buffer *buffer) // IN/OUT
+{
+ SVGA3dCmdWaitForGBQuery *cmd;
+
+ cmd = SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_WAIT_FOR_GB_QUERY,
+ sizeof *cmd,
+ 2);
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ cmd->cid = swc->cid;
+ cmd->type = type;
+
+ swc->mob_relocation(swc, &cmd->mobid, &cmd->offset, buffer,
+ 0, SVGA_RELOC_READ | SVGA_RELOC_WRITE);
swc->commit(swc);
{
SVGA3dCmdWaitForQuery *cmd;
+ if (swc->have_gb_objects)
+ return SVGA3D_WaitForGBQuery(swc, type, buffer);
+
cmd = SVGA3D_FIFOReserve(swc,
SVGA_3D_CMD_WAIT_FOR_QUERY,
sizeof *cmd,
cmd->type = type;
swc->region_relocation(swc, &cmd->guestResult, buffer, 0,
- SVGA_RELOC_WRITE);
+ SVGA_RELOC_READ | SVGA_RELOC_WRITE);
+
+ swc->commit(swc);
+
+ return PIPE_OK;
+}
+
+
+enum pipe_error
+SVGA3D_BindGBShader(struct svga_winsys_context *swc,
+ struct svga_winsys_gb_shader *gbshader)
+{
+ SVGA3dCmdBindGBShader *cmd =
+ SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_BIND_GB_SHADER,
+ sizeof *cmd,
+ 2); /* two relocations */
+
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ swc->shader_relocation(swc, &cmd->shid, &cmd->mobid,
+ &cmd->offsetInBytes, gbshader, 0);
+
+ swc->commit(swc);
+
+ return PIPE_OK;
+}
+
+
+enum pipe_error
+SVGA3D_SetGBShader(struct svga_winsys_context *swc,
+ SVGA3dShaderType type, // IN
+ struct svga_winsys_gb_shader *gbshader)
+{
+ SVGA3dCmdSetShader *cmd;
+
+ assert(type == SVGA3D_SHADERTYPE_VS || type == SVGA3D_SHADERTYPE_PS);
+
+ cmd = SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_SET_SHADER,
+ sizeof *cmd,
+ 2); /* two relocations */
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ cmd->cid = swc->cid;
+ cmd->type = type;
+ if (gbshader)
+ swc->shader_relocation(swc, &cmd->shid, NULL, NULL, gbshader, 0);
+ else
+ cmd->shid = SVGA_ID_INVALID;
+ swc->commit(swc);
+
+ return PIPE_OK;
+}
+
+
+/**
+ * \param flags mask of SVGA_RELOC_READ / _WRITE
+ */
+enum pipe_error
+SVGA3D_BindGBSurface(struct svga_winsys_context *swc,
+ struct svga_winsys_surface *surface)
+{
+ SVGA3dCmdBindGBSurface *cmd =
+ SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_BIND_GB_SURFACE,
+ sizeof *cmd,
+ 2); /* two relocations */
+
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ swc->surface_relocation(swc, &cmd->sid, &cmd->mobid, surface,
+ SVGA_RELOC_READ | SVGA_RELOC_INTERNAL);
+
+ swc->commit(swc);
+
+ return PIPE_OK;
+}
+
+
+/**
+ * Update an image in a guest-backed surface.
+ * (Inform the device that the guest-contents have been updated.)
+ */
+enum pipe_error
+SVGA3D_UpdateGBImage(struct svga_winsys_context *swc,
+ struct svga_winsys_surface *surface,
+ const SVGA3dBox *box,
+ unsigned face, unsigned mipLevel)
+
+{
+ SVGA3dCmdUpdateGBImage *cmd =
+ SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_UPDATE_GB_IMAGE,
+ sizeof *cmd,
+ 1); /* one relocation */
+
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ swc->surface_relocation(swc, &cmd->image.sid, NULL, surface,
+ SVGA_RELOC_WRITE | SVGA_RELOC_INTERNAL);
+ cmd->image.face = face;
+ cmd->image.mipmap = mipLevel;
+ cmd->box = *box;
+
+ swc->commit(swc);
+ swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
+
+ return PIPE_OK;
+}
+
+
+/**
+ * Update an entire guest-backed surface.
+ * (Inform the device that the guest-contents have been updated.)
+ */
+enum pipe_error
+SVGA3D_UpdateGBSurface(struct svga_winsys_context *swc,
+ struct svga_winsys_surface *surface)
+{
+ SVGA3dCmdUpdateGBSurface *cmd =
+ SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_UPDATE_GB_SURFACE,
+ sizeof *cmd,
+ 1); /* one relocation */
+
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ swc->surface_relocation(swc, &cmd->sid, NULL, surface,
+ SVGA_RELOC_WRITE | SVGA_RELOC_INTERNAL);
+
+ swc->commit(swc);
+ swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
+
+ return PIPE_OK;
+}
+
+
+/**
+ * Readback an image in a guest-backed surface.
+ * (Request the device to flush the dirty contents into the guest.)
+ */
+enum pipe_error
+SVGA3D_ReadbackGBImage(struct svga_winsys_context *swc,
+ struct svga_winsys_surface *surface,
+ unsigned face, unsigned mipLevel)
+{
+ SVGA3dCmdReadbackGBImage *cmd =
+ SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_READBACK_GB_IMAGE,
+ sizeof *cmd,
+ 1); /* one relocation */
+
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ swc->surface_relocation(swc, &cmd->image.sid, NULL, surface,
+ SVGA_RELOC_READ | SVGA_RELOC_INTERNAL);
+ cmd->image.face = face;
+ cmd->image.mipmap = mipLevel;
+
+ swc->commit(swc);
+ swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
+
+ return PIPE_OK;
+}
+
+
+/**
+ * Readback an entire guest-backed surface.
+ * (Request the device to flush the dirty contents into the guest.)
+ */
+enum pipe_error
+SVGA3D_ReadbackGBSurface(struct svga_winsys_context *swc,
+ struct svga_winsys_surface *surface)
+{
+ SVGA3dCmdReadbackGBSurface *cmd =
+ SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_READBACK_GB_SURFACE,
+ sizeof *cmd,
+ 1); /* one relocation */
+
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ swc->surface_relocation(swc, &cmd->sid, NULL, surface,
+ SVGA_RELOC_READ | SVGA_RELOC_INTERNAL);
+
+ swc->commit(swc);
+ swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
+
+ return PIPE_OK;
+}
+
+
+enum pipe_error
+SVGA3D_ReadbackGBImagePartial(struct svga_winsys_context *swc,
+ struct svga_winsys_surface *surface,
+ unsigned face, unsigned mipLevel,
+ const SVGA3dBox *box,
+ bool invertBox)
+{
+ SVGA3dCmdReadbackGBImagePartial *cmd =
+ SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL,
+ sizeof *cmd,
+ 1); /* one relocation */
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ swc->surface_relocation(swc, &cmd->image.sid, NULL, surface,
+ SVGA_RELOC_READ | SVGA_RELOC_INTERNAL);
+ cmd->image.face = face;
+ cmd->image.mipmap = mipLevel;
+ cmd->box = *box;
+ cmd->invertBox = invertBox;
+
+ swc->commit(swc);
+ swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
+
+ return PIPE_OK;
+}
+
+
+enum pipe_error
+SVGA3D_InvalidateGBImagePartial(struct svga_winsys_context *swc,
+ struct svga_winsys_surface *surface,
+ unsigned face, unsigned mipLevel,
+ const SVGA3dBox *box,
+ bool invertBox)
+{
+ SVGA3dCmdInvalidateGBImagePartial *cmd =
+ SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL,
+ sizeof *cmd,
+ 1); /* one relocation */
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ swc->surface_relocation(swc, &cmd->image.sid, NULL, surface,
+ SVGA_RELOC_READ | SVGA_RELOC_INTERNAL);
+ cmd->image.face = face;
+ cmd->image.mipmap = mipLevel;
+ cmd->box = *box;
+ cmd->invertBox = invertBox;
+
+ swc->commit(swc);
+
+ return PIPE_OK;
+}
+
+
+enum pipe_error
+SVGA3D_SetGBShaderConstsInline(struct svga_winsys_context *swc,
+ unsigned regStart,
+ unsigned numRegs,
+ SVGA3dShaderType shaderType,
+ SVGA3dShaderConstType constType,
+ const void *values)
+{
+ SVGA3dCmdSetGBShaderConstInline *cmd;
+
+ assert(numRegs > 0);
+
+ cmd = SVGA3D_FIFOReserve(swc,
+ SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE,
+ sizeof *cmd + numRegs * sizeof(float[4]),
+ 0); /* no relocations */
+ if (!cmd)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ cmd->cid = swc->cid;
+ cmd->regStart = regStart;
+ cmd->shaderType = shaderType;
+ cmd->constType = constType;
+
+ memcpy(&cmd[1], values, numRegs * sizeof(float[4]));
swc->commit(swc);