vrend: simplify vrend_object_insert

Remove the unused length argument.   Remove unused
vrend_object_insert_nofree as well now that context resource
management is not built on top of vrend_object.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Chia-I Wu 5 years ago
parent 4e5e469b14
commit b16105b25c
  1. 6
      src/vrend_decode.c
  2. 19
      src/vrend_object.c
  3. 8
      src/vrend_object.h
  4. 18
      src/vrend_renderer.c
  5. 2
      src/vrend_renderer.h

@ -470,7 +470,7 @@ static int vrend_decode_create_blend(struct vrend_decode_ctx *ctx, uint32_t hand
blend_state->rt[i].colormask = (tmp >> 27) & 0xf;
}
tmp = vrend_renderer_object_insert(ctx->grctx, blend_state, sizeof(struct pipe_blend_state), handle,
tmp = vrend_renderer_object_insert(ctx->grctx, blend_state, handle,
VIRGL_OBJECT_BLEND);
if (tmp == 0) {
FREE(blend_state);
@ -514,7 +514,7 @@ static int vrend_decode_create_dsa(struct vrend_decode_ctx *ctx, uint32_t handle
tmp = get_buf_entry(ctx, VIRGL_OBJ_DSA_ALPHA_REF);
dsa_state->alpha.ref_value = uif(tmp);
tmp = vrend_renderer_object_insert(ctx->grctx, dsa_state, sizeof(struct pipe_depth_stencil_alpha_state), handle,
tmp = vrend_renderer_object_insert(ctx->grctx, dsa_state, handle,
VIRGL_OBJECT_DSA);
if (tmp == 0) {
FREE(dsa_state);
@ -580,7 +580,7 @@ static int vrend_decode_create_rasterizer(struct vrend_decode_ctx *ctx, uint32_t
rs_state->offset_scale = uif(get_buf_entry(ctx, VIRGL_OBJ_RS_OFFSET_SCALE));
rs_state->offset_clamp = uif(get_buf_entry(ctx, VIRGL_OBJ_RS_OFFSET_CLAMP));
tmp = vrend_renderer_object_insert(ctx->grctx, rs_state, sizeof(struct pipe_rasterizer_state), handle,
tmp = vrend_renderer_object_insert(ctx->grctx, rs_state, handle,
VIRGL_OBJECT_RASTERIZER);
if (tmp == 0) {
FREE(rs_state);

@ -42,21 +42,19 @@ struct vrend_object {
enum virgl_object_type type;
uint32_t handle;
void *data;
bool free_data;
};
static void free_object(void *value)
{
struct vrend_object *obj = value;
if (obj->free_data) {
if (obj_types[obj->type].unref)
obj_types[obj->type].unref(obj->data);
else {
/* for objects with no callback just free them */
free(obj->data);
}
}
free(obj);
}
@ -94,9 +92,9 @@ void vrend_ctx_resource_fini_table(struct util_hash_table *res_hash)
}
uint32_t
vrend_object_insert_nofree(struct util_hash_table *handle_hash,
void *data, UNUSED uint32_t length, uint32_t handle,
enum virgl_object_type type, bool free_data)
vrend_object_insert(struct util_hash_table *handle_hash,
void *data, uint32_t handle,
enum virgl_object_type type)
{
struct vrend_object *obj = CALLOC_STRUCT(vrend_object);
@ -105,19 +103,10 @@ vrend_object_insert_nofree(struct util_hash_table *handle_hash,
obj->handle = handle;
obj->data = data;
obj->type = type;
obj->free_data = free_data;
util_hash_table_set(handle_hash, intptr_to_pointer(obj->handle), obj);
return obj->handle;
}
uint32_t
vrend_object_insert(struct util_hash_table *handle_hash,
void *data, uint32_t length, uint32_t handle, enum virgl_object_type type)
{
return vrend_object_insert_nofree(handle_hash, data, length,
handle, type, true);
}
void
vrend_object_remove(struct util_hash_table *handle_hash,
uint32_t handle, UNUSED enum virgl_object_type type)

@ -34,12 +34,10 @@ void vrend_object_fini_ctx_table(struct util_hash_table *ctx_hash);
void vrend_object_remove(struct util_hash_table *handle_hash, uint32_t handle, enum virgl_object_type obj);
void *vrend_object_lookup(struct util_hash_table *handle_hash, uint32_t handle, enum virgl_object_type obj);
uint32_t vrend_object_insert(struct util_hash_table *handle_hash, void *data, uint32_t length, uint32_t handle, enum virgl_object_type type);
uint32_t vrend_object_insert_nofree(struct util_hash_table *handle_hash,
void *data, uint32_t length,
uint32_t vrend_object_insert(struct util_hash_table *handle_hash,
void *data,
uint32_t handle,
enum virgl_object_type type,
bool free_data);
enum virgl_object_type type);
void vrend_object_set_destroy_callback(int type, void (*cb)(void *));

@ -1811,7 +1811,7 @@ int vrend_create_surface(struct vrend_context *ctx,
vrend_resource_reference(&surf->texture, res);
ret_handle = vrend_renderer_object_insert(ctx, surf, sizeof(*surf), handle, VIRGL_OBJECT_SURFACE);
ret_handle = vrend_renderer_object_insert(ctx, surf, handle, VIRGL_OBJECT_SURFACE);
if (ret_handle == 0) {
FREE(surf);
return ENOMEM;
@ -1974,7 +1974,7 @@ int vrend_create_sampler_state(struct vrend_context *ctx,
glSamplerParameteri(state->ids[i], GL_TEXTURE_SRGB_DECODE_EXT, i == 0 ? GL_SKIP_DECODE_EXT : GL_DECODE_EXT);
}
}
ret_handle = vrend_renderer_object_insert(ctx, state, sizeof(struct vrend_sampler_state), handle,
ret_handle = vrend_renderer_object_insert(ctx, state, handle,
VIRGL_OBJECT_SAMPLER_STATE);
if (!ret_handle) {
if (has_feature(feat_samplers))
@ -2178,7 +2178,7 @@ int vrend_create_sampler_view(struct vrend_context *ctx,
}
}
ret_handle = vrend_renderer_object_insert(ctx, view, sizeof(*view), handle, VIRGL_OBJECT_SAMPLER_VIEW);
ret_handle = vrend_renderer_object_insert(ctx, view, handle, VIRGL_OBJECT_SAMPLER_VIEW);
if (ret_handle == 0) {
FREE(view);
return ENOMEM;
@ -2664,7 +2664,7 @@ int vrend_create_vertex_elements_state(struct vrend_context *ctx,
glEnableVertexAttribArray(i);
}
}
ret_handle = vrend_renderer_object_insert(ctx, v, sizeof(struct vrend_vertex_element), handle,
ret_handle = vrend_renderer_object_insert(ctx, v, handle,
VIRGL_OBJECT_VERTEX_ELEMENTS);
if (!ret_handle) {
FREE(v);
@ -3527,7 +3527,7 @@ int vrend_create_shader(struct vrend_context *ctx,
}
if (new_shader) {
ret_handle = vrend_renderer_object_insert(ctx, sel, sizeof(*sel), handle, VIRGL_OBJECT_SHADER);
ret_handle = vrend_renderer_object_insert(ctx, sel, handle, VIRGL_OBJECT_SHADER);
if (ret_handle == 0) {
ret = ENOMEM;
goto error;
@ -8940,9 +8940,9 @@ vrend_renderer_object_destroy(struct vrend_context *ctx, uint32_t handle)
}
uint32_t vrend_renderer_object_insert(struct vrend_context *ctx, void *data,
uint32_t size, uint32_t handle, enum virgl_object_type type)
uint32_t handle, enum virgl_object_type type)
{
return vrend_object_insert(ctx->sub->object_hash, data, size, handle, type);
return vrend_object_insert(ctx->sub->object_hash, data, handle, type);
}
int vrend_create_query(struct vrend_context *ctx, uint32_t handle,
@ -9031,7 +9031,7 @@ int vrend_create_query(struct vrend_context *ctx, uint32_t handle,
glGenQueries(1, &q->id);
ret_handle = vrend_renderer_object_insert(ctx, q, sizeof(struct vrend_query), handle,
ret_handle = vrend_renderer_object_insert(ctx, q, handle,
VIRGL_OBJECT_QUERY);
if (!ret_handle) {
FREE(q);
@ -9313,7 +9313,7 @@ int vrend_create_so_target(struct vrend_context *ctx,
target->sub_ctx = ctx->sub;
vrend_resource_reference(&target->buffer, res);
ret_handle = vrend_renderer_object_insert(ctx, target, sizeof(*target), handle,
ret_handle = vrend_renderer_object_insert(ctx, target, handle,
VIRGL_OBJECT_STREAMOUT_TARGET);
if (ret_handle == 0) {
FREE(target);

@ -342,7 +342,7 @@ void vrend_renderer_check_fences(void);
bool vrend_hw_switch_context(struct vrend_context *ctx, bool now);
uint32_t vrend_renderer_object_insert(struct vrend_context *ctx, void *data,
uint32_t size, uint32_t handle, enum virgl_object_type type);
uint32_t handle, enum virgl_object_type type);
void vrend_renderer_object_destroy(struct vrend_context *ctx, uint32_t handle);
int vrend_create_query(struct vrend_context *ctx, uint32_t handle,

Loading…
Cancel
Save