Mesa (master): nvc0: enable GL_NV_viewport_array2

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 16 00:42:17 UTC 2020


Module: Mesa
Branch: master
Commit: 04a7ec7c8a7ca63fc3e90e5d2fe1290976a77bd6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=04a7ec7c8a7ca63fc3e90e5d2fe1290976a77bd6

Author: Ilia Mirkin <imirkin at alum.mit.edu>
Date:   Fri Apr 10 23:47:04 2020 -0400

nvc0: enable GL_NV_viewport_array2

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Reviewed-By: Karol Herbst <kherbst at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4529>

---

 src/gallium/drivers/nouveau/codegen/nv50_ir.h             | 1 +
 src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h      | 1 +
 src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 4 ++++
 src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h            | 2 ++
 src/gallium/drivers/nouveau/nvc0/nvc0_program.c           | 4 +++-
 src/gallium/drivers/nouveau/nvc0/nvc0_program.h           | 1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c            | 1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c      | 9 ++++++++-
 8 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
index 296b79f5d49..42ee969c66b 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
@@ -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,
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
index 322bdd02557..5dc0e24c5dc 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
@@ -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) */
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
index 3375c599e75..60f3d582a0b 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
@@ -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;
 
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h b/src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h
index 33a5310b27e..221bab3105b 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h
@@ -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
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
index 128b94e1da5..32aa82d168c 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
@@ -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;
 }
 
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.h b/src/gallium/drivers/nouveau/nvc0/nvc0_program.h
index 183b14a42c2..5684207aa54 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.h
@@ -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;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index f8550be7082..0148f78a750 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -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;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
index 774c5648113..b7e0c8a930f 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
@@ -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



More information about the mesa-commit mailing list