nvc0: enable GL_NV_viewport_array2
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 11 Apr 2020 03:47:04 +0000 (23:47 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Thu, 16 Apr 2020 00:21:18 +0000 (20:21 -0400)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-By: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4529>

src/gallium/drivers/nouveau/codegen/nv50_ir.h
src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h
src/gallium/drivers/nouveau/nvc0/nvc0_program.c
src/gallium/drivers/nouveau/nvc0/nvc0_program.h
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c

index 296b79f5d4941d0de29c728f4b7baf43e84ccc69..42ee969c66bb3f4aec7625c43e58038e0e2a0b80 100644 (file)
@@ -467,6 +467,7 @@ enum SVSemantic
    SV_VERTEX_COUNT, // gl_PatchVerticesIn
    SV_LAYER,
    SV_VIEWPORT_INDEX,
+   SV_VIEWPORT_MASK,
    SV_YDIR,
    SV_FACE,
    SV_POINT_SIZE,
index 322bdd02557614e3358c0c74d192bd4ea69c355f..5dc0e24c5dcc01254f7c4774bf6cb42c79b28b11 100644 (file)
@@ -177,6 +177,7 @@ struct nv50_ir_prog_info
       uint8_t globalAccess;      /* 1 for read, 2 for wr, 3 for rw */
       bool fp64;                 /* program uses fp64 math */
       bool mul_zero_wins;        /* program wants for x*0 = 0 */
+      bool layer_viewport_relative;
       bool nv50styleSurfaces;    /* generate gX[] access for raw buffers */
       uint16_t texBindBase;      /* base address for tex handles (nve4) */
       uint16_t fbtexBindBase;    /* base address for fbtex handle (nve4) */
index 3375c599e7593bf8a4829b1f7fb251ea2bfd85e4..60f3d582a0bb7668f2d022a089848da3413a065e 100644 (file)
@@ -1229,6 +1229,9 @@ void Source::scanProperty(const struct tgsi_full_property *prop)
    case TGSI_PROPERTY_MUL_ZERO_WINS:
       info->io.mul_zero_wins = prop->u[0].Data;
       break;
+   case TGSI_PROPERTY_LAYER_VIEWPORT_RELATIVE:
+      info->io.layer_viewport_relative = prop->u[0].Data;
+      break;
    default:
       INFO("unhandled TGSI property %d\n", prop->Property.PropertyName);
       break;
@@ -1548,6 +1551,7 @@ bool Source::scanInstruction(const struct tgsi_full_instruction *inst)
              info->out[dst.getIndex(0)].sn == TGSI_SEMANTIC_PRIMID ||
              info->out[dst.getIndex(0)].sn == TGSI_SEMANTIC_LAYER ||
              info->out[dst.getIndex(0)].sn == TGSI_SEMANTIC_VIEWPORT_INDEX ||
+             info->out[dst.getIndex(0)].sn == TGSI_SEMANTIC_VIEWPORT_MASK ||
              info->out[dst.getIndex(0)].sn == TGSI_SEMANTIC_FOG)
             info->out[dst.getIndex(0)].mask &= 1;
 
index 33a5310b27e11307f724e4aa392ba71c6545d247..221bab3105b4020530c2c49ad042aa65cc071d3f 100644 (file)
@@ -851,6 +851,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_TYPE_FLOAT                0x38000000
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_BGRA                      0x80000000
 
+#define NVC0_3D_LAYER_VIEWPORT_RELATIVE                                0x000011f0
+
 #define NVC0_3D_UNK1214                                        0x00001214
 
 #define NVC0_3D_UNK1218                                        0x00001218
index 128b94e1da51a3980e805cfd3c047fb109592975..32aa82d168c2f84d1d6e2f629b493d5aaa8c1cc8 100644 (file)
@@ -81,7 +81,7 @@ nvc0_shader_output_address(unsigned sn, unsigned si)
    case TGSI_SEMANTIC_CLIPDIST:      return 0x2c0 + si * 0x10;
    case TGSI_SEMANTIC_CLIPVERTEX:    return 0x270;
    case TGSI_SEMANTIC_TEXCOORD:      return 0x300 + si * 0x10;
-   /* case TGSI_SEMANTIC_VIEWPORT_MASK: return 0x3a0; */
+   case TGSI_SEMANTIC_VIEWPORT_MASK: return 0x3a0;
    case TGSI_SEMANTIC_EDGEFLAG:      return ~0;
    default:
       assert(!"invalid TGSI output semantic");
@@ -272,6 +272,8 @@ nvc0_vtgp_gen_header(struct nvc0_program *vp, struct nv50_ir_prog_info *info)
    if (info->io.genUserClip < 0)
       vp->vp.num_ucps = PIPE_MAX_CLIP_PLANES + 1; /* prevent rebuilding */
 
+   vp->vp.layer_viewport_relative = info->io.layer_viewport_relative;
+
    return 0;
 }
 
index 183b14a42c2c2d2dc010ece70aaef77b7b5a70a0..5684207aa5498b9dfbd57fe859b12092df3cd8f6 100644 (file)
@@ -41,6 +41,7 @@ struct nvc0_program {
       uint8_t edgeflag; /* attribute index of edgeflag input */
       bool need_vertex_id;
       bool need_draw_parameters;
+      bool layer_viewport_relative; /* also applies go gp and tp */
    } vp;
    struct {
       uint8_t early_z;
index f8550be7082d570839acfd0508d4b1d39e33fe6a..0148f78a7508308fe1da380bacdc2ccdd96b744e 100644 (file)
@@ -312,6 +312,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_CONSERVATIVE_RASTER_POST_DEPTH_COVERAGE:
    case PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS:
    case PIPE_CAP_VIEWPORT_SWIZZLE:
+   case PIPE_CAP_VIEWPORT_MASK:
       return class_3d >= GM200_3D_CLASS;
    case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_TRIANGLES:
       return class_3d >= GP100_3D_CLASS;
index 774c564811387f7209c67f60e264cc7b8f81e327..b7e0c8a930f37c719c4218a55e26493b94c685d9 100644 (file)
@@ -257,6 +257,7 @@ nvc0_layer_validate(struct nvc0_context *nvc0)
    struct nouveau_pushbuf *push = nvc0->base.pushbuf;
    struct nvc0_program *last;
    bool prog_selects_layer = false;
+   bool layer_viewport_relative = false;
 
    if (nvc0->gmtyprog)
       last = nvc0->gmtyprog;
@@ -265,11 +266,17 @@ nvc0_layer_validate(struct nvc0_context *nvc0)
    else
       last = nvc0->vertprog;
 
-   if (last)
+   if (last) {
       prog_selects_layer = !!(last->hdr[13] & (1 << 9));
+      layer_viewport_relative = last->vp.layer_viewport_relative;
+   }
 
    BEGIN_NVC0(push, NVC0_3D(LAYER), 1);
    PUSH_DATA (push, prog_selects_layer ? NVC0_3D_LAYER_USE_GP : 0);
+   if (nvc0->screen->eng3d->oclass >= GM200_3D_CLASS) {
+      IMMED_NVC0(push, NVC0_3D(LAYER_VIEWPORT_RELATIVE),
+                 layer_viewport_relative);
+   }
 }
 
 void