vrend: Warn on depth range out of bounds

OpenGL ES glDepthRange clamps the values, warn if the range is out of bounds.
We can't do much more then then this, during normal guest side Desktop OpenGL
operation this does not seem to happen.

Signed-off-by: Jakob Bornecrantz <jakob.bornecrantz@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Jakob Bornecrantz 7 years ago committed by Dave Airlie
parent 75987564c6
commit 883cda5713
  1. 14
      src/vrend_renderer.c

@ -500,8 +500,9 @@ static void __report_core_warn(const char *fname, struct vrend_context *ctx, enu
#define GLES_WARN_NONE 0 #define GLES_WARN_NONE 0
#define GLES_WARN_STIPPLE 1 #define GLES_WARN_STIPPLE 1
#define GLES_WARN_POLYGON_MODE 2 #define GLES_WARN_POLYGON_MODE 2
#define GLES_WARN_DEPTH_RANGE 3
static const char *vrend_gles_warn_strings[] = { "None", "Stipple", "Polygon Mode" }; static const char *vrend_gles_warn_strings[] = { "None", "Stipple", "Polygon Mode", "Depth Range" };
static void __report_gles_warn(const char *fname, struct vrend_context *ctx, enum virgl_ctx_errors error, uint32_t value) static void __report_gles_warn(const char *fname, struct vrend_context *ctx, enum virgl_ctx_errors error, uint32_t value)
{ {
@ -1658,7 +1659,16 @@ void vrend_set_viewport_states(struct vrend_context *ctx,
ctx->sub->vps[idx].far_val != far_val) { ctx->sub->vps[idx].far_val != far_val) {
ctx->sub->vps[idx].near_val = near_val; ctx->sub->vps[idx].near_val = near_val;
ctx->sub->vps[idx].far_val = far_val; ctx->sub->vps[idx].far_val = far_val;
if (idx)
if (vrend_state.use_gles) {
if (near_val < 0.0f || far_val < 0.0f ||
near_val > 1.0f || far_val > 1.0f || idx) {
report_gles_warn(ctx, GLES_WARN_DEPTH_RANGE, 0);
}
/* Best effort despite the warning, gles will clamp. */
glDepthRangef(ctx->sub->vps[idx].near_val, ctx->sub->vps[idx].far_val);
} else if (idx)
glDepthRangeIndexed(idx, ctx->sub->vps[idx].near_val, ctx->sub->vps[idx].far_val); glDepthRangeIndexed(idx, ctx->sub->vps[idx].near_val, ctx->sub->vps[idx].far_val);
else else
glDepthRange(ctx->sub->vps[idx].near_val, ctx->sub->vps[idx].far_val); glDepthRange(ctx->sub->vps[idx].near_val, ctx->sub->vps[idx].far_val);

Loading…
Cancel
Save