mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 08:50:13 +01:00
i965: Port Gen8+ 3DSTATE_RASTER state to genxml.
Emits 3DSTATE_RASTER from genX_state_upload.c using pack structs from genxml. v3: - Style fixes (Ken) Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
36c02ce448
commit
13ac46557a
3 changed files with 123 additions and 127 deletions
|
|
@ -156,7 +156,6 @@ extern const struct brw_tracked_state gen8_ps_blend;
|
|||
extern const struct brw_tracked_state gen8_ps_extra;
|
||||
extern const struct brw_tracked_state gen8_ps_state;
|
||||
extern const struct brw_tracked_state gen8_wm_state;
|
||||
extern const struct brw_tracked_state gen8_raster_state;
|
||||
extern const struct brw_tracked_state gen8_sbe_state;
|
||||
extern const struct brw_tracked_state gen8_sf_state;
|
||||
extern const struct brw_tracked_state gen8_sf_clip_viewport;
|
||||
|
|
|
|||
|
|
@ -224,128 +224,3 @@ const struct brw_tracked_state gen8_sf_state = {
|
|||
},
|
||||
.emit = upload_sf,
|
||||
};
|
||||
|
||||
static void
|
||||
upload_raster(struct brw_context *brw)
|
||||
{
|
||||
struct gl_context *ctx = &brw->ctx;
|
||||
uint32_t dw1 = 0;
|
||||
|
||||
/* _NEW_BUFFERS */
|
||||
bool render_to_fbo = _mesa_is_user_fbo(brw->ctx.DrawBuffer);
|
||||
|
||||
/* _NEW_POLYGON */
|
||||
if (ctx->Polygon._FrontBit == render_to_fbo)
|
||||
dw1 |= GEN8_RASTER_FRONT_WINDING_CCW;
|
||||
|
||||
if (ctx->Polygon.CullFlag) {
|
||||
switch (ctx->Polygon.CullFaceMode) {
|
||||
case GL_FRONT:
|
||||
dw1 |= GEN8_RASTER_CULL_FRONT;
|
||||
break;
|
||||
case GL_BACK:
|
||||
dw1 |= GEN8_RASTER_CULL_BACK;
|
||||
break;
|
||||
case GL_FRONT_AND_BACK:
|
||||
dw1 |= GEN8_RASTER_CULL_BOTH;
|
||||
break;
|
||||
default:
|
||||
unreachable("not reached");
|
||||
}
|
||||
} else {
|
||||
dw1 |= GEN8_RASTER_CULL_NONE;
|
||||
}
|
||||
|
||||
/* _NEW_POINT */
|
||||
if (ctx->Point.SmoothFlag)
|
||||
dw1 |= GEN8_RASTER_SMOOTH_POINT_ENABLE;
|
||||
|
||||
if (_mesa_is_multisample_enabled(ctx))
|
||||
dw1 |= GEN8_RASTER_API_MULTISAMPLE_ENABLE;
|
||||
|
||||
if (ctx->Polygon.OffsetFill)
|
||||
dw1 |= GEN6_SF_GLOBAL_DEPTH_OFFSET_SOLID;
|
||||
|
||||
if (ctx->Polygon.OffsetLine)
|
||||
dw1 |= GEN6_SF_GLOBAL_DEPTH_OFFSET_WIREFRAME;
|
||||
|
||||
if (ctx->Polygon.OffsetPoint)
|
||||
dw1 |= GEN6_SF_GLOBAL_DEPTH_OFFSET_POINT;
|
||||
|
||||
switch (ctx->Polygon.FrontMode) {
|
||||
case GL_FILL:
|
||||
dw1 |= GEN6_SF_FRONT_SOLID;
|
||||
break;
|
||||
case GL_LINE:
|
||||
dw1 |= GEN6_SF_FRONT_WIREFRAME;
|
||||
break;
|
||||
case GL_POINT:
|
||||
dw1 |= GEN6_SF_FRONT_POINT;
|
||||
break;
|
||||
|
||||
default:
|
||||
unreachable("not reached");
|
||||
}
|
||||
|
||||
switch (ctx->Polygon.BackMode) {
|
||||
case GL_FILL:
|
||||
dw1 |= GEN6_SF_BACK_SOLID;
|
||||
break;
|
||||
case GL_LINE:
|
||||
dw1 |= GEN6_SF_BACK_WIREFRAME;
|
||||
break;
|
||||
case GL_POINT:
|
||||
dw1 |= GEN6_SF_BACK_POINT;
|
||||
break;
|
||||
default:
|
||||
unreachable("not reached");
|
||||
}
|
||||
|
||||
/* _NEW_LINE */
|
||||
if (ctx->Line.SmoothFlag)
|
||||
dw1 |= GEN8_RASTER_LINE_AA_ENABLE;
|
||||
|
||||
/* _NEW_SCISSOR */
|
||||
if (ctx->Scissor.EnableFlags)
|
||||
dw1 |= GEN8_RASTER_SCISSOR_ENABLE;
|
||||
|
||||
/* _NEW_TRANSFORM */
|
||||
if (!ctx->Transform.DepthClamp) {
|
||||
if (brw->gen >= 9) {
|
||||
dw1 |= GEN9_RASTER_VIEWPORT_Z_NEAR_CLIP_TEST_ENABLE |
|
||||
GEN9_RASTER_VIEWPORT_Z_FAR_CLIP_TEST_ENABLE;
|
||||
} else {
|
||||
dw1 |= GEN8_RASTER_VIEWPORT_Z_CLIP_TEST_ENABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/* BRW_NEW_CONSERVATIVE_RASTERIZATION */
|
||||
if (ctx->IntelConservativeRasterization) {
|
||||
if (brw->gen >= 9)
|
||||
dw1 |= GEN9_RASTER_CONSERVATIVE_RASTERIZATION_ENABLE;
|
||||
}
|
||||
|
||||
BEGIN_BATCH(5);
|
||||
OUT_BATCH(_3DSTATE_RASTER << 16 | (5 - 2));
|
||||
OUT_BATCH(dw1);
|
||||
OUT_BATCH_F(ctx->Polygon.OffsetUnits * 2); /* constant. copied from gen4 */
|
||||
OUT_BATCH_F(ctx->Polygon.OffsetFactor); /* scale */
|
||||
OUT_BATCH_F(ctx->Polygon.OffsetClamp); /* global depth offset clamp */
|
||||
ADVANCE_BATCH();
|
||||
}
|
||||
|
||||
const struct brw_tracked_state gen8_raster_state = {
|
||||
.dirty = {
|
||||
.mesa = _NEW_BUFFERS |
|
||||
_NEW_LINE |
|
||||
_NEW_MULTISAMPLE |
|
||||
_NEW_POINT |
|
||||
_NEW_POLYGON |
|
||||
_NEW_SCISSOR |
|
||||
_NEW_TRANSFORM,
|
||||
.brw = BRW_NEW_BLORP |
|
||||
BRW_NEW_CONTEXT |
|
||||
BRW_NEW_CONSERVATIVE_RASTERIZATION,
|
||||
},
|
||||
.emit = upload_raster,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -338,9 +338,131 @@ static const struct brw_tracked_state genX(clip_state) = {
|
|||
.emit = genX(upload_clip_state),
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
#if GEN_GEN >= 8
|
||||
static void
|
||||
genX(upload_raster)(struct brw_context *brw)
|
||||
{
|
||||
struct gl_context *ctx = &brw->ctx;
|
||||
|
||||
/* _NEW_BUFFERS */
|
||||
bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
|
||||
|
||||
/* _NEW_POLYGON */
|
||||
struct gl_polygon_attrib *polygon = &ctx->Polygon;
|
||||
|
||||
/* _NEW_POINT */
|
||||
struct gl_point_attrib *point = &ctx->Point;
|
||||
|
||||
brw_batch_emit(brw, GENX(3DSTATE_RASTER), raster) {
|
||||
if (polygon->_FrontBit == render_to_fbo)
|
||||
raster.FrontWinding = CounterClockwise;
|
||||
|
||||
if (polygon->CullFlag) {
|
||||
switch (polygon->CullFaceMode) {
|
||||
case GL_FRONT:
|
||||
raster.CullMode = CULLMODE_FRONT;
|
||||
break;
|
||||
case GL_BACK:
|
||||
raster.CullMode = CULLMODE_BACK;
|
||||
break;
|
||||
case GL_FRONT_AND_BACK:
|
||||
raster.CullMode = CULLMODE_BOTH;
|
||||
break;
|
||||
default:
|
||||
unreachable("not reached");
|
||||
}
|
||||
} else {
|
||||
raster.CullMode = CULLMODE_NONE;
|
||||
}
|
||||
|
||||
point->SmoothFlag = raster.SmoothPointEnable;
|
||||
|
||||
raster.DXMultisampleRasterizationEnable =
|
||||
_mesa_is_multisample_enabled(ctx);
|
||||
|
||||
raster.GlobalDepthOffsetEnableSolid = polygon->OffsetFill;
|
||||
raster.GlobalDepthOffsetEnableWireframe = polygon->OffsetLine;
|
||||
raster.GlobalDepthOffsetEnablePoint = polygon->OffsetPoint;
|
||||
|
||||
switch (polygon->FrontMode) {
|
||||
case GL_FILL:
|
||||
raster.FrontFaceFillMode = FILL_MODE_SOLID;
|
||||
break;
|
||||
case GL_LINE:
|
||||
raster.FrontFaceFillMode = FILL_MODE_WIREFRAME;
|
||||
break;
|
||||
case GL_POINT:
|
||||
raster.FrontFaceFillMode = FILL_MODE_POINT;
|
||||
break;
|
||||
default:
|
||||
unreachable("not reached");
|
||||
}
|
||||
|
||||
switch (polygon->BackMode) {
|
||||
case GL_FILL:
|
||||
raster.BackFaceFillMode = FILL_MODE_SOLID;
|
||||
break;
|
||||
case GL_LINE:
|
||||
raster.BackFaceFillMode = FILL_MODE_WIREFRAME;
|
||||
break;
|
||||
case GL_POINT:
|
||||
raster.BackFaceFillMode = FILL_MODE_POINT;
|
||||
break;
|
||||
default:
|
||||
unreachable("not reached");
|
||||
}
|
||||
|
||||
/* _NEW_LINE */
|
||||
raster.AntialiasingEnable = ctx->Line.SmoothFlag;
|
||||
|
||||
/* _NEW_SCISSOR */
|
||||
raster.ScissorRectangleEnable = ctx->Scissor.EnableFlags;
|
||||
|
||||
/* _NEW_TRANSFORM */
|
||||
if (!ctx->Transform.DepthClamp) {
|
||||
#if GEN_GEN >= 9
|
||||
raster.ViewportZFarClipTestEnable = true;
|
||||
raster.ViewportZNearClipTestEnable = true;
|
||||
#else
|
||||
raster.ViewportZClipTestEnable = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* BRW_NEW_CONSERVATIVE_RASTERIZATION */
|
||||
#if GEN_GEN >= 9
|
||||
raster.ConservativeRasterizationEnable =
|
||||
ctx->IntelConservativeRasterization;
|
||||
#endif
|
||||
|
||||
raster.GlobalDepthOffsetClamp = polygon->OffsetClamp;
|
||||
raster.GlobalDepthOffsetScale = polygon->OffsetFactor;
|
||||
|
||||
raster.GlobalDepthOffsetConstant = polygon->OffsetUnits * 2;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct brw_tracked_state genX(raster_state) = {
|
||||
.dirty = {
|
||||
.mesa = _NEW_BUFFERS |
|
||||
_NEW_LINE |
|
||||
_NEW_MULTISAMPLE |
|
||||
_NEW_POINT |
|
||||
_NEW_POLYGON |
|
||||
_NEW_SCISSOR |
|
||||
_NEW_TRANSFORM,
|
||||
.brw = BRW_NEW_BLORP |
|
||||
BRW_NEW_CONTEXT |
|
||||
BRW_NEW_CONSERVATIVE_RASTERIZATION,
|
||||
},
|
||||
.emit = genX(upload_raster),
|
||||
};
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
genX(init_atoms)(struct brw_context *brw)
|
||||
|
|
@ -623,7 +745,7 @@ genX(init_atoms)(struct brw_context *brw)
|
|||
&gen8_gs_state,
|
||||
&gen7_sol_state,
|
||||
&genX(clip_state),
|
||||
&gen8_raster_state,
|
||||
&genX(raster_state),
|
||||
&gen8_sbe_state,
|
||||
&gen8_sf_state,
|
||||
&gen8_ps_blend,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue