radv/xfb: fix counter buffer bounds checks.
authorDave Airlie <airlied@redhat.com>
Thu, 13 Dec 2018 03:29:04 +0000 (03:29 +0000)
committerDave Airlie <airlied@redhat.com>
Thu, 13 Dec 2018 19:27:05 +0000 (19:27 +0000)
If we gave this function 0 counter buffers, we'd still try and
access pCounterBuffers[0] as this check was incorrect.

Fixes crash with ext_transform_feedback-pipeline-basic-primgen
on zink on radv.

Fixes: 677b496b6 (radv: fix begin/end transform feedback with 0 counter buffers.)
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_cmd_buffer.c

index 982107138d30c64075676b8a04ae88ff2b59188b..aebf93b447f2768dc4d59cd8249aab27b87a2301 100644 (file)
@@ -4853,7 +4853,7 @@ void radv_CmdBeginTransformFeedbackEXT(
        assert(firstCounterBuffer + counterBufferCount <= MAX_SO_BUFFERS);
        for_each_bit(i, so->enabled_mask) {
                int32_t counter_buffer_idx = i - firstCounterBuffer;
-               if (counter_buffer_idx >= 0 && counter_buffer_idx > counterBufferCount)
+               if (counter_buffer_idx >= 0 && counter_buffer_idx >= counterBufferCount)
                        counter_buffer_idx = -1;
 
                /* SI binds streamout buffers as shader resources.
@@ -4915,7 +4915,7 @@ void radv_CmdEndTransformFeedbackEXT(
        assert(firstCounterBuffer + counterBufferCount <= MAX_SO_BUFFERS);
        for_each_bit(i, so->enabled_mask) {
                int32_t counter_buffer_idx = i - firstCounterBuffer;
-               if (counter_buffer_idx >= 0 && counter_buffer_idx > counterBufferCount)
+               if (counter_buffer_idx >= 0 && counter_buffer_idx >= counterBufferCount)
                        counter_buffer_idx = -1;
 
                if (counter_buffer_idx >= 0 && pCounterBuffers && pCounterBuffers[counter_buffer_idx]) {