aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGert Wollny <gert.wollny@collabora.com>2023-09-27 15:24:11 +0200
committerMarge Bot <emma+marge@anholt.net>2024-04-11 20:18:55 +0000
commita5eba491786fd781159688027b8e2ae2e182c568 (patch)
treeef8881a4dcb52753b9589d1e3d6adb36020540ef
parent75cedde6c493a432266238f9e6c1004000ae4fa9 (diff)
downloadvirglrenderer-a5eba491786fd781159688027b8e2ae2e182c568.tar.gz
vrend: Add more error messages for shader decoding
v2: * Fix error message for long shader TGSI parse error. * Move error message emission to the right conditional (Ryan Neph). Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1248>
-rw-r--r--src/vrend_renderer.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 7c677e58..935b9b1a 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -4521,17 +4521,23 @@ int vrend_create_shader(struct vrend_context *ctx,
enum pipe_shader_type type, uint32_t pkt_length)
{
if (type == PIPE_SHADER_GEOMETRY &&
- !has_feature(feat_geometry_shader))
+ !has_feature(feat_geometry_shader)) {
+ virgl_error("Geometry shader not supported\n");
return EINVAL;
+ }
if ((type == PIPE_SHADER_TESS_CTRL ||
type == PIPE_SHADER_TESS_EVAL) &&
- !has_feature(feat_tessellation))
+ !has_feature(feat_tessellation)) {
+ virgl_error("Tesselation shaders not supported\n");
return EINVAL;
+ }
if (type == PIPE_SHADER_COMPUTE &&
- !has_feature(feat_compute_shader))
+ !has_feature(feat_compute_shader)) {
+ virgl_error("Compute shaders not supported\n");
return EINVAL;
+ }
/* offlen & VIRGL_OBJ_SHADER_OFFSET_CONT declares whether we have a new shader or
* a shader continuation
@@ -4545,27 +4551,37 @@ int vrend_create_shader(struct vrend_context *ctx,
/* if we have an in progress one - don't allow a new shader
of that type or a different handle. */
if (sub_ctx->long_shader_in_progress[type]) {
- if (new_shader == true)
+ if (new_shader == true) {
+ virgl_error("Expected long shader continuation, got new shader\n");
return EINVAL;
- if (handle != sub_ctx->long_shader_in_progress[type]->handle)
+ }
+ if (handle != sub_ctx->long_shader_in_progress[type]->handle) {
+ virgl_error("Long shader continuation handle invalid\n");
return EINVAL;
+ }
}
/* Ensure that we won't hit an overflow */
- if (pkt_length >= (UINT32_MAX >> 2))
+ if (pkt_length >= (UINT32_MAX >> 2)) {
+ virgl_error("Packed length overflow\n");
return EINVAL;
+ }
const uint32_t pkt_length_bytes = pkt_length * 4;
if (new_shader) {
const uint32_t expected_token_count = (offlen + 3) / 4; /* round up count */
- if (expected_token_count < pkt_length)
+ if (expected_token_count < pkt_length) {
+ virgl_error("Invalid expected token count\n");
return EINVAL;
+ }
struct vrend_shader_selector *sel;
sel = vrend_create_shader_state(so_info, req_local_mem, type);
- if (sel == NULL)
+ if (sel == NULL) {
+ virgl_error("Unable to allocate shader state\n");
return ENOMEM;
+ }
int ret_handle = vrend_renderer_object_insert(ctx, sel, handle, VIRGL_OBJECT_SHADER);
if (ret_handle == 0) {
@@ -4581,6 +4597,7 @@ int vrend_create_shader(struct vrend_context *ctx,
&sub_ctx->long_shader_in_progress[type]);
if (ret != 0) {
vrend_renderer_object_destroy(ctx, handle);
+ virgl_error("Error storing long shader\n");
return ret;
}
} else {
@@ -4589,6 +4606,7 @@ int vrend_create_shader(struct vrend_context *ctx,
num_tokens);
if (ret != 0) {
vrend_renderer_object_destroy(ctx, handle);
+ virgl_error("Error assigning TGSI\n");
return ret;
}
}
@@ -4628,6 +4646,7 @@ int vrend_create_shader(struct vrend_context *ctx,
sub_ctx->long_shader_in_progress[type] = NULL;
vrend_destroy_long_shader_buffer(lsbuf);
if (ret != 0) {
+ virgl_error("Error assigning TGSI\n");
vrend_renderer_object_destroy(ctx, handle);
return ret;
}