Hi,

GL_ARB_provoking_vertex states that quads are not required to abide
the provoking vertex convention, and the actual hardware and/or driver
behavior can be queried with
GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION.

I'd like to add a new PIPE_CAP_* to query for this capability in
Gallium, as it appears R3xx-R5xx hardware doesn't support the first
vertex convention for quads and I'd like the driver to behave
correctly. Fortunately, other primitive types are supported.

I decided to use the name "quads follow flatshade_first convention"
instead of "provoking vertex convention" because the actual state
variable in pipe_rasterizer_state is called flatshade_first.

The attached patch:
- adds PIPE_CAP_QUADS_FOLLOW_FLATSHADE_FIRST_CONVENTION
- adds the query in the Mesa state tracker
- and updates softpipe and llvmpipe to return 1 when this cap is
queried, and r300g to explicitly return 0

Please review/push.

Cheers.

Marek
From bbf279f81e03a6872507cbf533b382748c4ae015 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Marek=20Ol=C5=A1=C3=A1k?= <mar...@gmail.com>
Date: Fri, 18 Dec 2009 05:10:27 +0100
Subject: [PATCH] gallium: add PIPE_CAP_QUADS_FOLLOW_FLATSHADE_FIRST_CONVENTION

---
 src/gallium/drivers/llvmpipe/lp_screen.c |    2 ++
 src/gallium/drivers/r300/r300_screen.c   |    2 ++
 src/gallium/drivers/softpipe/sp_screen.c |    2 ++
 src/gallium/include/pipe/p_defines.h     |    1 +
 src/mesa/state_tracker/st_extensions.c   |    4 ++++
 5 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index 9b47415..fa786f9 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -110,6 +110,8 @@ llvmpipe_get_param(struct pipe_screen *screen, int param)
       return 1;
    case PIPE_CAP_BLEND_EQUATION_SEPARATE:
       return 1;
+   case PIPE_CAP_QUADS_FOLLOW_FLATSHADE_FIRST_CONVENTION:
+      return 1;
    default:
       return 0;
    }
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index c2ea9b6..0b75ecf 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -138,6 +138,8 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
             return 0;
         case PIPE_CAP_BLEND_EQUATION_SEPARATE:
             return 1;
+        case PIPE_CAP_QUADS_FOLLOW_FLATSHADE_FIRST_CONVENTION:
+            return 0;
         default:
             debug_printf("r300: Implementation error: Bad param %d\n",
                 param);
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index bd3532d..510150b 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -91,6 +91,8 @@ softpipe_get_param(struct pipe_screen *screen, int param)
       return 1;
    case PIPE_CAP_BLEND_EQUATION_SEPARATE:
       return 1;
+   case PIPE_CAP_QUADS_FOLLOW_FLATSHADE_FIRST_CONVENTION:
+      return 1;
    default:
       return 0;
    }
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index fe1390d..6a37893 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -393,6 +393,7 @@ enum pipe_transfer_usage {
 #define PIPE_CAP_MAX_PREDICATE_REGISTERS 30
 #define PIPE_CAP_MAX_COMBINED_SAMPLERS   31  /*< Maximum texture image units accessible from vertex
                                                  and fragment shaders combined */
+#define PIPE_CAP_QUADS_FOLLOW_FLATSHADE_FIRST_CONVENTION 32
 
 
 /**
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index ef3cbc5..db3380b 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -125,6 +125,10 @@ void st_init_limits(struct st_context *st)
       = CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
               1, MAX_DRAW_BUFFERS);
 
+   c->QuadsFollowProvokingVertexConvention
+      = CLAMP(screen->get_param(screen, PIPE_CAP_QUADS_FOLLOW_FLATSHADE_FIRST_CONVENTION),
+              0, 1);
+
    /* Is TGSI_OPCODE_CONT supported? */
    /* XXX separate query for early function return? */
    st->ctx->Shader.EmitContReturn =
-- 
1.6.3.3

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to