nvc0: only force early fragment tests if requested by shader
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Thu, 1 Mar 2012 20:23:06 +0000 (21:23 +0100)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sat, 14 Apr 2012 04:14:21 +0000 (06:14 +0200)
src/gallium/drivers/nvc0/nvc0_3d.xml.h
src/gallium/drivers/nvc0/nvc0_context.h
src/gallium/drivers/nvc0/nvc0_program.c
src/gallium/drivers/nvc0/nvc0_shader_state.c
src/gallium/drivers/nvc0/nvc0_state_validate.c

index 18d27865d716a08e6d37ad8ad087a0d97b207b53..05f967313eba68b14631197770b9ccf0c8f62748 100644 (file)
@@ -84,7 +84,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define NVC0_3D_LINE_WIDTH_SEPARATE                            0x0000020c
 
-#define NVC0_3D_EARLY_FRAGMENT_TESTS                           0x00000210
+#define NVC0_3D_FORCE_EARLY_FRAGMENT_TESTS                     0x00000210
 
 #define NVC0_3D_MEM_BARRIER                                    0x0000021c
 #define NVC0_3D_MEM_BARRIER_UNK0                               0x00000001
index 4b35330ef8adaf069a9afc82547d046c52a560d0..7342a6e664f6f438f777aa3d8853a106473f146f 100644 (file)
@@ -78,7 +78,7 @@ struct nvc0_context {
    struct {
       boolean flushed;
       boolean rasterizer_discard;
-      boolean early_z;
+      boolean early_z_forced;
       boolean prim_restart;
       uint32_t instance_elts; /* bitmask of per-instance elements */
       uint32_t instance_base;
index b403e2ee9f24801f2a34989e02f878938eec492d..e867461fb2ecc841997a5517d0d8774a27008d20 100644 (file)
@@ -479,10 +479,6 @@ nvc0_fp_gen_header(struct nvc0_program *fp, struct nv50_ir_prog_info *info)
    }
 
    fp->fp.early_z = info->prop.fp.earlyFragTests;
-   if (fp->fp.early_z == FALSE && fp->code_size >= 0x400)
-      fp->fp.early_z = !(info->prop.fp.writesDepth ||
-                         info->prop.fp.usesDiscard ||
-                         (info->io.globalAccess & 2));
 
    return 0;
 }
index 9d6888434735abdab5a4e8a37706f07da52f15dd..6cbaaf9d1d8de48f3252f68c1d07e54fdf10f1f8 100644 (file)
@@ -110,6 +110,11 @@ nvc0_fragprog_validate(struct nvc0_context *nvc0)
          return;
    nvc0_program_update_context_state(nvc0, fp, 4);
 
+   if (fp->fp.early_z != nvc0->state.early_z_forced) {
+      nvc0->state.early_z_forced = fp->fp.early_z;
+      IMMED_NVC0(push, NVC0_3D(FORCE_EARLY_FRAGMENT_TESTS), fp->fp.early_z);
+   }
+
    BEGIN_NVC0(push, NVC0_3D(SP_SELECT(5)), 2);
    PUSH_DATA (push, 0x51);
    PUSH_DATA (push, fp->code_base);
index f235ba57e3650dd2379682bec6243339268efa21..4211fcdefd58fb6662892a0529b804c1ee9ce7c4 100644 (file)
@@ -442,16 +442,8 @@ static void
 nvc0_validate_derived_1(struct nvc0_context *nvc0)
 {
    struct nouveau_pushbuf *push = nvc0->base.pushbuf;
-   boolean early_z;
    boolean rasterizer_discard;
 
-   early_z = nvc0->fragprog->fp.early_z && !nvc0->zsa->pipe.alpha.enabled;
-
-   if (early_z != nvc0->state.early_z) {
-      nvc0->state.early_z = early_z;
-      IMMED_NVC0(push, NVC0_3D(EARLY_FRAGMENT_TESTS), early_z);
-   }
-
    rasterizer_discard = (!nvc0->fragprog || !nvc0->fragprog->hdr[18]) &&
       !nvc0->zsa->pipe.depth.enabled && !nvc0->zsa->pipe.stencil[0].enabled;
    rasterizer_discard = rasterizer_discard ||