* IN THE SOFTWARE.
*/
+#include "compiler/nir/nir.h"
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
upload_sbe(struct brw_context *brw)
{
struct gl_context *ctx = &brw->ctx;
- /* CACHE_NEW_WM_PROG */
- uint32_t num_outputs = brw->wm.prog_data->num_varying_inputs;
+ /* BRW_NEW_FS_PROG_DATA */
+ const struct brw_wm_prog_data *wm_prog_data =
+ brw_wm_prog_data(brw->wm.base.prog_data);
+ uint32_t num_outputs = wm_prog_data->num_varying_inputs;
uint16_t attr_overrides[VARYING_SLOT_MAX];
uint32_t urb_entry_read_length;
+ uint32_t urb_entry_read_offset;
uint32_t point_sprite_enables;
- uint32_t flat_enables;
+ int sbe_cmd_length;
uint32_t dw1 =
GEN7_SBE_SWIZZLE_ENABLE |
num_outputs << GEN7_SBE_NUM_OUTPUTS_SHIFT;
+ uint32_t dw4 = 0;
+ uint32_t dw5 = 0;
/* _NEW_BUFFERS */
bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
else
dw1 |= GEN6_SF_POINT_SPRITE_UPPERLEFT;
- /* BRW_NEW_VUE_MAP_GEOM_OUT | _NEW_POINT | _NEW_LIGHT | _NEW_PROGRAM |
- * CACHE_NEW_WM_PROG
+ /* _NEW_POINT | _NEW_LIGHT | _NEW_PROGRAM,
+ * BRW_NEW_FS_PROG_DATA | BRW_NEW_FRAGMENT_PROGRAM |
+ * BRW_NEW_GS_PROG_DATA | BRW_NEW_PRIMITIVE | BRW_NEW_TES_PROG_DATA |
+ * BRW_NEW_VUE_MAP_GEOM_OUT
*/
calculate_attr_overrides(brw, attr_overrides,
&point_sprite_enables,
- &flat_enables,
- &urb_entry_read_length);
+ &urb_entry_read_length,
+ &urb_entry_read_offset);
/* Typically, the URB entry read length and offset should be programmed in
* 3DSTATE_VS and 3DSTATE_GS; SBE inherits it from the last active stage
*/
dw1 |=
urb_entry_read_length << GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT |
- BRW_SF_URB_ENTRY_READ_OFFSET << GEN8_SBE_URB_ENTRY_READ_OFFSET_SHIFT |
+ urb_entry_read_offset << GEN8_SBE_URB_ENTRY_READ_OFFSET_SHIFT |
GEN8_SBE_FORCE_URB_ENTRY_READ_LENGTH |
GEN8_SBE_FORCE_URB_ENTRY_READ_OFFSET;
- BEGIN_BATCH(4);
- OUT_BATCH(_3DSTATE_SBE << 16 | (4 - 2));
+ if (brw->gen == 8) {
+ sbe_cmd_length = 4;
+ } else {
+ sbe_cmd_length = 6;
+
+ /* prepare the active component dwords */
+ int input_index = 0;
+ for (int attr = 0; attr < VARYING_SLOT_MAX; attr++) {
+ if (!(brw->fragment_program->info.inputs_read &
+ BITFIELD64_BIT(attr))) {
+ continue;
+ }
+
+ assert(input_index < 32);
+
+ if (input_index < 16)
+ dw4 |= (GEN9_SBE_ACTIVE_COMPONENT_XYZW << (input_index << 1));
+ else
+ dw5 |= (GEN9_SBE_ACTIVE_COMPONENT_XYZW << ((input_index - 16) << 1));
+
+ ++input_index;
+ }
+ }
+ BEGIN_BATCH(sbe_cmd_length);
+ OUT_BATCH(_3DSTATE_SBE << 16 | (sbe_cmd_length - 2));
OUT_BATCH(dw1);
OUT_BATCH(point_sprite_enables);
- OUT_BATCH(flat_enables);
+ OUT_BATCH(wm_prog_data->flat_inputs);
+ if (sbe_cmd_length >= 6) {
+ OUT_BATCH(dw4);
+ OUT_BATCH(dw5);
+ }
ADVANCE_BATCH();
BEGIN_BATCH(11);
const struct brw_tracked_state gen8_sbe_state = {
.dirty = {
- .mesa = _NEW_BUFFERS | _NEW_LIGHT | _NEW_POINT | _NEW_PROGRAM,
- .brw = BRW_NEW_CONTEXT |
+ .mesa = _NEW_BUFFERS |
+ _NEW_LIGHT |
+ _NEW_POINT |
+ _NEW_POLYGON |
+ _NEW_PROGRAM,
+ .brw = BRW_NEW_BLORP |
+ BRW_NEW_CONTEXT |
BRW_NEW_FRAGMENT_PROGRAM |
+ BRW_NEW_FS_PROG_DATA |
+ BRW_NEW_GS_PROG_DATA |
+ BRW_NEW_TES_PROG_DATA |
BRW_NEW_VUE_MAP_GEOM_OUT,
- .cache = CACHE_NEW_WM_PROG,
},
.emit = upload_sbe,
};
uint32_t dw1 = 0, dw2 = 0, dw3 = 0;
float point_size;
- dw1 = GEN6_SF_STATISTICS_ENABLE | GEN6_SF_VIEWPORT_TRANSFORM_ENABLE;
+ dw1 = GEN6_SF_STATISTICS_ENABLE;
+
+ if (brw->sf.viewport_transform_enable)
+ dw1 |= GEN6_SF_VIEWPORT_TRANSFORM_ENABLE;
/* _NEW_LINE */
- uint32_t line_width_u3_7 = U_FIXED(CLAMP(ctx->Line.Width, 0.0, 7.99), 7);
- if (line_width_u3_7 == 0)
- line_width_u3_7 = 1;
- dw2 |= line_width_u3_7 << GEN6_SF_LINE_WIDTH_SHIFT;
+ uint32_t line_width_u3_7 = brw_get_line_width(brw);
+ if (brw->gen >= 9 || brw->is_cherryview) {
+ dw1 |= line_width_u3_7 << GEN9_SF_LINE_WIDTH_SHIFT;
+ } else {
+ dw2 |= line_width_u3_7 << GEN6_SF_LINE_WIDTH_SHIFT;
+ }
if (ctx->Line.SmoothFlag) {
dw2 |= GEN6_SF_LINE_END_CAP_WIDTH_1_0;
}
- /* Clamp to ARB_point_parameters user limits */
+ /* _NEW_POINT - Clamp to ARB_point_parameters user limits */
point_size = CLAMP(ctx->Point.Size, ctx->Point.MinSize, ctx->Point.MaxSize);
/* Clamp to the hardware limits and convert to fixed point */
- dw3 |= U_FIXED(CLAMP(point_size, 0.125, 255.875), 3);
+ dw3 |= U_FIXED(CLAMP(point_size, 0.125f, 255.875f), 3);
- /* _NEW_PROGRAM | _NEW_POINT */
- if (!(ctx->VertexProgram.PointSizeEnabled || ctx->Point._Attenuated))
+ /* _NEW_PROGRAM | _NEW_POINT, BRW_NEW_VUE_MAP_GEOM_OUT */
+ if (use_state_point_size(brw))
dw3 |= GEN6_SF_USE_STATE_POINT_WIDTH;
/* _NEW_POINT | _NEW_MULTISAMPLE */
- if ((ctx->Point.SmoothFlag || ctx->Multisample._Enabled) &&
+ if ((ctx->Point.SmoothFlag || _mesa_is_multisample_enabled(ctx)) &&
!ctx->Point.PointSprite) {
dw3 |= GEN8_SF_SMOOTH_POINT_ENABLE;
}
_NEW_LINE |
_NEW_MULTISAMPLE |
_NEW_POINT,
- .brw = BRW_NEW_CONTEXT,
- .cache = 0,
+ .brw = BRW_NEW_BLORP |
+ BRW_NEW_CONTEXT |
+ BRW_NEW_VUE_MAP_GEOM_OUT,
},
.emit = upload_sf,
};
bool render_to_fbo = _mesa_is_user_fbo(brw->ctx.DrawBuffer);
/* _NEW_POLYGON */
- if ((ctx->Polygon.FrontFace == GL_CCW) ^ render_to_fbo)
+ if (ctx->Polygon._FrontBit == render_to_fbo)
dw1 |= GEN8_RASTER_FRONT_WINDING_CCW;
if (ctx->Polygon.CullFlag) {
if (ctx->Point.SmoothFlag)
dw1 |= GEN8_RASTER_SMOOTH_POINT_ENABLE;
- if (ctx->Multisample._Enabled)
+ if (_mesa_is_multisample_enabled(ctx))
dw1 |= GEN8_RASTER_API_MULTISAMPLE_ENABLE;
if (ctx->Polygon.OffsetFill)
dw1 |= GEN8_RASTER_SCISSOR_ENABLE;
/* _NEW_TRANSFORM */
- if (!ctx->Transform.DepthClamp)
- dw1 |= GEN8_RASTER_VIEWPORT_Z_CLIP_TEST_ENABLE;
+ 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;
+ }
+ }
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(0.0);
+ OUT_BATCH_F(ctx->Polygon.OffsetClamp); /* global depth offset clamp */
ADVANCE_BATCH();
}
_NEW_POLYGON |
_NEW_SCISSOR |
_NEW_TRANSFORM,
- .brw = BRW_NEW_CONTEXT,
- .cache = 0,
+ .brw = BRW_NEW_BLORP |
+ BRW_NEW_CONTEXT,
},
.emit = upload_raster,
};