From 9fd1df55765569f4ac8cb13625bda8073550dc42 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 22 Dec 2017 18:57:56 +0000 Subject: [PATCH] vrend: Warn and partially work around missing GL_TEXTURE_RECTANGLE Not supported at all in GLES, 1x1 texture rectangles can be emulated by GL_TEXTURE_2D, which was the only usage I have come accross in my limited testing. Signed-off-by: Jakob Bornecrantz Signed-off-by: Dave Airlie --- src/vrend_renderer.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 92130fa..ec37fc8 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -504,12 +504,15 @@ static void __report_core_warn(const char *fname, struct vrend_context *ctx, enu #define GLES_WARN_POINT_SIZE 4 #define GLES_WARN_LOD_BIAS 5 #define GLES_WARN_SRGB_FB 6 +#define GLES_WARN_TEXTURE_RECT 7 -static const char *vrend_gles_warn_strings[] = { "None", "Stipple", "Polygon Mode", "Depth Range", "Point Size", "Lod Bias", "SRGB Framebuffer" }; +static const char *vrend_gles_warn_strings[] = { "None", "Stipple", "Polygon Mode", "Depth Range", "Point Size", "Lod Bias", "SRGB Framebuffer", "Texture Rect" }; static void __report_gles_warn(const char *fname, struct vrend_context *ctx, enum virgl_ctx_errors error, uint32_t value) { - fprintf(stderr,"%s: gles violation reported %d \"%s\" %s %d\n", fname, ctx->ctx_id, ctx->debug_name, vrend_gles_warn_strings[error], value); + int id = ctx ? ctx->ctx_id : -1; + const char *name = ctx ? ctx->debug_name : "NO_CONTEXT"; + fprintf(stderr,"%s: gles violation reported %d \"%s\" %s %d\n", fname, id, ctx->debug_name, vrend_gles_warn_strings[error], value); } #define report_gles_warn(ctx, error, value) __report_gles_warn(__func__, ctx, error, value) @@ -4391,6 +4394,16 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a struct vrend_texture *gt = (struct vrend_texture *)gr; GLenum internalformat, glformat, gltype; gr->target = tgsitargettogltarget(args->target, args->nr_samples); + + /* ugly workaround for texture rectangle missing on GLES */ + if (vrend_state.use_gles && gr->target == GL_TEXTURE_RECTANGLE_NV) { + /* for some guests this is the only usage of rect */ + if (args->width != 1 || args->height != 1) { + report_gles_warn(NULL, GLES_WARN_TEXTURE_RECT, 0); + } + gr->target = GL_TEXTURE_2D; + } + glGenTextures(1, &gr->id); glBindTexture(gr->target, gr->id);