On Tue, Dec 4, 2018 at 3:46 PM Lionel Landwerlin
<lionel.g.landwer...@intel.com> wrote:
>
> Signed-off-by: Lionel Landwerlin <lionel.g.landwer...@intel.com>
> ---
>  Makefile.am            |   1 +
>  src/tests/bug/108909.c | 106 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 107 insertions(+)
>  create mode 100644 src/tests/bug/108909.c
>
> diff --git a/Makefile.am b/Makefile.am
> index b35e329..528650a 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -74,6 +74,7 @@ bin_crucible_SOURCES = \
>         src/qonos/qonos.c \
>         src/qonos/qonos_pipeline.c \
>         src/tests/bug/104809.c \
> +       src/tests/bug/108909.c \
>         src/tests/bench/copy-buffer.c \
>         src/tests/example/basic.c \
>         src/tests/example/images.c \
> diff --git a/src/tests/bug/108909.c b/src/tests/bug/108909.c
> new file mode 100644
> index 0000000..1faadbf
> --- /dev/null
> +++ b/src/tests/bug/108909.c
> @@ -0,0 +1,106 @@
> +// Copyright 2018 Intel Corporation
> +//
> +// Permission is hereby granted, free of charge, to any person obtaining a
> +// copy of this software and associated documentation files (the "Software"),
> +// to deal in the Software without restriction, including without limitation
> +// the rights to use, copy, modify, merge, publish, distribute, sublicense,
> +// and/or sell copies of the Software, and to permit persons to whom the
> +// Software is furnished to do so, subject to the following conditions:
> +//
> +// The above copyright notice and this permission notice (including the next
> +// paragraph) shall be included in all copies or substantial portions of the
> +// Software.
> +//
> +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> +// IN THE SOFTWARE.
> +
> +#include <inttypes.h>
> +#include <stdio.h>
> +#include "tapi/t.h"
> +#include "util/misc.h"
> +
> +/* This is a test for https://bugs.freedesktop.org/show_bug.cgi?id=108909
> + *
> + * Ensure ordering of operations for between 3d pipeline and command
> + * streamer on Intel HW.
> + */
> +
> +static void
> +test(void)
> +{
> +    const uint64_t initialData[] = {
> +        0xdeaddeadbeef,
> +        0xdeaddeadbeef,
> +        0xdeaddeadbeef,
> +        0xdeaddeadbeef,
> +    };
> +    VkBuffer dataBuffer = qoCreateBuffer(t_device,
> +                                          .size = sizeof(initialData),
> +                                          .usage = 
> VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
> +    VkDeviceMemory dataMem = qoAllocBufferMemory(t_device, dataBuffer,
> +                                                  .properties = 
> VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
> +                                                  
> VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
> +    memcpy(qoMapMemory(t_device, dataMem, /*offset*/ 0,
> +                       sizeof(initialData), /*flags*/ 0),
> +           initialData,
> +           sizeof(initialData));
> +    qoBindBufferMemory(t_device, dataBuffer, dataMem, /*offset*/ 0);
> +
> +    VkBuffer resultBuffer = qoCreateBuffer(t_device,
> +                                            .size = sizeof(initialData),
> +                                            .usage = 
> VK_BUFFER_USAGE_TRANSFER_DST_BIT);
> +    VkDeviceMemory resultMem = qoAllocBufferMemory(t_device, resultBuffer,
> +                                                   .properties = 
> VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
> +                                                   
> VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
> +    qoBindBufferMemory(t_device, resultBuffer, resultMem, /*offset*/ 0);
> +
> +    VkQueryPool pool = qoCreateQueryPool(t_device,
> +                                               .queryType = 
> VK_QUERY_TYPE_TIMESTAMP,
> +                                               .queryCount = 
> ARRAY_LENGTH(initialData));
> +
> +
> +    /* vkCmdCopyQueryPoolResults should be ordered with regard to 
> vkCmdCopyBuffer. */
> +    VkCommandBuffer cmdBuffer = qoAllocateCommandBuffer(t_device, 
> t_cmd_pool);
> +    qoBeginCommandBuffer(cmdBuffer);
> +    vkCmdWriteTimestamp(cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, pool, 
> 0);
> +    vkCmdWriteTimestamp(cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, pool, 
> 1);
> +    vkCmdCopyBuffer(cmdBuffer, dataBuffer, resultBuffer,
> +                    1, &(VkBufferCopy){ .srcOffset = 0, .dstOffset = 0, 
> .size = sizeof(initialData) });
> +    vkCmdWriteTimestamp(cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, pool, 
> 2);
> +    vkCmdWriteTimestamp(cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, pool, 
> 3);
> +    vkCmdCopyQueryPoolResults(cmdBuffer, pool, /*firstQuery*/ 0, 
> /*queryCount*/ 4,
> +                              resultBuffer, /*dstBufferOffset*/ 0, 
> sizeof(uint64_t),
> +                              VK_QUERY_RESULT_WAIT_BIT);

A pipeline barrier between vkCmdCopyBuffer() and
vkCmdCopyQueryPoolResults() might be required.

> +    qoEndCommandBuffer(cmdBuffer);
> +
> +    qoQueueSubmit(t_queue, 1, &cmdBuffer, VK_NULL_HANDLE);
> +    qoQueueWaitIdle(t_queue);
> +
> +    uint64_t *copiedResults = qoMapMemory(t_device, resultMem, /*offset*/ 0,
> +                                          sizeof(initialData), /*flags*/ 0);
> +
> +    for (unsigned i = 0; i < ARRAY_LENGTH(initialData); i++) {
> +        printf("timestamp%i = 0x%016" PRIx64 "\n",
> +               i, copiedResults[i]);
> +        if (copiedResults[i] == initialData[i]) {
> +            printf("Got unexpected timestamp (index=%i) 0x%016" PRIx64 "\n",
> +                   i, copiedResults[i]);
> +
> +            t_fail();
> +            return;
> +        }
> +    }
> +
> +    t_pass();
> +}
> +
> +test_define {
> +    .name = "bug.108909",
> +    .start = test,
> +    .no_image = true,
> +};
> --
> 2.20.0.rc1
>
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to