vrend: Make vrend_report_buffer_error a macro

So the caller is correctly printed, from:

vrend_report_buffer_error: context error reported 1 "deqp-gles31" Illegal command buffer 14091265

to:

vrend_decode_block: context error reported 1 "deqp-gles31" Illegal command buffer 14091265

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Tomeu Vizoso 5 years ago committed by Tomeu Vizoso
parent 469b65b9cb
commit 8056fe3565
  1. 118
      src/vrend_renderer.c
  2. 10
      src/vrend_renderer.h

@ -790,8 +790,8 @@ static const char *vrend_ctx_error_strings[] = {
[VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS] = "IOV data size exceeds resource capacity", [VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS] = "IOV data size exceeds resource capacity",
}; };
static void __report_context_error(const char *fname, struct vrend_context *ctx, void vrend_report_context_error_internal(const char *fname, struct vrend_context *ctx,
enum virgl_ctx_errors error, uint32_t value) enum virgl_ctx_errors error, uint32_t value)
{ {
ctx->in_error = true; ctx->in_error = true;
ctx->last_error = error; ctx->last_error = error;
@ -799,12 +799,6 @@ static void __report_context_error(const char *fname, struct vrend_context *ctx,
ctx->ctx_id, ctx->debug_name, vrend_ctx_error_strings[error], ctx->ctx_id, ctx->debug_name, vrend_ctx_error_strings[error],
value); value);
} }
#define report_context_error(ctx, error, value) __report_context_error(__func__, ctx, error, value)
void vrend_report_buffer_error(struct vrend_context *ctx, int cmd)
{
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, cmd);
}
#define CORE_PROFILE_WARN_NONE 0 #define CORE_PROFILE_WARN_NONE 0
#define CORE_PROFILE_WARN_STIPPLE 1 #define CORE_PROFILE_WARN_STIPPLE 1
@ -1021,7 +1015,7 @@ static bool vrend_compile_shader(struct vrend_context *ctx,
char infolog[65536]; char infolog[65536];
int len; int len;
glGetShaderInfoLog(shader->id, 65536, &len, infolog); glGetShaderInfoLog(shader->id, 65536, &len, infolog);
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0);
vrend_printf("shader failed to compile\n%s\n", infolog); vrend_printf("shader failed to compile\n%s\n", infolog);
vrend_shader_dump(shader); vrend_shader_dump(shader);
return false; return false;
@ -1439,7 +1433,7 @@ static struct vrend_linked_shader_program *add_cs_shader_program(struct vrend_co
glGetProgramInfoLog(prog_id, 65536, &len, infolog); glGetProgramInfoLog(prog_id, 65536, &len, infolog);
vrend_printf("got error linking\n%s\n", infolog); vrend_printf("got error linking\n%s\n", infolog);
/* dump shaders */ /* dump shaders */
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0);
vrend_shader_dump(cs); vrend_shader_dump(cs);
glDeleteProgram(prog_id); glDeleteProgram(prog_id);
free(sprog); free(sprog);
@ -1539,7 +1533,7 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
glBindFragDataLocationIndexed(prog_id, 0, 0, "fsout_c0"); glBindFragDataLocationIndexed(prog_id, 0, 0, "fsout_c0");
glBindFragDataLocationIndexed(prog_id, 0, 1, "fsout_c1"); glBindFragDataLocationIndexed(prog_id, 0, 1, "fsout_c1");
} else { } else {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_DUAL_SRC_BLEND, 0); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_DUAL_SRC_BLEND, 0);
} }
sprog->dual_src_linked = true; sprog->dual_src_linked = true;
} else { } else {
@ -1570,7 +1564,7 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
glGetProgramInfoLog(prog_id, 65536, &len, infolog); glGetProgramInfoLog(prog_id, 65536, &len, infolog);
vrend_printf("got error linking\n%s\n", infolog); vrend_printf("got error linking\n%s\n", infolog);
/* dump shaders */ /* dump shaders */
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0);
vrend_shader_dump(vs); vrend_shader_dump(vs);
if (gs) if (gs)
vrend_shader_dump(gs); vrend_shader_dump(gs);
@ -1757,7 +1751,7 @@ int vrend_create_surface(struct vrend_context *ctx,
res = vrend_renderer_ctx_res_lookup(ctx, res_handle); res = vrend_renderer_ctx_res_lookup(ctx, res_handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);
return EINVAL; return EINVAL;
} }
@ -2017,7 +2011,7 @@ int vrend_create_sampler_view(struct vrend_context *ctx,
res = vrend_renderer_ctx_res_lookup(ctx, res_handle); res = vrend_renderer_ctx_res_lookup(ctx, res_handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);
return EINVAL; return EINVAL;
} }
@ -2029,14 +2023,14 @@ int vrend_create_sampler_view(struct vrend_context *ctx,
view->format = format & 0xffffff; view->format = format & 0xffffff;
if (!view->format || view->format >= VIRGL_FORMAT_MAX) { if (!view->format || view->format >= VIRGL_FORMAT_MAX) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_FORMAT, view->format); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_FORMAT, view->format);
FREE(view); FREE(view);
return EINVAL; return EINVAL;
} }
uint32_t pipe_target = (format >> 24) & 0xff; uint32_t pipe_target = (format >> 24) & 0xff;
if (pipe_target >= PIPE_MAX_TEXTURE_TYPES) { if (pipe_target >= PIPE_MAX_TEXTURE_TYPES) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SAMPLER_VIEW_TARGET, vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SAMPLER_VIEW_TARGET,
view->format); view->format);
FREE(view); FREE(view);
return EINVAL; return EINVAL;
@ -2412,7 +2406,7 @@ void vrend_set_framebuffer_state(struct vrend_context *ctx,
if (zsurf_handle) { if (zsurf_handle) {
zsurf = vrend_object_lookup(ctx->sub->object_hash, zsurf_handle, VIRGL_OBJECT_SURFACE); zsurf = vrend_object_lookup(ctx->sub->object_hash, zsurf_handle, VIRGL_OBJECT_SURFACE);
if (!zsurf) { if (!zsurf) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SURFACE, zsurf_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SURFACE, zsurf_handle);
return; return;
} }
} else } else
@ -2431,7 +2425,7 @@ void vrend_set_framebuffer_state(struct vrend_context *ctx,
if (surf_handle[i] != 0) { if (surf_handle[i] != 0) {
surf = vrend_object_lookup(ctx->sub->object_hash, surf_handle[i], VIRGL_OBJECT_SURFACE); surf = vrend_object_lookup(ctx->sub->object_hash, surf_handle[i], VIRGL_OBJECT_SURFACE);
if (!surf) { if (!surf) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SURFACE, surf_handle[i]); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SURFACE, surf_handle[i]);
return; return;
} }
} else } else
@ -2467,7 +2461,7 @@ void vrend_set_framebuffer_state(struct vrend_context *ctx,
} }
} }
if (surf == NULL) { if (surf == NULL) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SURFACE, i); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SURFACE, i);
return; return;
} }
new_height = u_minify(surf->texture->base.height0, surf->val0); new_height = u_minify(surf->texture->base.height0, surf->val0);
@ -2528,7 +2522,7 @@ void vrend_set_viewport_states(struct vrend_context *ctx,
if (num_viewports > PIPE_MAX_VIEWPORTS || if (num_viewports > PIPE_MAX_VIEWPORTS ||
start_slot > (PIPE_MAX_VIEWPORTS - num_viewports)) { start_slot > (PIPE_MAX_VIEWPORTS - num_viewports)) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, num_viewports); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, num_viewports);
return; return;
} }
@ -2638,7 +2632,7 @@ int vrend_create_vertex_elements_state(struct vrend_context *ctx,
type = GL_UNSIGNED_INT_10F_11F_11F_REV; type = GL_UNSIGNED_INT_10F_11F_11F_REV;
if (type == GL_FALSE) { if (type == GL_FALSE) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_VERTEX_FORMAT, elements[i].src_format); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_VERTEX_FORMAT, elements[i].src_format);
FREE(v); FREE(v);
return EINVAL; return EINVAL;
} }
@ -2689,7 +2683,7 @@ void vrend_bind_vertex_elements_state(struct vrend_context *ctx,
} }
v = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_VERTEX_ELEMENTS); v = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_VERTEX_ELEMENTS);
if (!v) { if (!v) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle);
return; return;
} }
@ -2738,7 +2732,7 @@ void vrend_set_uniform_buffer(struct vrend_context *ctx,
res = vrend_renderer_ctx_res_lookup(ctx, res_handle); res = vrend_renderer_ctx_res_lookup(ctx, res_handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);
return; return;
} }
ctx->sub->cbs[shader][index].buffer = (struct pipe_resource *)res; ctx->sub->cbs[shader][index].buffer = (struct pipe_resource *)res;
@ -2770,7 +2764,7 @@ void vrend_set_index_buffer(struct vrend_context *ctx,
if (!res) { if (!res) {
vrend_resource_reference((struct vrend_resource **)&ctx->sub->ib.buffer, NULL); vrend_resource_reference((struct vrend_resource **)&ctx->sub->ib.buffer, NULL);
ctx->sub->index_buffer_res_id = 0; ctx->sub->index_buffer_res_id = 0;
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);
return; return;
} }
vrend_resource_reference((struct vrend_resource **)&ctx->sub->ib.buffer, res); vrend_resource_reference((struct vrend_resource **)&ctx->sub->ib.buffer, res);
@ -2804,7 +2798,7 @@ void vrend_set_single_vbo(struct vrend_context *ctx,
} else if (ctx->sub->vbo_res_ids[index] != res_handle) { } else if (ctx->sub->vbo_res_ids[index] != res_handle) {
res = vrend_renderer_ctx_res_lookup(ctx, res_handle); res = vrend_renderer_ctx_res_lookup(ctx, res_handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);
ctx->sub->vbo_res_ids[index] = 0; ctx->sub->vbo_res_ids[index] = 0;
return; return;
} }
@ -2844,7 +2838,7 @@ void vrend_set_single_sampler_view(struct vrend_context *ctx,
view = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_SAMPLER_VIEW); view = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_SAMPLER_VIEW);
if (!view) { if (!view) {
ctx->sub->views[shader_type].views[index] = NULL; ctx->sub->views[shader_type].views[index] = NULL;
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle);
return; return;
} }
if (ctx->sub->views[shader_type].views[index] == view) { if (ctx->sub->views[shader_type].views[index] == view) {
@ -2971,7 +2965,7 @@ void vrend_set_single_image_view(struct vrend_context *ctx,
res = vrend_renderer_ctx_res_lookup(ctx, handle); res = vrend_renderer_ctx_res_lookup(ctx, handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, handle);
return; return;
} }
iview->texture = res; iview->texture = res;
@ -3002,7 +2996,7 @@ void vrend_set_single_ssbo(struct vrend_context *ctx,
if (handle) { if (handle) {
res = vrend_renderer_ctx_res_lookup(ctx, handle); res = vrend_renderer_ctx_res_lookup(ctx, handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, handle);
return; return;
} }
ssbo->res = res; ssbo->res = res;
@ -3031,7 +3025,7 @@ void vrend_set_single_abo(struct vrend_context *ctx,
if (handle) { if (handle) {
res = vrend_renderer_ctx_res_lookup(ctx, handle); res = vrend_renderer_ctx_res_lookup(ctx, handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, handle);
return; return;
} }
abo->res = res; abo->res = res;
@ -3289,12 +3283,12 @@ static int vrend_shader_create(struct vrend_context *ctx,
bool ret = vrend_convert_shader(ctx, &ctx->shader_cfg, shader->sel->tokens, bool ret = vrend_convert_shader(ctx, &ctx->shader_cfg, shader->sel->tokens,
shader->sel->req_local_mem, key, &shader->sel->sinfo, &shader->glsl_strings); shader->sel->req_local_mem, key, &shader->sel->sinfo, &shader->glsl_strings);
if (!ret) { if (!ret) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, shader->sel->type); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, shader->sel->type);
glDeleteShader(shader->id); glDeleteShader(shader->id);
return -1; return -1;
} }
} else if (!ctx->shader_cfg.use_gles && shader->sel->type != TGSI_PROCESSOR_TESS_CTRL) { } else if (!ctx->shader_cfg.use_gles && shader->sel->type != TGSI_PROCESSOR_TESS_CTRL) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, shader->sel->type); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, shader->sel->type);
glDeleteShader(shader->id); glDeleteShader(shader->id);
return -1; return -1;
} }
@ -4298,7 +4292,7 @@ int vrend_draw_vbo(struct vrend_context *ctx,
return EINVAL; return EINVAL;
indirect_res = vrend_renderer_ctx_res_lookup(ctx, indirect_handle); indirect_res = vrend_renderer_ctx_res_lookup(ctx, indirect_handle);
if (!indirect_res) { if (!indirect_res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, indirect_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, indirect_handle);
return 0; return 0;
} }
} }
@ -4310,7 +4304,7 @@ int vrend_draw_vbo(struct vrend_context *ctx,
indirect_params_res = vrend_renderer_ctx_res_lookup(ctx, indirect_draw_count_handle); indirect_params_res = vrend_renderer_ctx_res_lookup(ctx, indirect_draw_count_handle);
if (!indirect_params_res){ if (!indirect_params_res){
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, indirect_draw_count_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, indirect_draw_count_handle);
return 0; return 0;
} }
} }
@ -4667,7 +4661,7 @@ void vrend_launch_grid(struct vrend_context *ctx,
if (indirect_handle) { if (indirect_handle) {
indirect_res = vrend_renderer_ctx_res_lookup(ctx, indirect_handle); indirect_res = vrend_renderer_ctx_res_lookup(ctx, indirect_handle);
if (!indirect_res) { if (!indirect_res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, indirect_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, indirect_handle);
return; return;
} }
} }
@ -4993,7 +4987,7 @@ void vrend_object_bind_blend(struct vrend_context *ctx,
} }
state = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_BLEND); state = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_BLEND);
if (!state) { if (!state) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle);
return; return;
} }
@ -5042,7 +5036,7 @@ void vrend_object_bind_dsa(struct vrend_context *ctx,
state = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_DSA); state = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_DSA);
if (!state) { if (!state) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle);
return; return;
} }
@ -5399,7 +5393,7 @@ void vrend_object_bind_rasterizer(struct vrend_context *ctx,
state = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_RASTERIZER); state = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_RASTERIZER);
if (!state) { if (!state) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handle);
return; return;
} }
@ -5418,13 +5412,13 @@ void vrend_bind_sampler_states(struct vrend_context *ctx,
struct vrend_sampler_state *state; struct vrend_sampler_state *state;
if (shader_type >= PIPE_SHADER_TYPES) { if (shader_type >= PIPE_SHADER_TYPES) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, shader_type); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, shader_type);
return; return;
} }
if (num_states > PIPE_MAX_SAMPLERS || if (num_states > PIPE_MAX_SAMPLERS ||
start_slot > (PIPE_MAX_SAMPLERS - num_states)) { start_slot > (PIPE_MAX_SAMPLERS - num_states)) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, num_states); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, num_states);
return; return;
} }
@ -7677,7 +7671,7 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info,
if (!res) { if (!res) {
if (info->ctx_id) if (info->ctx_id)
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle);
return EINVAL; return EINVAL;
} }
@ -7702,7 +7696,7 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info,
if (!iov) { if (!iov) {
if (info->ctx_id) if (info->ctx_id)
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle);
return EINVAL; return EINVAL;
} }
@ -7713,12 +7707,12 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info,
#endif #endif
if (!check_transfer_bounds(res, info)) { if (!check_transfer_bounds(res, info)) {
report_context_error(ctx, VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS, res->id); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS, res->id);
return EINVAL; return EINVAL;
} }
if (!check_iov_bounds(res, info, iov, num_iovs)) { if (!check_iov_bounds(res, info, iov, num_iovs)) {
report_context_error(ctx, VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS, res->id); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS, res->id);
return EINVAL; return EINVAL;
} }
@ -7747,17 +7741,17 @@ int vrend_transfer_inline_write(struct vrend_context *ctx,
res = vrend_renderer_ctx_res_lookup(ctx, info->handle); res = vrend_renderer_ctx_res_lookup(ctx, info->handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle);
return EINVAL; return EINVAL;
} }
if (!check_transfer_bounds(res, info)) { if (!check_transfer_bounds(res, info)) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle);
return EINVAL; return EINVAL;
} }
if (!check_iov_bounds(res, info, info->iovec, info->iovec_cnt)) { if (!check_iov_bounds(res, info, info->iovec, info->iovec_cnt)) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle);
return EINVAL; return EINVAL;
} }
@ -7775,27 +7769,27 @@ int vrend_renderer_copy_transfer3d(struct vrend_context *ctx,
dst_res = vrend_renderer_ctx_res_lookup(ctx, info->handle); dst_res = vrend_renderer_ctx_res_lookup(ctx, info->handle);
if (!src_res) { if (!src_res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, src_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, src_handle);
return EINVAL; return EINVAL;
} }
if (!dst_res) { if (!dst_res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle);
return EINVAL; return EINVAL;
} }
if (!src_res->iov) { if (!src_res->iov) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle);
return EINVAL; return EINVAL;
} }
if (!check_transfer_bounds(dst_res, info)) { if (!check_transfer_bounds(dst_res, info)) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle);
return EINVAL; return EINVAL;
} }
if (!check_iov_bounds(dst_res, info, src_res->iov, src_res->num_iovs)) { if (!check_iov_bounds(dst_res, info, src_res->iov, src_res->num_iovs)) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle);
return EINVAL; return EINVAL;
} }
@ -7976,7 +7970,7 @@ void vrend_set_streamout_targets(struct vrend_context *ctx,
continue; continue;
target = vrend_object_lookup(ctx->sub->object_hash, handles[i], VIRGL_OBJECT_STREAMOUT_TARGET); target = vrend_object_lookup(ctx->sub->object_hash, handles[i], VIRGL_OBJECT_STREAMOUT_TARGET);
if (!target) { if (!target) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handles[i]); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_HANDLE, handles[i]);
free(obj); free(obj);
return; return;
} }
@ -8227,11 +8221,11 @@ void vrend_renderer_resource_copy_region(struct vrend_context *ctx,
dst_res = vrend_renderer_ctx_res_lookup(ctx, dst_handle); dst_res = vrend_renderer_ctx_res_lookup(ctx, dst_handle);
if (!src_res) { if (!src_res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, src_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, src_handle);
return; return;
} }
if (!dst_res) { if (!dst_res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle);
return; return;
} }
@ -8649,11 +8643,11 @@ void vrend_renderer_blit(struct vrend_context *ctx,
dst_res = vrend_renderer_ctx_res_lookup(ctx, dst_handle); dst_res = vrend_renderer_ctx_res_lookup(ctx, dst_handle);
if (!src_res) { if (!src_res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, src_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, src_handle);
return; return;
} }
if (!dst_res) { if (!dst_res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle);
return; return;
} }
@ -8661,12 +8655,12 @@ void vrend_renderer_blit(struct vrend_context *ctx,
return; return;
if (!info->src.format || info->src.format >= VIRGL_FORMAT_MAX) { if (!info->src.format || info->src.format >= VIRGL_FORMAT_MAX) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_FORMAT, info->src.format); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_FORMAT, info->src.format);
return; return;
} }
if (!info->dst.format || info->dst.format >= VIRGL_FORMAT_MAX) { if (!info->dst.format || info->dst.format >= VIRGL_FORMAT_MAX) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_FORMAT, info->dst.format); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_FORMAT, info->dst.format);
return; return;
} }
@ -8943,7 +8937,7 @@ int vrend_create_query(struct vrend_context *ctx, uint32_t handle,
bool fake_samples_passed = false; bool fake_samples_passed = false;
res = vrend_renderer_ctx_res_lookup(ctx, res_handle); res = vrend_renderer_ctx_res_lookup(ctx, res_handle);
if (!res || !has_bit(res->storage_bits, VREND_STORAGE_HOST_SYSTEM_MEMORY)) { if (!res || !has_bit(res->storage_bits, VREND_STORAGE_HOST_SYSTEM_MEMORY)) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);
return EINVAL; return EINVAL;
} }
@ -8957,7 +8951,7 @@ int vrend_create_query(struct vrend_context *ctx, uint32_t handle,
if (query_type == PIPE_QUERY_OCCLUSION_PREDICATE && if (query_type == PIPE_QUERY_OCCLUSION_PREDICATE &&
!has_feature(feat_occlusion_query_boolean)) { !has_feature(feat_occlusion_query_boolean)) {
report_context_error(ctx, VIRGL_ERROR_GL_ANY_SAMPLES_PASSED, res_handle); vrend_report_context_error(ctx, VIRGL_ERROR_GL_ANY_SAMPLES_PASSED, res_handle);
return EINVAL; return EINVAL;
} }
@ -9137,7 +9131,7 @@ void vrend_get_query_result_qbo(struct vrend_context *ctx, uint32_t handle,
res = vrend_renderer_ctx_res_lookup(ctx, qbo_handle); res = vrend_renderer_ctx_res_lookup(ctx, qbo_handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, qbo_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, qbo_handle);
return; return;
} }
@ -9286,7 +9280,7 @@ int vrend_create_so_target(struct vrend_context *ctx,
int ret_handle; int ret_handle;
res = vrend_renderer_ctx_res_lookup(ctx, res_handle); res = vrend_renderer_ctx_res_lookup(ctx, res_handle);
if (!res) { if (!res) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);
return EINVAL; return EINVAL;
} }

@ -423,7 +423,15 @@ void vrend_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver,
void vrend_renderer_create_sub_ctx(struct vrend_context *ctx, int sub_ctx_id); void vrend_renderer_create_sub_ctx(struct vrend_context *ctx, int sub_ctx_id);
void vrend_renderer_destroy_sub_ctx(struct vrend_context *ctx, int sub_ctx_id); void vrend_renderer_destroy_sub_ctx(struct vrend_context *ctx, int sub_ctx_id);
void vrend_renderer_set_sub_ctx(struct vrend_context *ctx, int sub_ctx_id); void vrend_renderer_set_sub_ctx(struct vrend_context *ctx, int sub_ctx_id);
void vrend_report_buffer_error(struct vrend_context *ctx, int cmd);
void vrend_report_context_error_internal(const char *fname, struct vrend_context *ctx,
enum virgl_ctx_errors error, uint32_t value);
#define vrend_report_context_error(ctx, error, value) \
vrend_report_context_error_internal(__func__, ctx, error, value)
#define vrend_report_buffer_error(ctx, cmd) \
vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, cmd)
void vrend_fb_bind_texture(struct vrend_resource *res, void vrend_fb_bind_texture(struct vrend_resource *res,
int idx, int idx,

Loading…
Cancel
Save