if (state == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ struct GEN8_COLOR_CALC_STATE color_calc_state = {
+ .BlendConstantColorRed = pCreateInfo->blendConst[0],
+ .BlendConstantColorGreen = pCreateInfo->blendConst[1],
+ .BlendConstantColorBlue = pCreateInfo->blendConst[2],
+ .BlendConstantColorAlpha = pCreateInfo->blendConst[3]
+ };
+
+ GEN8_COLOR_CALC_STATE_pack(NULL, state->state_color_calc, &color_calc_state);
+
*pState = (VkDynamicCbState) state;
return VK_SUCCESS;
struct GEN8_3DSTATE_WM_DEPTH_STENCIL wm_depth_stencil = {
GEN8_3DSTATE_WM_DEPTH_STENCIL_header,
- /* pCreateInfo->stencilFrontRef,
- * pCreateInfo->stencilBackRef,
- * go in cc state
- */
-
/* Is this what we need to do? */
.StencilBufferWriteEnable = pCreateInfo->stencilWriteMask != 0,
GEN8_3DSTATE_WM_DEPTH_STENCIL_pack(NULL, state->state_wm_depth_stencil,
&wm_depth_stencil);
+ struct GEN8_COLOR_CALC_STATE color_calc_state = {
+ .StencilReferenceValue = pCreateInfo->stencilFrontRef,
+ .BackFaceStencilReferenceValue = pCreateInfo->stencilBackRef
+ };
+
+ GEN8_COLOR_CALC_STATE_pack(NULL, state->state_color_calc, &color_calc_state);
+
*pState = (VkDynamicDsState) state;
return VK_SUCCESS;
}
}
+static struct anv_state
+anv_cmd_buffer_emit_dynamic(struct anv_cmd_buffer *cmd_buffer,
+ uint32_t *a, uint32_t dwords, uint32_t alignment)
+{
+ struct anv_device *device = cmd_buffer->device;
+ struct anv_state state;
+
+ state = anv_state_pool_alloc(&device->dynamic_state_pool, dwords * 4, alignment);
+ memcpy(state.map, a, dwords * 4);
+
+ return state;
+}
+
+static struct anv_state
+anv_cmd_buffer_merge_dynamic(struct anv_cmd_buffer *cmd_buffer,
+ uint32_t *a, uint32_t *b, uint32_t dwords, uint32_t alignment)
+{
+ struct anv_device *device = cmd_buffer->device;
+ struct anv_state state;
+ uint32_t *p;
+
+ state = anv_state_pool_alloc(&device->dynamic_state_pool, dwords * 4, alignment);
+ p = state.map;
+ for (uint32_t i = 0; i < dwords; i++)
+ p[i] = a[i] | b[i];
+
+ return state;
+}
+
static void
anv_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
{
cmd_buffer->ds_state->state_wm_depth_stencil,
pipeline->state_wm_depth_stencil);
+ if (cmd_buffer->dirty & (ANV_CMD_BUFFER_CB_DIRTY | ANV_CMD_BUFFER_DS_DIRTY)) {
+ struct anv_state state;
+ if (cmd_buffer->ds_state)
+ state = anv_cmd_buffer_merge_dynamic(cmd_buffer,
+ cmd_buffer->ds_state->state_color_calc,
+ cmd_buffer->cb_state->state_color_calc,
+ GEN8_COLOR_CALC_STATE_length, 32);
+ else
+ state = anv_cmd_buffer_emit_dynamic(cmd_buffer,
+ cmd_buffer->cb_state->state_color_calc,
+ GEN8_COLOR_CALC_STATE_length, 32);
+
+ anv_batch_emit(&cmd_buffer->batch,
+ GEN8_3DSTATE_CC_STATE_POINTERS,
+ .ColorCalcStatePointer = state.offset,
+ .ColorCalcStatePointerValid = true);
+ }
+
cmd_buffer->vb_dirty &= ~vb_emit;
cmd_buffer->dirty = 0;
}
struct anv_dynamic_ds_state {
uint32_t state_wm_depth_stencil[GEN8_3DSTATE_WM_DEPTH_STENCIL_length];
+ uint32_t state_color_calc[GEN8_COLOR_CALC_STATE_length];
};
struct anv_dynamic_cb_state {
- uint32_t blend_offset;
+ uint32_t state_color_calc[GEN8_COLOR_CALC_STATE_length];
+
};
struct anv_query_pool_slot {
#define ANV_CMD_BUFFER_DESCRIPTOR_SET_DIRTY (1 << 1)
#define ANV_CMD_BUFFER_RS_DIRTY (1 << 2)
#define ANV_CMD_BUFFER_DS_DIRTY (1 << 3)
+#define ANV_CMD_BUFFER_CB_DIRTY (1 << 4)
struct anv_bindings {
struct {
struct anv_dynamic_rs_state * rs_state;
struct anv_dynamic_ds_state * ds_state;
struct anv_dynamic_vp_state * vp_state;
+ struct anv_dynamic_cb_state * cb_state;
struct anv_bindings * bindings;
struct anv_bindings default_bindings;
};