* This copies brw_stage_state::surf_offset[] into the indirect state section
* of the batchbuffer (allocated by brw_state_batch()).
*/
-void
+static void
brw_upload_binding_table(struct brw_context *brw,
+ uint32_t packet_name,
GLbitfield brw_new_binding_table,
- struct brw_stage_state *stage_state,
- unsigned binding_table_entries,
- int shader_time_surf_index)
+ struct brw_stage_state *stage_state)
{
- if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
- gen7_create_shader_time_surface(brw, &stage_state->surf_offset[shader_time_surf_index]);
- }
-
- /* If there are no surfaces, skip making the binding table altogether. */
- if (binding_table_entries == 0) {
- if (stage_state->bind_bo_offset != 0) {
- brw->state.dirty.brw |= brw_new_binding_table;
- stage_state->bind_bo_offset = 0;
+ /* CACHE_NEW_*_PROG */
+ struct brw_stage_prog_data *prog_data = stage_state->prog_data;
+
+ if (prog_data->binding_table.size_bytes == 0) {
+ /* There are no surfaces; skip making the binding table altogether. */
+ if (stage_state->bind_bo_offset == 0)
+ return;
+
+ stage_state->bind_bo_offset = 0;
+ } else {
+ /* Upload a new binding table. */
+ if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
+ brw->vtbl.create_raw_surface(
+ brw, brw->shader_time.bo, 0, brw->shader_time.bo->size,
+ &stage_state->surf_offset[prog_data->binding_table.shader_time_start], true);
}
- return;
- }
-
- size_t table_size_in_bytes = binding_table_entries * sizeof(uint32_t);
- uint32_t *bind = brw_state_batch(brw, AUB_TRACE_BINDING_TABLE,
- table_size_in_bytes, 32,
- &stage_state->bind_bo_offset);
+ uint32_t *bind = brw_state_batch(brw, AUB_TRACE_BINDING_TABLE,
+ prog_data->binding_table.size_bytes, 32,
+ &stage_state->bind_bo_offset);
- /* BRW_NEW_SURFACES and BRW_NEW_*_CONSTBUF */
- memcpy(bind, stage_state->surf_offset, table_size_in_bytes);
+ /* BRW_NEW_SURFACES and BRW_NEW_*_CONSTBUF */
+ memcpy(bind, stage_state->surf_offset,
+ prog_data->binding_table.size_bytes);
+ }
brw->state.dirty.brw |= brw_new_binding_table;
+
+ if (brw->gen >= 7) {
+ BEGIN_BATCH(2);
+ OUT_BATCH(packet_name << 16 | (2 - 2));
+ OUT_BATCH(stage_state->bind_bo_offset);
+ ADVANCE_BATCH();
+ }
}
/**
static void
brw_vs_upload_binding_table(struct brw_context *brw)
{
- struct brw_stage_state *stage_state = &brw->vs.base;
- /* CACHE_NEW_VS_PROG */
- const struct brw_vec4_prog_data *prog_data = &brw->vs.prog_data->base;
-
- /* BRW_NEW_SURFACES and BRW_NEW_VS_CONSTBUF */
- brw_upload_binding_table(brw, BRW_NEW_VS_BINDING_TABLE, stage_state,
- prog_data->binding_table_size,
- SURF_INDEX_VEC4_SHADER_TIME);
+ brw_upload_binding_table(brw,
+ _3DSTATE_BINDING_TABLE_POINTERS_VS,
+ BRW_NEW_VS_BINDING_TABLE, &brw->vs.base);
}
const struct brw_tracked_state brw_vs_binding_table = {
static void
brw_upload_wm_binding_table(struct brw_context *brw)
{
- struct brw_stage_state *stage_state = &brw->wm.base;
-
- /* BRW_NEW_SURFACES and CACHE_NEW_WM_PROG */
- brw_upload_binding_table(brw, BRW_NEW_PS_BINDING_TABLE, stage_state,
- brw->wm.prog_data->binding_table_size,
- SURF_INDEX_WM_SHADER_TIME);
+ brw_upload_binding_table(brw,
+ _3DSTATE_BINDING_TABLE_POINTERS_PS,
+ BRW_NEW_PS_BINDING_TABLE, &brw->wm.base);
}
const struct brw_tracked_state brw_wm_binding_table = {
static void
brw_gs_upload_binding_table(struct brw_context *brw)
{
- struct brw_stage_state *stage_state = &brw->gs.base;
-
/* If there's no GS, skip changing anything. */
- if (!brw->gs.prog_data)
+ if (brw->geometry_program == NULL)
return;
- /* CACHE_NEW_GS_PROG */
- const struct brw_vec4_prog_data *prog_data = &brw->gs.prog_data->base;
-
- /* BRW_NEW_SURFACES and BRW_NEW_GS_CONSTBUF */
- brw_upload_binding_table(brw, BRW_NEW_GS_BINDING_TABLE, stage_state,
- prog_data->binding_table_size,
- SURF_INDEX_VEC4_SHADER_TIME);
+ brw_upload_binding_table(brw,
+ _3DSTATE_BINDING_TABLE_POINTERS_GS,
+ BRW_NEW_GS_BINDING_TABLE, &brw->gs.base);
}
const struct brw_tracked_state brw_gs_binding_table = {
.emit = gen6_upload_binding_table_pointers,
};
-/* Gen7+ code lives in gen7_{vs,gs,wm}_state.c. */
-
/** @} */