32
32
#include "main/macros.h"
33
33
#include "intel_batchbuffer.h"
36
36
get_attr_override(struct brw_context *brw, int fs_attr, int two_side_color)
38
38
int attr_index = 0, i, vs_attr;
101
101
/* _NEW_BUFFER */
102
102
GLboolean render_to_fbo = brw->intel.ctx.DrawBuffer->Name != 0;
103
int attr = 0, input_index = 0;
105
105
int two_side_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide);
107
uint16_t attr_overrides[FRAG_ATTRIB_MAX];
107
109
/* _NEW_TRANSFORM */
108
110
if (ctx->Transform.ClipPlanesEnabled)
209
211
ctx->Point._Attenuated))
210
212
dw4 |= GEN6_SF_USE_STATE_POINT_WIDTH;
212
dw4 |= U_FIXED(CLAMP(ctx->Point.Size, 0.125, 255.875), 3) <<
213
GEN6_SF_POINT_WIDTH_SHIFT;
214
/* Clamp to ARB_point_parameters user limits */
215
point_size = CLAMP(ctx->Point.Size, ctx->Point.MinSize, ctx->Point.MaxSize);
217
/* Clamp to the hardware limits and convert to fixed point */
218
dw4 |= U_FIXED(CLAMP(point_size, 0.125, 255.875), 3);
214
220
if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT)
215
221
dw1 |= GEN6_SF_POINT_SPRITE_LOWERLEFT;
225
231
(1 << GEN6_SF_TRIFAN_PROVOKE_SHIFT);
228
if (ctx->Point.PointSprite) {
229
for (i = 0; i < 8; i++) {
230
if (ctx->Point.CoordReplace[i])
235
234
/* flat shading */
236
235
if (ctx->Light.ShadeModel == GL_FLAT) {
237
236
dw17 |= ((brw->fragment_program->Base.InputsRead & (FRAG_BIT_COL0 | FRAG_BIT_COL1)) >>
238
237
((brw->fragment_program->Base.InputsRead & FRAG_BIT_WPOS) ? 0 : 1));
240
/* Create the mapping from the FS inputs we produce to the VS outputs
243
for (; attr < FRAG_ATTRIB_MAX; attr++) {
244
if (!(brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr)))
248
if (ctx->Point.PointSprite &&
249
(attr >= FRAG_ATTRIB_TEX0 && attr <= FRAG_ATTRIB_TEX7) &&
250
ctx->Point.CoordReplace[attr - FRAG_ATTRIB_TEX0]) {
251
dw16 |= (1 << input_index);
254
if (attr == FRAG_ATTRIB_PNTC)
255
dw16 |= (1 << input_index);
257
/* The hardware can only do the overrides on 16 overrides at a
258
* time, and the other up to 16 have to be lined up so that the
259
* input index = the output index. We'll need to do some
260
* tweaking to make sure that's the case.
262
assert(input_index < 16 || attr == input_index);
264
attr_overrides[input_index++] = get_attr_override(brw, attr,
268
for (; input_index < FRAG_ATTRIB_MAX; input_index++)
269
attr_overrides[input_index] = 0;
242
OUT_BATCH(CMD_3D_SF_STATE << 16 | (20 - 2));
272
OUT_BATCH(_3DSTATE_SF << 16 | (20 - 2));
248
278
OUT_BATCH_F(ctx->Polygon.OffsetFactor); /* scale */
249
279
OUT_BATCH_F(0.0); /* XXX: global depth offset clamp */
250
280
for (i = 0; i < 8; i++) {
251
uint32_t attr_overrides = 0;
253
for (; attr < 64; attr++) {
254
if (brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr)) {
255
attr_overrides |= get_attr_override(brw, attr, two_side_color);
261
for (; attr < 64; attr++) {
262
if (brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr)) {
263
attr_overrides |= get_attr_override(brw, attr, two_side_color) << 16;
268
OUT_BATCH(attr_overrides);
281
OUT_BATCH(attr_overrides[i * 2] | attr_overrides[i * 2 + 1] << 16);
270
283
OUT_BATCH(dw16); /* point sprite texcoord bitmask */
271
284
OUT_BATCH(dw17); /* constant interp bitmask */