Skip to contentSkip to conversation

nv30: remove use_nv4x, it is identical to is_nv4x

PATCH New Ilia Mirkin 1 participant 4 messages Feb 21, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 nv30: remove use_nv4x, it is identical to is_nv4x

---

Perhaps there was a day when those were different, but that day is not today.

 src/gallium/drivers/nouveau/nv30/nv30_context.c  |  1 -
 src/gallium/drivers/nouveau/nv30/nv30_context.h  |  1 -
 src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c | 20 ++++++++++----------
 src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c |  8 ++++----
 4 files changed, 14 insertions(+), 16 deletions(-)
src/gallium/drivers/nouveau/nv30/nv30_context.c +0 -1
index 2146d27..4f68eee 100644
@@ -235,7 +235,6 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv)
 
    /*XXX: nvfx... */
    nv30->is_nv4x = (screen->eng3d->oclass >= NV40_3D_CLASS) ? ~0 : 0;
-   nv30->use_nv4x = (screen->eng3d->oclass >= NV40_3D_CLASS) ? ~0 : 0;
    nv30->render_mode = HW;
 
    nv30->sample_mask = 0xffff;
src/gallium/drivers/nouveau/nv30/nv30_context.h +0 -1
index 527614a..d0cb5f5 100644
@@ -121,7 +121,6 @@ struct nv30_context {
 
    /*XXX: nvfx state, DO NOT USE EVER OUTSIDE "STOLEN" NVFX code */
    unsigned is_nv4x;
-   unsigned use_nv4x;
    bool hw_pointsprite_control;
    enum {
       HW,
src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c +10 -10
index 4751ec8..ae4f789 100644
@@ -807,7 +807,7 @@ nvfx_fragprog_parse_instruction(struct nv30_context* nvfx, struct nvfx_fpc *fpc,
    case TGSI_OPCODE_IF:
       // MOVRC0 R31 (TR0.xyzw), R<src>:
       // IF (NE.xxxx) ELSE <else> END <end>
-      if(!nvfx->use_nv4x)
+      if(!nvfx->is_nv4x)
          goto nv3x_cflow;
       nv40_fp_if(fpc, src[0]);
       break;
@@ -815,7 +815,7 @@ nvfx_fragprog_parse_instruction(struct nv30_context* nvfx, struct nvfx_fpc *fpc,
    case TGSI_OPCODE_ELSE:
    {
       uint32_t *hw;
-      if(!nvfx->use_nv4x)
+      if(!nvfx->is_nv4x)
          goto nv3x_cflow;
       assert(util_dynarray_contains(&fpc->if_stack, unsigned));
       hw = &fpc->fp->insn[util_dynarray_top(&fpc->if_stack, unsigned)];
@@ -826,7 +826,7 @@ nvfx_fragprog_parse_instruction(struct nv30_context* nvfx, struct nvfx_fpc *fpc,
    case TGSI_OPCODE_ENDIF:
    {
       uint32_t *hw;
-      if(!nvfx->use_nv4x)
+      if(!nvfx->is_nv4x)
          goto nv3x_cflow;
       assert(util_dynarray_contains(&fpc->if_stack, unsigned));
       hw = &fpc->fp->insn[util_dynarray_pop(&fpc->if_stack, unsigned)];
@@ -849,19 +849,19 @@ nvfx_fragprog_parse_instruction(struct nv30_context* nvfx, struct nvfx_fpc *fpc,
       break;
 
    case TGSI_OPCODE_CAL:
-      if(!nvfx->use_nv4x)
+      if(!nvfx->is_nv4x)
          goto nv3x_cflow;
       nv40_fp_cal(fpc, finst->Label.Label);
       break;
 
    case TGSI_OPCODE_RET:
-      if(!nvfx->use_nv4x)
+      if(!nvfx->is_nv4x)
          goto nv3x_cflow;
       nv40_fp_ret(fpc);
       break;
 
    case TGSI_OPCODE_BGNLOOP:
-      if(!nvfx->use_nv4x)
+      if(!nvfx->is_nv4x)
          goto nv3x_cflow;
       /* TODO: we should support using two nested REPs to allow a > 255 iteration count */
       nv40_fp_rep(fpc, 255, finst->Label.Label);
@@ -871,7 +871,7 @@ nvfx_fragprog_parse_instruction(struct nv30_context* nvfx, struct nvfx_fpc *fpc,
       break;
 
    case TGSI_OPCODE_BRK:
-      if(!nvfx->use_nv4x)
+      if(!nvfx->is_nv4x)
          goto nv3x_cflow;
       nv40_fp_brk(fpc);
       break;
@@ -951,7 +951,7 @@ static boolean
 nvfx_fragprog_assign_generic(struct nv30_context *nvfx, struct nvfx_fpc *fpc,
                              const struct tgsi_full_declaration *fdec)
 {
-   unsigned num_texcoords = nvfx->use_nv4x ? 10 : 8;
+   unsigned num_texcoords = nvfx->is_nv4x ? 10 : 8;
    unsigned idx = fdec->Range.First;
    unsigned hw;
 
@@ -1002,7 +1002,7 @@ nvfx_fragprog_parse_decl_output(struct nv30_context* nvfx, struct nvfx_fpc *fpc,
       case 2: hw = 3; break;
       case 3: hw = 4; break;
       }
-      if(hw > ((nvfx->use_nv4x) ? 4 : 2)) {
+      if(hw > ((nvfx->is_nv4x) ? 4 : 2)) {
          NOUVEAU_ERR("bad rcol index\n");
          return FALSE;
       }
@@ -1129,7 +1129,7 @@ _nvfx_fragprog_translate(struct nv30_context *nvfx, struct nv30_fragprog *fp,
    if (!fpc)
       goto out_err;
 
-   fpc->max_temps = nvfx->use_nv4x ? 48 : 32;
+   fpc->max_temps = nvfx->is_nv4x ? 48 : 32;
    fpc->fp = fp;
    fpc->num_regs = 2;
    memset(fp->texcoord, 0xff, sizeof(fp->texcoord));
src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c +4 -4
index 3ae51ef..7642c5e 100644
@@ -313,8 +313,8 @@ nvfx_vp_emit(struct nvfx_vpc *vpc, struct nvfx_insn insn)
       hw[0] |= NVFX_VP(INST_COND_UPDATE_ENABLE);
 
    if(insn.sat) {
-      assert(nv30->use_nv4x);
-      if(nv30->use_nv4x)
+      assert(nv30->is_nv4x);
+      if(nv30->is_nv4x)
          hw[0] |= NV40_VP_INST_SATURATE;
    }
 
@@ -540,7 +540,7 @@ nvfx_vertprog_parse_instruction(struct nv30_context *nv30, struct nvfx_vpc *vpc,
    mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
    if(finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE) {
       assert(finst->Instruction.Opcode != TGSI_OPCODE_ARL);
-      if (nv30->use_nv4x)
+      if (nv30->is_nv4x)
          sat = TRUE;
       else
       if(dst.type != NVFXSR_TEMP)
@@ -802,7 +802,7 @@ nvfx_vertprog_parse_instruction(struct nv30_context *nv30, struct nvfx_vpc *vpc,
       return FALSE;
    }
 
-   if(finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE && !nv30->use_nv4x) {
+   if(finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE && !nv30->is_nv4x) {
       if (!vpc->r_0_1.type)
          vpc->r_0_1 = constant(vpc, -1, 0, 1, 0, 0);
       nvfx_vp_emit(vpc, arith(0, VEC, MAX, dst, mask, nvfx_src(dst), swz(nvfx_src(vpc->r_0_1), X, X, X, X), none));
Signature · 1 line
1.8.3.2

A message that is not in the archive (sent off-list or not yet received): 1392968233-26889-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/[email protected]

#2 lore raw

PATCH 2/4 nv30: remove unused render_mode and hw_pointsprite_control

---

Were these things that didn't get quite ported over from the old nvfx? If so, does it matter? Are they things we need? Even if they are, they can be implemented in a way that doesn't put that state into nv30_context.

 src/gallium/drivers/nouveau/nv30/nv30_context.c |  1 -
 src/gallium/drivers/nouveau/nv30/nv30_context.h | 10 +++-------
 2 files changed, 3 insertions(+), 8 deletions(-)
src/gallium/drivers/nouveau/nv30/nv30_context.c +0 -1
index 4f68eee..4a4538c 100644
@@ -235,7 +235,6 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv)
 
    /*XXX: nvfx... */
    nv30->is_nv4x = (screen->eng3d->oclass >= NV40_3D_CLASS) ? ~0 : 0;
-   nv30->render_mode = HW;
 
    nv30->sample_mask = 0xffff;
    nv30_vbo_init(pipe);
src/gallium/drivers/nouveau/nv30/nv30_context.h +3 -7
index d0cb5f5..864d97a 100644
@@ -119,16 +119,12 @@ struct nv30_context {
    struct nouveau_heap  *blit_vp;
    struct pipe_resource *blit_fp;
 
-   /*XXX: nvfx state, DO NOT USE EVER OUTSIDE "STOLEN" NVFX code */
-   unsigned is_nv4x;
-   bool hw_pointsprite_control;
-   enum {
-      HW,
-   } render_mode;
-
    struct pipe_query *render_cond_query;
    unsigned render_cond_mode;
    boolean render_cond_cond;
+
+   /*XXX: nvfx state, DO NOT USE EVER OUTSIDE "STOLEN" NVFX code */
+   unsigned is_nv4x;
 };
 
 static INLINE struct nv30_context *
Signature · 1 line
1.8.3.2
#3 lore raw

PATCH 3/4 nv30: remove unused sprite flipping parameter

In reply to a message not in the archive

---

I assume this is some left-over from nvfx -> nv30? That flag certainly doesn't do anything now...

 src/gallium/drivers/nouveau/nv30/nv30_context.h  | 3 +--
 src/gallium/drivers/nouveau/nv30/nv30_fragprog.c | 2 +-
 src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c | 3 +--
 3 files changed, 3 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/nv30/nv30_context.h +1 -2
index 864d97a..6dfab38 100644
@@ -214,8 +214,7 @@ nv30_state_release(struct nv30_context *nv30);
 
 //XXX: needed to make it build, clean this up!
 void
-_nvfx_fragprog_translate(struct nv30_context *nvfx, struct nv30_fragprog *fp,
-         boolean emulate_sprite_flipping);
+_nvfx_fragprog_translate(struct nv30_context *nvfx, struct nv30_fragprog *fp);
 
 boolean
 _nvfx_vertprog_translate(struct nv30_context *nv30, struct nv30_vertprog *vp);
src/gallium/drivers/nouveau/nv30/nv30_fragprog.c +1 -1
index e8acdfe..3551645 100644
@@ -67,7 +67,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
    int i;
 
    if (!fp->translated) {
-      _nvfx_fragprog_translate(nv30, fp, FALSE);
+      _nvfx_fragprog_translate(nv30, fp);
       if (!fp->translated)
          return;
 
src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c +1 -2
index ae4f789..bee23eb 100644
@@ -1114,8 +1114,7 @@ out_err:
 DEBUG_GET_ONCE_BOOL_OPTION(nvfx_dump_fp, "NVFX_DUMP_FP", FALSE)
 
 void
-_nvfx_fragprog_translate(struct nv30_context *nvfx, struct nv30_fragprog *fp,
-         boolean emulate_sprite_flipping)
+_nvfx_fragprog_translate(struct nv30_context *nvfx, struct nv30_fragprog *fp)
 {
    struct tgsi_parse_context parse;
    struct nvfx_fpc *fpc = NULL;
Signature · 1 line
1.8.3.2
#4 lore raw

PATCH 4/4 nv30: remove nv30_context use from nvfx_*prog

In reply to a message not in the archive

This should pave the way to being able to use the compiler without a context. Also leads to cleaner code.

---

So... there was a bit of an oops on this patch, I realized that NOUVEAU_ERR was supplied in silly places and decided to move it to a shared nouveau_debug. Ideally this would have been a separate patch, but I did things in the wrong order, and it's a pain to split it. Let me know if you _really_ want that, and I'll do it, but I'd rather not.

It's not really great that nvfx_*prog relies on nv30_*prog, but... wtvr. Not a huge deal. This patch sets up nvfx to be plug-in-able into nouveau_compiler.

 src/gallium/drivers/nouveau/codegen/nv50_ir.cpp  |  2 +-
 src/gallium/drivers/nouveau/nouveau_debug.h      | 25 +++++++++
 src/gallium/drivers/nouveau/nv30/nv30_context.c  |  3 --
 src/gallium/drivers/nouveau/nv30/nv30_context.h  | 10 ----
 src/gallium/drivers/nouveau/nv30/nv30_fragprog.c |  2 +-
 src/gallium/drivers/nouveau/nv30/nv30_screen.h   |  4 +-
 src/gallium/drivers/nouveau/nv30/nv30_vertprog.c |  3 +-
 src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c | 65 +++++++++++++-----------
 src/gallium/drivers/nouveau/nv30/nvfx_shader.h   | 12 ++++-
 src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c | 62 +++++++++++-----------
 src/gallium/drivers/nouveau/nv50/nv50_context.h  |  2 +-
 src/gallium/drivers/nouveau/nv50/nv50_debug.h    | 25 ---------
 src/gallium/drivers/nouveau/nvc0/nvc0_context.h  |  2 +-
 13 files changed, 110 insertions(+), 107 deletions(-)
 create mode 100644 src/gallium/drivers/nouveau/nouveau_debug.h
 delete mode 100644 src/gallium/drivers/nouveau/nv50/nv50_debug.h
src/gallium/drivers/nouveau/codegen/nv50_ir.cpp +1 -1
index 90fb51c..a24a66c 100644
@@ -25,8 +25,8 @@
 #include "codegen/nv50_ir_driver.h"
 
 extern "C" {
+#include "nouveau_debug.h"
 #include "nv50/nv50_program.h"
-#include "nv50/nv50_debug.h"
 }
 
 namespace nv50_ir {
src/gallium/drivers/nouveau/nouveau_debug.h new file +25 -0
new file mode 100644
index 0000000..d17df81
@@ -0,0 +1,25 @@
+
+#ifndef __NOUVEAU_DEBUG_H__
+#define __NOUVEAU_DEBUG_H__
+
+#include <stdio.h>
+
+#include "util/u_debug.h"
+
+#define NOUVEAU_DEBUG_MISC       0x0001
+#define NOUVEAU_DEBUG_SHADER     0x0100
+#define NOUVEAU_DEBUG_PROG_IR    0x0200
+#define NOUVEAU_DEBUG_PROG_RA    0x0400
+#define NOUVEAU_DEBUG_PROG_CFLOW 0x0800
+#define NOUVEAU_DEBUG_PROG_ALL   0x1f00
+
+#define NOUVEAU_DEBUG 0
+
+#define NOUVEAU_ERR(fmt, args...)                                 \
+   fprintf(stderr, "%s:%d - "fmt, __FUNCTION__, __LINE__, ##args)
+
+#define NOUVEAU_DBG(ch, args...)           \
+   if ((NOUVEAU_DEBUG) & (NOUVEAU_DEBUG_##ch))        \
+      debug_printf(args)
+
+#endif /* __NOUVEAU_DEBUG_H__ */
src/gallium/drivers/nouveau/nv30/nv30_context.c +0 -3
index 4a4538c..f325c5c 100644
@@ -233,9 +233,6 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv)
    if (debug_get_bool_option("NV30_SWTNL", FALSE))
       nv30->draw_flags |= NV30_NEW_SWTNL;
 
-   /*XXX: nvfx... */
-   nv30->is_nv4x = (screen->eng3d->oclass >= NV40_3D_CLASS) ? ~0 : 0;
-
    nv30->sample_mask = 0xffff;
    nv30_vbo_init(pipe);
    nv30_query_init(pipe);
src/gallium/drivers/nouveau/nv30/nv30_context.h +0 -10
index 6dfab38..7b32aae 100644
@@ -122,9 +122,6 @@ struct nv30_context {
    struct pipe_query *render_cond_query;
    unsigned render_cond_mode;
    boolean render_cond_cond;
-
-   /*XXX: nvfx state, DO NOT USE EVER OUTSIDE "STOLEN" NVFX code */
-   unsigned is_nv4x;
 };
 
 static INLINE struct nv30_context *
@@ -212,13 +209,6 @@ nv30_state_validate(struct nv30_context *nv30, boolean hwtnl);
 void
 nv30_state_release(struct nv30_context *nv30);
 
-//XXX: needed to make it build, clean this up!
-void
-_nvfx_fragprog_translate(struct nv30_context *nvfx, struct nv30_fragprog *fp);
-
-boolean
-_nvfx_vertprog_translate(struct nv30_context *nv30, struct nv30_vertprog *vp);
-
 #ifdef NV30_3D_VERTEX_BEGIN_END
 #define NV30_PRIM_GL_CASE(n) \
    case PIPE_PRIM_##n: return NV30_3D_VERTEX_BEGIN_END_##n
src/gallium/drivers/nouveau/nv30/nv30_fragprog.c +1 -1
index 3551645..a05bfe1 100644
@@ -67,7 +67,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
    int i;
 
    if (!fp->translated) {
-      _nvfx_fragprog_translate(nv30, fp);
+      _nvfx_fragprog_translate(eng3d->oclass, fp);
       if (!fp->translated)
          return;
 
src/gallium/drivers/nouveau/nv30/nv30_screen.h +1 -3
index c4c3aae..0b3bbbb 100644
@@ -3,11 +3,9 @@
 
 #include <stdio.h>
 
-#define NOUVEAU_ERR(fmt, args...) \
-   fprintf(stderr, "%s:%d -  "fmt, __FUNCTION__, __LINE__, ##args);
-
 #include "util/u_double_list.h"
 
+#include "nouveau_debug.h"
 #include "nouveau_screen.h"
 #include "nouveau_fence.h"
 #include "nouveau_heap.h"
src/gallium/drivers/nouveau/nv30/nv30_vertprog.c +2 -1
index 7bf05dd..3c1b7e7 100644
@@ -29,6 +29,7 @@
 #include "nv_object.xml.h"
 #include "nv30/nv30-40_3d.xml.h"
 #include "nv30/nv30_context.h"
+#include "nv30/nvfx_shader.h"
 #include "nv30/nv30_state.h"
 
 static void
@@ -75,7 +76,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
    }
 
    if (!vp->translated) {
-      vp->translated = _nvfx_vertprog_translate(nv30, vp);
+      vp->translated = _nvfx_vertprog_translate(eng3d->oclass, vp);
       if (!vp->translated) {
          nv30->draw_flags |= NV30_NEW_VERTPROG;
          return;
src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c +35 -30

250 lines not on this page · raw message

src/gallium/drivers/nouveau/nv30/nvfx_shader.h +11 -1
index 987e1b0..9538a79 100644
@@ -10,7 +10,7 @@
 /* this will resolve to either the NV30 or the NV40 version
  * depending on the current hardware */
 /* unusual, but very fast and compact method */
-#define NVFX_VP(c) ((NV30_VP_##c) + (nv30->is_nv4x & ((NV40_VP_##c) - (NV30_VP_##c))))
+#define NVFX_VP(c) ((NV30_VP_##c) + (vpc->is_nv4x & ((NV40_VP_##c) - (NV30_VP_##c))))
 
 #define NVFX_VP_INST_SLOT_VEC 0
 #define NVFX_VP_INST_SLOT_SCA 1
@@ -522,4 +522,14 @@ struct nvfx_relocation {
         unsigned target;
 };
 
+struct nv30_fragprog;
+struct nv30_vertprog;
+
+//XXX: needed to make it build, clean this up!
+void
+_nvfx_fragprog_translate(uint16_t oclass, struct nv30_fragprog *fp);
+
+boolean
+_nvfx_vertprog_translate(uint16_t oclass, struct nv30_vertprog *vp);
+
 #endif
src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c +32 -30

217 lines not on this page · raw message

src/gallium/drivers/nouveau/nv50/nv50_context.h +1 -1
index 84ff46e..32ca591 100644
@@ -14,7 +14,6 @@
 #include "draw/draw_vertex.h"
 #endif
 
-#include "nv50/nv50_debug.h"
 #include "nv50/nv50_winsys.h"
 #include "nv50/nv50_stateobj.h"
 #include "nv50/nv50_screen.h"
@@ -23,6 +22,7 @@
 #include "nv50/nv50_transfer.h"
 
 #include "nouveau_context.h"
+#include "nouveau_debug.h"
 #include "nv_object.xml.h"
 #include "nv_m2mf.xml.h"
 #include "nv50/nv50_3ddefs.xml.h"
src/gallium/drivers/nouveau/nv50/nv50_debug.h deleted +0 -25
deleted file mode 100644
index f3dee62..0000000
@@ -1,25 +0,0 @@
-
-#ifndef __NV50_DEBUG_H__
-#define __NV50_DEBUG_H__
-
-#include <stdio.h>
-
-#include "util/u_debug.h"
-
-#define NV50_DEBUG_MISC       0x0001
-#define NV50_DEBUG_SHADER     0x0100
-#define NV50_DEBUG_PROG_IR    0x0200
-#define NV50_DEBUG_PROG_RA    0x0400
-#define NV50_DEBUG_PROG_CFLOW 0x0800
-#define NV50_DEBUG_PROG_ALL   0x1f00
-
-#define NV50_DEBUG 0
-
-#define NOUVEAU_ERR(fmt, args...)                                 \
-   fprintf(stderr, "%s:%d - "fmt, __FUNCTION__, __LINE__, ##args)
-
-#define NV50_DBGMSG(ch, args...)           \
-   if ((NV50_DEBUG) & (NV50_DEBUG_##ch))        \
-      debug_printf(args)
-
-#endif /* __NV50_DEBUG_H__ */
src/gallium/drivers/nouveau/nvc0/nvc0_context.h +1 -1
index 3fbecdc..b6b5beb 100644
@@ -14,7 +14,6 @@
 #include "draw/draw_vertex.h"
 #endif
 
-#include "nv50/nv50_debug.h"
 #include "nvc0/nvc0_winsys.h"
 #include "nvc0/nvc0_stateobj.h"
 #include "nvc0/nvc0_screen.h"
@@ -24,6 +23,7 @@
 #include "nv50/nv50_transfer.h"
 
 #include "nouveau_context.h"
+#include "nouveau_debug.h"
 
 #include "nvc0/nvc0_3ddefs.xml.h"
 #include "nvc0/nvc0_3d.xml.h"
Signature · 1 line
1.8.3.2