vrend: implement ARB_clear_texture

Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Elie Tournier 5 years ago
parent 71e0626657
commit 66b5e91c10
  1. 18
      src/virgl_protocol.h
  2. 3
      src/vrend_debug.c
  3. 30
      src/vrend_decode.c
  4. 32
      src/vrend_renderer.c
  5. 5
      src/vrend_renderer.h

@ -102,6 +102,7 @@ enum virgl_context_cmd {
VIRGL_CCMD_END_TRANSFERS,
VIRGL_CCMD_COPY_TRANSFER3D,
VIRGL_CCMD_SET_TWEAKS,
VIRGL_CCMD_CLEAR_TEXTURE,
VIRGL_MAX_COMMANDS
};
@ -605,4 +606,19 @@ enum vrend_tweak_type {
virgl_tweak_undefined
};
#endif
/* 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

@ -75,7 +75,8 @@ static const char *command_names[VIRGL_MAX_COMMANDS] = {
"TRANSFER3D",
"END_TRANSFERS",
"COPY_TRANSFER3D",
"TWEAK"
"TWEAK",
"CLEAR_TEXTURE"
};
static const char *object_type_names[VIRGL_MAX_OBJECTS] = {

@ -211,6 +211,33 @@ static int vrend_decode_clear(struct vrend_decode_ctx *ctx, int length)
return 0;
}
static int vrend_decode_clear_texture(struct vrend_decode_ctx *ctx, int length)
{
struct pipe_box box;
uint32_t handle;
uint32_t level;
uint32_t arr[4] = {0};
if (length != VIRGL_CLEAR_TEXTURE_SIZE)
return EINVAL;
handle = get_buf_entry(ctx, VIRGL_TEXTURE_HANDLE);
level = get_buf_entry(ctx, VIRGL_TEXTURE_LEVEL);
box.x = get_buf_entry(ctx, VIRGL_TEXTURE_SRC_X);
box.y = get_buf_entry(ctx, VIRGL_TEXTURE_SRC_Y);
box.z = get_buf_entry(ctx, VIRGL_TEXTURE_SRC_Z);
box.width = get_buf_entry(ctx, VIRGL_TEXTURE_SRC_W);
box.height = get_buf_entry(ctx, VIRGL_TEXTURE_SRC_H);
box.depth = get_buf_entry(ctx, VIRGL_TEXTURE_SRC_D);
arr[0] = get_buf_entry(ctx, VIRGL_TEXTURE_ARRAY_A);
arr[1] = get_buf_entry(ctx, VIRGL_TEXTURE_ARRAY_B);
arr[2] = get_buf_entry(ctx, VIRGL_TEXTURE_ARRAY_C);
arr[3] = get_buf_entry(ctx, VIRGL_TEXTURE_ARRAY_D);
vrend_clear_texture(ctx->grctx, handle, level, &box, (void *) &arr);
return 0;
}
static float uif(unsigned int ui)
{
union { float f; unsigned int ui; } myuif;
@ -1496,6 +1523,9 @@ static int vrend_decode_ctx_submit_cmd(struct virgl_context *ctx,
case VIRGL_CCMD_CLEAR:
ret = vrend_decode_clear(gdctx, len);
break;
case VIRGL_CCMD_CLEAR_TEXTURE:
ret = vrend_decode_clear_texture(gdctx, len);
break;
case VIRGL_CCMD_DRAW_VBO:
ret = vrend_decode_draw_vbo(gdctx, len);
break;

@ -3720,6 +3720,38 @@ void vrend_clear(struct vrend_context *ctx,
glDisable(GL_SCISSOR_TEST);
}
void vrend_clear_texture(struct vrend_context* ctx,
uint32_t handle, uint32_t level,
const struct pipe_box *box,
const void * data)
{
GLenum format, type;
struct vrend_resource *res;
if (handle)
res = vrend_renderer_ctx_res_lookup(ctx, handle);
else {
vrend_printf( "cannot find resource for handle %d\n", handle);
return;
}
enum virgl_formats fmt = vrend_format_replace_emulated(res->base.bind, res->base.format);
format = tex_conv_table[fmt].glformat;
type = tex_conv_table[fmt].gltype;
if (vrend_state.use_gles) {
glClearTexSubImageEXT(res->id, level,
box->x, box->y, box->z,
box->width, box->height, box->depth,
format, type, data);
} else {
glClearTexSubImage(res->id, level,
box->x, box->y, box->z,
box->width, box->height, box->depth,
format, type, data);
}
}
static void vrend_update_scissor_state(struct vrend_context *ctx)
{
struct pipe_scissor_state *ss;

@ -154,6 +154,11 @@ void vrend_clear(struct vrend_context *ctx,
const union pipe_color_union *color,
double depth, unsigned stencil);
void vrend_clear_texture(struct vrend_context* ctx,
uint32_t handle, uint32_t level,
const struct pipe_box *box,
const void * data);
int vrend_draw_vbo(struct vrend_context *ctx,
const struct pipe_draw_info *info,
uint32_t cso, uint32_t indirect_handle, uint32_t indirect_draw_count_handle);

Loading…
Cancel
Save