anv/cmd_buffer: Use a temporary variable for dynamic state

We were already doing this for some packets to keep the lines shorter.
We may as well just do it for all of them.

Tested-by: Józef Kucia <joseph.kucia@gmail.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Cc: "18.0" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
Jason Ekstrand
2017-12-15 16:47:56 -08:00
parent 8bd5ec5b86
commit 24caee8975
2 changed files with 24 additions and 27 deletions

View File

@@ -155,6 +155,7 @@ void
genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
{ {
struct anv_pipeline *pipeline = cmd_buffer->state.gfx.base.pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.gfx.base.pipeline;
struct anv_dynamic_state *d = &cmd_buffer->state.dynamic;
if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE | if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE |
ANV_CMD_DIRTY_RENDER_TARGETS | ANV_CMD_DIRTY_RENDER_TARGETS |
@@ -164,10 +165,10 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
struct GENX(3DSTATE_SF) sf = { struct GENX(3DSTATE_SF) sf = {
GENX(3DSTATE_SF_header), GENX(3DSTATE_SF_header),
.DepthBufferSurfaceFormat = get_depth_format(cmd_buffer), .DepthBufferSurfaceFormat = get_depth_format(cmd_buffer),
.LineWidth = cmd_buffer->state.dynamic.line_width, .LineWidth = d->line_width,
.GlobalDepthOffsetConstant = cmd_buffer->state.dynamic.depth_bias.bias, .GlobalDepthOffsetConstant = d->depth_bias.bias,
.GlobalDepthOffsetScale = cmd_buffer->state.dynamic.depth_bias.slope, .GlobalDepthOffsetScale = d->depth_bias.slope,
.GlobalDepthOffsetClamp = cmd_buffer->state.dynamic.depth_bias.clamp .GlobalDepthOffsetClamp = d->depth_bias.clamp
}; };
GENX(3DSTATE_SF_pack)(NULL, sf_dw, &sf); GENX(3DSTATE_SF_pack)(NULL, sf_dw, &sf);
@@ -176,16 +177,15 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS | if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS |
ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE)) { ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE)) {
struct anv_dynamic_state *d = &cmd_buffer->state.dynamic;
struct anv_state cc_state = struct anv_state cc_state =
anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, anv_cmd_buffer_alloc_dynamic_state(cmd_buffer,
GENX(COLOR_CALC_STATE_length) * 4, GENX(COLOR_CALC_STATE_length) * 4,
64); 64);
struct GENX(COLOR_CALC_STATE) cc = { struct GENX(COLOR_CALC_STATE) cc = {
.BlendConstantColorRed = cmd_buffer->state.dynamic.blend_constants[0], .BlendConstantColorRed = d->blend_constants[0],
.BlendConstantColorGreen = cmd_buffer->state.dynamic.blend_constants[1], .BlendConstantColorGreen = d->blend_constants[1],
.BlendConstantColorBlue = cmd_buffer->state.dynamic.blend_constants[2], .BlendConstantColorBlue = d->blend_constants[2],
.BlendConstantColorAlpha = cmd_buffer->state.dynamic.blend_constants[3], .BlendConstantColorAlpha = d->blend_constants[3],
.StencilReferenceValue = d->stencil_reference.front & 0xff, .StencilReferenceValue = d->stencil_reference.front & 0xff,
.BackfaceStencilReferenceValue = d->stencil_reference.back & 0xff, .BackfaceStencilReferenceValue = d->stencil_reference.back & 0xff,
}; };
@@ -202,7 +202,6 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
ANV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK | ANV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK |
ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK)) { ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK)) {
uint32_t depth_stencil_dw[GENX(DEPTH_STENCIL_STATE_length)]; uint32_t depth_stencil_dw[GENX(DEPTH_STENCIL_STATE_length)];
struct anv_dynamic_state *d = &cmd_buffer->state.dynamic;
struct GENX(DEPTH_STENCIL_STATE) depth_stencil = { struct GENX(DEPTH_STENCIL_STATE) depth_stencil = {
.StencilTestMask = d->stencil_compare_mask.front & 0xff, .StencilTestMask = d->stencil_compare_mask.front & 0xff,

View File

@@ -382,6 +382,7 @@ void
genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
{ {
struct anv_pipeline *pipeline = cmd_buffer->state.gfx.base.pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.gfx.base.pipeline;
struct anv_dynamic_state *d = &cmd_buffer->state.dynamic;
if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE | if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE |
ANV_CMD_DIRTY_DYNAMIC_LINE_WIDTH)) { ANV_CMD_DIRTY_DYNAMIC_LINE_WIDTH)) {
@@ -391,12 +392,12 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
}; };
#if GEN_GEN == 8 #if GEN_GEN == 8
if (cmd_buffer->device->info.is_cherryview) { if (cmd_buffer->device->info.is_cherryview) {
sf.CHVLineWidth = cmd_buffer->state.dynamic.line_width; sf.CHVLineWidth = d->line_width;
} else { } else {
sf.LineWidth = cmd_buffer->state.dynamic.line_width; sf.LineWidth = d->line_width;
} }
#else #else
sf.LineWidth = cmd_buffer->state.dynamic.line_width, sf.LineWidth = d->line_width,
#endif #endif
GENX(3DSTATE_SF_pack)(NULL, sf_dw, &sf); GENX(3DSTATE_SF_pack)(NULL, sf_dw, &sf);
anv_batch_emit_merge(&cmd_buffer->batch, sf_dw, pipeline->gen8.sf); anv_batch_emit_merge(&cmd_buffer->batch, sf_dw, pipeline->gen8.sf);
@@ -407,9 +408,9 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
uint32_t raster_dw[GENX(3DSTATE_RASTER_length)]; uint32_t raster_dw[GENX(3DSTATE_RASTER_length)];
struct GENX(3DSTATE_RASTER) raster = { struct GENX(3DSTATE_RASTER) raster = {
GENX(3DSTATE_RASTER_header), GENX(3DSTATE_RASTER_header),
.GlobalDepthOffsetConstant = cmd_buffer->state.dynamic.depth_bias.bias, .GlobalDepthOffsetConstant = d->depth_bias.bias,
.GlobalDepthOffsetScale = cmd_buffer->state.dynamic.depth_bias.slope, .GlobalDepthOffsetScale = d->depth_bias.slope,
.GlobalDepthOffsetClamp = cmd_buffer->state.dynamic.depth_bias.clamp .GlobalDepthOffsetClamp = d->depth_bias.clamp
}; };
GENX(3DSTATE_RASTER_pack)(NULL, raster_dw, &raster); GENX(3DSTATE_RASTER_pack)(NULL, raster_dw, &raster);
anv_batch_emit_merge(&cmd_buffer->batch, raster_dw, anv_batch_emit_merge(&cmd_buffer->batch, raster_dw,
@@ -424,16 +425,15 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
#if GEN_GEN == 8 #if GEN_GEN == 8
if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS | if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS |
ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE)) { ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE)) {
struct anv_dynamic_state *d = &cmd_buffer->state.dynamic;
struct anv_state cc_state = struct anv_state cc_state =
anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, anv_cmd_buffer_alloc_dynamic_state(cmd_buffer,
GENX(COLOR_CALC_STATE_length) * 4, GENX(COLOR_CALC_STATE_length) * 4,
64); 64);
struct GENX(COLOR_CALC_STATE) cc = { struct GENX(COLOR_CALC_STATE) cc = {
.BlendConstantColorRed = cmd_buffer->state.dynamic.blend_constants[0], .BlendConstantColorRed = d->blend_constants[0],
.BlendConstantColorGreen = cmd_buffer->state.dynamic.blend_constants[1], .BlendConstantColorGreen = d->blend_constants[1],
.BlendConstantColorBlue = cmd_buffer->state.dynamic.blend_constants[2], .BlendConstantColorBlue = d->blend_constants[2],
.BlendConstantColorAlpha = cmd_buffer->state.dynamic.blend_constants[3], .BlendConstantColorAlpha = d->blend_constants[3],
.StencilReferenceValue = d->stencil_reference.front & 0xff, .StencilReferenceValue = d->stencil_reference.front & 0xff,
.BackfaceStencilReferenceValue = d->stencil_reference.back & 0xff, .BackfaceStencilReferenceValue = d->stencil_reference.back & 0xff,
}; };
@@ -452,7 +452,6 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
ANV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK | ANV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK |
ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK)) { ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK)) {
uint32_t wm_depth_stencil_dw[GENX(3DSTATE_WM_DEPTH_STENCIL_length)]; uint32_t wm_depth_stencil_dw[GENX(3DSTATE_WM_DEPTH_STENCIL_length)];
struct anv_dynamic_state *d = &cmd_buffer->state.dynamic;
struct GENX(3DSTATE_WM_DEPTH_STENCIL wm_depth_stencil) = { struct GENX(3DSTATE_WM_DEPTH_STENCIL wm_depth_stencil) = {
GENX(3DSTATE_WM_DEPTH_STENCIL_header), GENX(3DSTATE_WM_DEPTH_STENCIL_header),
@@ -483,10 +482,10 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
GENX(COLOR_CALC_STATE_length) * 4, GENX(COLOR_CALC_STATE_length) * 4,
64); 64);
struct GENX(COLOR_CALC_STATE) cc = { struct GENX(COLOR_CALC_STATE) cc = {
.BlendConstantColorRed = cmd_buffer->state.dynamic.blend_constants[0], .BlendConstantColorRed = d->blend_constants[0],
.BlendConstantColorGreen = cmd_buffer->state.dynamic.blend_constants[1], .BlendConstantColorGreen = d->blend_constants[1],
.BlendConstantColorBlue = cmd_buffer->state.dynamic.blend_constants[2], .BlendConstantColorBlue = d->blend_constants[2],
.BlendConstantColorAlpha = cmd_buffer->state.dynamic.blend_constants[3], .BlendConstantColorAlpha = d->blend_constants[3],
}; };
GENX(COLOR_CALC_STATE_pack)(NULL, cc_state.map, &cc); GENX(COLOR_CALC_STATE_pack)(NULL, cc_state.map, &cc);
@@ -504,7 +503,6 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK | ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK |
ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE)) { ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE)) {
uint32_t dwords[GENX(3DSTATE_WM_DEPTH_STENCIL_length)]; uint32_t dwords[GENX(3DSTATE_WM_DEPTH_STENCIL_length)];
struct anv_dynamic_state *d = &cmd_buffer->state.dynamic;
struct GENX(3DSTATE_WM_DEPTH_STENCIL) wm_depth_stencil = { struct GENX(3DSTATE_WM_DEPTH_STENCIL) wm_depth_stencil = {
GENX(3DSTATE_WM_DEPTH_STENCIL_header), GENX(3DSTATE_WM_DEPTH_STENCIL_header),