virgl_encode_clear(vctx, buffers, color, depth, stencil);
}
+static void virgl_clear_texture(struct pipe_context *ctx,
+ struct pipe_resource *res,
+ unsigned int level,
+ const struct pipe_box *box,
+ const void *data)
+{
+ struct virgl_context *vctx = virgl_context(ctx);
+ struct virgl_resource *vres = virgl_resource(res);
+
+ virgl_encode_clear_texture(vctx, vres, level, box, data);
+
+ /* Mark as dirty, since we are updating the host side resource
+ * without going through the corresponding guest side resource, and
+ * hence the two will diverge.
+ */
+ virgl_resource_dirty(vres, level);
+}
+
static void virgl_draw_vbo(struct pipe_context *ctx,
const struct pipe_draw_info *dinfo)
{
vctx->base.launch_grid = virgl_launch_grid;
vctx->base.clear = virgl_clear;
+ vctx->base.clear_texture = virgl_clear_texture;
vctx->base.draw_vbo = virgl_draw_vbo;
vctx->base.flush = virgl_flush_from_st;
vctx->base.screen = pscreen;
return 0;
}
+int virgl_encode_clear_texture(struct virgl_context *ctx,
+ struct virgl_resource *res,
+ unsigned int level,
+ const struct pipe_box *box,
+ const void *data)
+{
+ const struct util_format_description *desc = util_format_description(res->u.b.format);
+ unsigned block_bits = desc->block.bits;
+ uint32_t arr[4] = {0};
+ /* The spec describe <data> as a pointer to an array of between one
+ * and four components of texel data that will be used as the source
+ * for the constant fill value.
+ * Here, we are just copying the memory into <arr>. We do not try to
+ * re-create the data array. The host part will take care of interpreting
+ * the memory and applying the correct format to the clear call.
+ */
+ memcpy(&arr, data, block_bits / 8);
+
+ virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_CLEAR_TEXTURE, 0, VIRGL_CLEAR_TEXTURE_SIZE));
+ virgl_encoder_write_res(ctx, res);
+ virgl_encoder_write_dword(ctx->cbuf, level);
+ virgl_encoder_write_dword(ctx->cbuf, box->x);
+ virgl_encoder_write_dword(ctx->cbuf, box->y);
+ virgl_encoder_write_dword(ctx->cbuf, box->z);
+ virgl_encoder_write_dword(ctx->cbuf, box->width);
+ virgl_encoder_write_dword(ctx->cbuf, box->height);
+ virgl_encoder_write_dword(ctx->cbuf, box->depth);
+ for (unsigned i = 0; i < 4; i++)
+ virgl_encoder_write_dword(ctx->cbuf, arr[i]);
+ return 0;
+}
+
int virgl_encoder_set_framebuffer_state(struct virgl_context *ctx,
const struct pipe_framebuffer_state *state)
{
const union pipe_color_union *color,
double depth, unsigned stencil);
+int virgl_encode_clear_texture(struct virgl_context *ctx,
+ struct virgl_resource *res,
+ unsigned int level,
+ const struct pipe_box *box,
+ const void *data);
+
int virgl_encode_bind_object(struct virgl_context *ctx,
uint32_t handle, uint32_t object);
int virgl_encode_delete_object(struct virgl_context *ctx,
VIRGL_CCMD_END_TRANSFERS,
VIRGL_CCMD_COPY_TRANSFER3D,
VIRGL_CCMD_SET_TWEAKS,
+ VIRGL_CCMD_CLEAR_TEXTURE,
};
/*
virgl_tweak_undefined
};
+/* Clear texture */
+#define VIRGL_CLEAR_TEXTURE_SIZE 12
+#define VIRGL_TEXTURE_HANDLE 1
+#define VIRGL_TEXTURE_LEVEL 2
+#define VIRGL_TEXTURE_SRC_X 3
+#define VIRGL_TEXTURE_SRC_Y 4
+#define VIRGL_TEXTURE_SRC_Z 5
+#define VIRGL_TEXTURE_SRC_W 6
+#define VIRGL_TEXTURE_SRC_H 7
+#define VIRGL_TEXTURE_SRC_D 8
+#define VIRGL_TEXTURE_ARRAY_A 9
+#define VIRGL_TEXTURE_ARRAY_B 10
+#define VIRGL_TEXTURE_ARRAY_C 11
+#define VIRGL_TEXTURE_ARRAY_D 12
+
#endif