anv: avoid crashes when failing to allocate batches
Most of the time we use macros that handle this situation transparently, but there are some cases were we need to handle this explicitly. This patch makes sure we don't crash, notice that error handling takes place in the function that actually failed the allocation, anv_batch_emit_dwords(), which will set the status field of the batch so it can be used at a later moment to report the error to the user. v2: - Not crashing is not good enough, we need to keep track of the error (Topi, Jason). Iago: now that we track errors in the batch, this is being handled. - Added guards in a few more places that needed it (Iago) v3: - Check result of anv_batch_emitn() for NULL before calling memset() in emit_vertex_input() (Topi) Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
This commit is contained in:
@@ -112,6 +112,8 @@ emit_vertex_input(struct anv_pipeline *pipeline,
|
||||
const uint32_t num_dwords = 1 + total_elems * 2;
|
||||
p = anv_batch_emitn(&pipeline->batch, num_dwords,
|
||||
GENX(3DSTATE_VERTEX_ELEMENTS));
|
||||
if (!p)
|
||||
return;
|
||||
memset(p + 1, 0, (num_dwords - 1) * 4);
|
||||
|
||||
for (uint32_t i = 0; i < info->vertexAttributeDescriptionCount; i++) {
|
||||
@@ -389,10 +391,14 @@ emit_3dstate_sbe(struct anv_pipeline *pipeline)
|
||||
|
||||
uint32_t *dw = anv_batch_emit_dwords(&pipeline->batch,
|
||||
GENX(3DSTATE_SBE_length));
|
||||
if (!dw)
|
||||
return;
|
||||
GENX(3DSTATE_SBE_pack)(&pipeline->batch, dw, &sbe);
|
||||
|
||||
#if GEN_GEN >= 8
|
||||
dw = anv_batch_emit_dwords(&pipeline->batch, GENX(3DSTATE_SBE_SWIZ_length));
|
||||
if (!dw)
|
||||
return;
|
||||
GENX(3DSTATE_SBE_SWIZ_pack)(&pipeline->batch, dw, &swiz);
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user