mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 19:40:10 +01:00
svga: handle null target pointers in svga_set_stream_output_targets()
Fixes crash in Piglit arb_separate_shader_object-xfb-explicit-location-array test. Signed-off-by: Brian Paul <brian.paul@broadcom.com> Reviewed-by: Roland Scheidegger <roland.scheidegger@broadcom.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34635>
This commit is contained in:
parent
65411350ac
commit
6325868bbe
1 changed files with 34 additions and 26 deletions
|
|
@ -416,8 +416,10 @@ svga_set_stream_output_targets(struct pipe_context *pipe,
|
|||
* before mapping.
|
||||
*/
|
||||
for (i = 0; i < svga->num_so_targets; i++) {
|
||||
struct svga_buffer *sbuf = svga_buffer(svga->so_targets[i]->buffer);
|
||||
sbuf->dirty = true;
|
||||
if (svga->so_targets[i]) {
|
||||
struct svga_buffer *sbuf = svga_buffer(svga->so_targets[i]->buffer);
|
||||
sbuf->dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Before the currently bound streamout targets are unbound,
|
||||
|
|
@ -433,36 +435,42 @@ svga_set_stream_output_targets(struct pipe_context *pipe,
|
|||
for (i = 0; i < num_targets; i++) {
|
||||
struct svga_stream_output_target *sot
|
||||
= svga_stream_output_target(targets[i]);
|
||||
struct svga_buffer *sbuf = svga_buffer(sot->base.buffer);
|
||||
unsigned size;
|
||||
if (sot) {
|
||||
struct svga_buffer *sbuf = svga_buffer(sot->base.buffer);
|
||||
|
||||
svga->so_surfaces[i] = svga_buffer_handle(svga, sot->base.buffer,
|
||||
PIPE_BIND_STREAM_OUTPUT);
|
||||
svga->so_surfaces[i] = svga_buffer_handle(svga, sot->base.buffer,
|
||||
PIPE_BIND_STREAM_OUTPUT);
|
||||
|
||||
assert(svga_buffer(sot->base.buffer)->key.flags
|
||||
& SVGA3D_SURFACE_BIND_STREAM_OUTPUT);
|
||||
assert(svga_buffer(sot->base.buffer)->key.flags
|
||||
& SVGA3D_SURFACE_BIND_STREAM_OUTPUT);
|
||||
|
||||
/* Mark the buffer surface as RENDERED */
|
||||
assert(sbuf->bufsurf);
|
||||
sbuf->bufsurf->surface_state = SVGA_SURFACE_STATE_RENDERED;
|
||||
/* Mark the buffer surface as RENDERED */
|
||||
assert(sbuf->bufsurf);
|
||||
sbuf->bufsurf->surface_state = SVGA_SURFACE_STATE_RENDERED;
|
||||
|
||||
svga->so_targets[i] = &sot->base;
|
||||
if (offsets[i] == -1) {
|
||||
soBindings[i].offset = -1;
|
||||
svga->so_targets[i] = &sot->base;
|
||||
if (offsets[i] == -1) {
|
||||
soBindings[i].offset = -1;
|
||||
|
||||
/* The streamout is being resumed. There is no need to restart streamout statistics
|
||||
* queries for the draw-auto fallback since those queries are still active.
|
||||
*/
|
||||
begin_so_queries = false;
|
||||
/* The streamout is being resumed. There is no need to restart
|
||||
* streamout statistics queries for the draw-auto fallback since
|
||||
* those queries are still active.
|
||||
*/
|
||||
begin_so_queries = false;
|
||||
} else {
|
||||
soBindings[i].offset = sot->base.buffer_offset + offsets[i];
|
||||
}
|
||||
|
||||
/* The size cannot extend beyond the end of the buffer. Clamp it. */
|
||||
soBindings[i].sizeInBytes =
|
||||
MIN2(sot->base.buffer_size,
|
||||
sot->base.buffer->width0 - sot->base.buffer_offset);
|
||||
} else {
|
||||
svga->so_surfaces[i] = NULL;
|
||||
svga->so_targets[i] = NULL;
|
||||
soBindings[i].offset = 0;
|
||||
soBindings[i].sizeInBytes = 0;
|
||||
}
|
||||
else
|
||||
soBindings[i].offset = sot->base.buffer_offset + offsets[i];
|
||||
|
||||
/* The size cannot extend beyond the end of the buffer. Clamp it. */
|
||||
size = MIN2(sot->base.buffer_size,
|
||||
sot->base.buffer->width0 - sot->base.buffer_offset);
|
||||
|
||||
soBindings[i].sizeInBytes = size;
|
||||
}
|
||||
|
||||
/* unbind any previously bound stream output buffers */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue