summaryrefslogtreecommitdiffstats
path: root/src/intel/blorp
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2017-03-09 14:22:25 +0100
committerIago Toral Quiroga <[email protected]>2017-03-16 11:40:05 +0100
commitd4bdd871dc295610de776d235e58ce8c5eadfded (patch)
treed0dd31cb74fbe179510278d28722e3a6acabed19 /src/intel/blorp
parent31f5049ff1c851d1b8652c7cb42740a6a7db58de (diff)
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 <[email protected]>
Diffstat (limited to 'src/intel/blorp')
-rw-r--r--src/intel/blorp/blorp_genX_exec.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h
index f0c4f38578f..dc1b7735ab3 100644
--- a/src/intel/blorp/blorp_genX_exec.h
+++ b/src/intel/blorp/blorp_genX_exec.h
@@ -110,14 +110,16 @@ _blorp_combine_address(struct blorp_batch *batch, void *location,
_blorp_cmd_pack(cmd)(batch, (void *)_dst, &name), \
_dst = NULL)
-#define blorp_emitn(batch, cmd, n) ({ \
- uint32_t *_dw = blorp_emit_dwords(batch, n); \
- struct cmd template = { \
- _blorp_cmd_header(cmd), \
- .DWordLength = n - _blorp_cmd_length_bias(cmd), \
- }; \
- _blorp_cmd_pack(cmd)(batch, _dw, &template); \
- _dw + 1; /* Array starts at dw[1] */ \
+#define blorp_emitn(batch, cmd, n) ({ \
+ uint32_t *_dw = blorp_emit_dwords(batch, n); \
+ if (_dw) { \
+ struct cmd template = { \
+ _blorp_cmd_header(cmd), \
+ .DWordLength = n - _blorp_cmd_length_bias(cmd), \
+ }; \
+ _blorp_cmd_pack(cmd)(batch, _dw, &template); \
+ } \
+ _dw ? _dw + 1 : NULL; /* Array starts at dw[1] */ \
})
/* 3DSTATE_URB
@@ -274,6 +276,8 @@ blorp_emit_vertex_buffers(struct blorp_batch *batch,
const unsigned num_dwords = 1 + GENX(VERTEX_BUFFER_STATE_length) * 2;
uint32_t *dw = blorp_emitn(batch, GENX(3DSTATE_VERTEX_BUFFERS), num_dwords);
+ if (!dw)
+ return;
for (unsigned i = 0; i < 2; i++) {
GENX(VERTEX_BUFFER_STATE_pack)(batch, dw, &vb[i]);
@@ -379,6 +383,8 @@ blorp_emit_vertex_elements(struct blorp_batch *batch,
const unsigned num_dwords =
1 + GENX(VERTEX_ELEMENT_STATE_length) * num_elements;
uint32_t *dw = blorp_emitn(batch, GENX(3DSTATE_VERTEX_ELEMENTS), num_dwords);
+ if (!dw)
+ return;
for (unsigned i = 0; i < num_elements; i++) {
GENX(VERTEX_ELEMENT_STATE_pack)(batch, dw, &ve[i]);
@@ -1019,6 +1025,9 @@ blorp_emit_depth_stencil_state(struct blorp_batch *batch,
uint32_t offset = 0;
uint32_t *dw = blorp_emit_dwords(batch,
GENX(3DSTATE_WM_DEPTH_STENCIL_length));
+ if (!dw)
+ return 0;
+
GENX(3DSTATE_WM_DEPTH_STENCIL_pack)(NULL, dw, &ds);
#else
uint32_t offset;