Skip to content

r300: fix r300_draw_elements() behavior

What does this MR do and why?

r300: fix r300_draw_elements() behavior

Indeed, the pointer processed by r300_upload_index_buffer() was not the right one.
This is the reason why "deqp-gles2 --deqp-case=dEQP-GLES2.functional.draw.draw_elements.indices.user_ptr.index_byte"
was failing (the logs are below). This change corrects this issue and makes the related deqp tests work properly.

This change considers that r300_upload_index_buffer() sets indexBuffer to NULL. The indexBuffer resource
should be properly freed once the buffer is processed. This is required to avoid another refcnt imbalance
(another kind of memory leak).

==9962==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000721f at pc 0x7fd57b54a9a0 bp 0x7fffd2c39290 sp 0x7fffd2c38a40
READ of size 30 at 0x60200000721f thread T0
    #0 0x7fd57b54a99f in __interceptor_memcpy (/usr/lib64/libasan.so.6.0.0+0x3c99f)
    #1 0x7fd570d10528 in u_upload_data ../src/gallium/auxiliary/util/u_upload_mgr.c:333
    #2 0x7fd57114142b in r300_upload_index_buffer ../src/gallium/drivers/r300/r300_screen_buffer.c:44
    #3 0x7fd57113943c in r300_draw_elements ../src/gallium/drivers/r300/r300_render.c:632
    #4 0x7fd57113bbc4 in r300_draw_vbo ../src/gallium/drivers/r300/r300_render.c:840
    #5 0x7fd570d212e2 in u_vbuf_draw_vbo ../src/gallium/auxiliary/util/u_vbuf.c:1487
    #6 0x7fd56fceb873 in _mesa_validated_drawrangeelements ../src/mesa/main/draw.c:1709
    #7 0x7fd56fcf28c5 in _mesa_DrawElementsBaseVertex ../src/mesa/main/draw.c:1852

Fixes: 330d0607ed6 ("gallium: remove pipe_index_buffer and set_index_buffer")
Signed-off-by: Patrick Lerda <patrick9876@free.fr>

Here are the deqp2 tests fixed in a gcc sanitizer environment by this change:

deqp-gles2/functional/draw/draw_elements/indices/user_ptr/index_byte: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/1_attribute/1_dynamic_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/1_attribute/1_dynamic_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/1_attribute/1_dynamic_buffer_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/1_attribute/1_dynamic_buffer_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/1_attribute/1_static_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/1_attribute/1_static_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/1_attribute/1_static_buffer_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/1_attribute/1_static_buffer_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/4_static_4_dynamic_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/4_static_4_dynamic_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/4_static_4_dynamic_buffers_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/4_static_4_dynamic_buffers_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/4_static_buffers_4_dynamic_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/4_static_buffers_4_dynamic_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/4_static_buffers_4_dynamic_buffers_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/4_static_buffers_4_dynamic_buffers_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/8_dynamic_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/8_dynamic_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/8_dynamic_buffers_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/8_dynamic_buffers_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/8_static_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/8_static_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/8_static_buffers_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/100_draws/8_attributes/8_static_buffers_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/1_attribute/1_dynamic_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/1_attribute/1_dynamic_buffer_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/1_attribute/1_static_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/1_attribute/1_static_buffer_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/4_static_4_dynamic_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/4_static_4_dynamic_buffers_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/4_static_buffers_4_dynamic_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/4_static_buffers_4_dynamic_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/4_static_buffers_4_dynamic_buffers_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/4_static_buffers_4_dynamic_buffers_2_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/8_dynamic_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/8_dynamic_buffers_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/8_static_10_triangles: fail pass
deqp-gles2/performance/api/draw_call_batching/draw_elements/10_draws/8_attributes/8_static_buffers_10_triangles: fail pass

Merge request reports

Loading