#define NVC0_3D_VERTEX_BASE_LOW 0x000015f8
#define NVC0_3D_POINT_COORD_REPLACE 0x00001604
-#define NVC0_3D_POINT_COORD_REPLACE_BITS__MASK 0x00001fff
-#define NVC0_3D_POINT_COORD_REPLACE_BITS__SHIFT 0
+#define NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN__MASK 0x00000004
+#define NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN__SHIFT 2
+#define NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN_LOWER_LEFT 0x00000000
+#define NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN_UPPER_LEFT 0x00000004
+#define NVC0_3D_POINT_COORD_REPLACE_ENABLE__MASK 0x000007f8
+#define NVC0_3D_POINT_COORD_REPLACE_ENABLE__SHIFT 3
#define NVC0_3D_CODE_ADDRESS_HIGH 0x00001608
#define NVC0_3D_POINT_RASTER_RULES_OGL 0x00000000
#define NVC0_3D_POINT_RASTER_RULES_D3D 0x00000001
-#define NVC0_3D_POINT_SPRITE_CTRL 0x00001660
-
#define NVC0_3D_TEX_MISC 0x00001664
#define NVC0_3D_TEX_MISC_SEAMLESS_CUBE_MAP 0x00000004
return 0x2e0;
*/
case TGSI_SEMANTIC_GENERIC:
+ /* We'd really like to distinguish between TEXCOORD and GENERIC here,
+ * since only 0x300 to 0x37c can be replaced by sprite coordinates.
+ * Also, gl_PointCoord should be a system value and must be assigned to
+ * address 0x2e0. For now, let's cheat:
+ */
assert(si < 31);
- return 0x80 + (si * 16);
+ if (si <= 7)
+ return 0x300 + si * 16;
+ if (si == 9)
+ return 0x2e0;
+ return 0x80 + ((si - 8) * 16);
case TGSI_SEMANTIC_NORMAL:
return 0x360;
case TGSI_SEMANTIC_PRIMID:
case TGSI_FILE_INPUT:
for (i = first; i <= last; ++i) {
if (ti->prog->type == PIPE_SHADER_VERTEX) {
- sn = TGSI_SEMANTIC_GENERIC;
- si = i;
+ for (c = 0; c < 4; ++c)
+ ti->input_loc[i][c] = 0x80 + i * 16 + c * 4;
+ } else {
+ for (c = 0; c < 4; ++c)
+ ti->input_loc[i][c] = nvc0_varying_location(sn, si) + c * 4;
+ /* for sprite coordinates: */
+ ti->prog->fp.in_pos[i] = ti->input_loc[i][0] / 4;
}
- for (c = 0; c < 4; ++c)
- ti->input_loc[i][c] = nvc0_varying_location(sn, si) + c * 4;
-
if (ti->prog->type == PIPE_SHADER_FRAGMENT)
ti->interp_mode[i] = nvc0_interp_mode(decl);
}
} else {
for (c = 0; c < 4; ++c)
ti->output_loc[i][c] = nvc0_varying_location(sn, si) + c * 4;
+ /* for TFB_VARYING_LOCS: */
+ ti->prog->vp.out_pos[i] = ti->output_loc[i][0] / 4;
}
}
break;
if (!ti->input_access[i][c])
continue;
a = ti->input_loc[i][c] / 2;
+ if (ti->input_loc[i][c] >= 0x2c0)
+ a -= 32;
if ((a & ~7) == 0x70/2)
fp->hdr[5] |= 1 << (28 + (a & 7) / 2); /* FRAG_COORD_UMASK */
else
unsigned code_size;
unsigned parm_size;
- uint32_t hdr[20];
+ uint32_t hdr[20]; /* TODO: move this into code to save space */
uint32_t flags[2];
struct {
uint8_t edgeflag;
uint8_t num_ucps;
+ uint8_t out_pos[PIPE_MAX_SHADER_OUTPUTS];
} vp;
struct {
uint8_t early_z;
+ uint8_t in_pos[PIPE_MAX_SHADER_INPUTS];
} fp;
void *relocs;
OUT_RINGp(chan, nvc0->rast->state, nvc0->rast->size);
}
+static void
+nvc0_validate_sprite_coords(struct nvc0_context *nvc0)
+{
+ struct nouveau_channel *chan = nvc0->screen->base.channel;
+ uint32_t reg;
+
+ if (nvc0->rast->pipe.sprite_coord_mode == PIPE_SPRITE_COORD_UPPER_LEFT)
+ reg = NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN_UPPER_LEFT;
+ else
+ reg = NVC0_3D_POINT_COORD_REPLACE_COORD_ORIGIN_LOWER_LEFT;
+
+ if (nvc0->rast->pipe.point_quad_rasterization) {
+ uint32_t en = nvc0->rast->pipe.sprite_coord_enable;
+ int i;
+ struct nvc0_program *prog = nvc0->fragprog;
+
+ while (en) {
+ i = ffs(en) - 1;
+ en &= ~(1 << i);
+ if (prog->fp.in_pos[i] >= 0xc0 && prog->fp.in_pos[i] < 0xe0)
+ reg |= 8 << ((prog->fp.in_pos[i] - 0xc0) / 4);
+ }
+ }
+
+ BEGIN_RING(chan, RING_3D(POINT_COORD_REPLACE), 1);
+ OUT_RING (chan, reg);
+}
+
static void
nvc0_constbufs_validate(struct nvc0_context *nvc0)
{
{ nvc0_tevlprog_validate, NVC0_NEW_TEVLPROG },
{ nvc0_gmtyprog_validate, NVC0_NEW_GMTYPROG },
{ nvc0_fragprog_validate, NVC0_NEW_FRAGPROG },
+ { nvc0_validate_sprite_coords, NVC0_NEW_RASTERIZER | NVC0_NEW_FRAGPROG },
{ nvc0_constbufs_validate, NVC0_NEW_CONSTBUF },
{ nvc0_validate_textures, NVC0_NEW_TEXTURES },
{ nvc0_validate_samplers, NVC0_NEW_SAMPLERS },