[Piglit] [PATCH] amd_pinned_memory: Port to Windows.
Marek Olšák
maraeo at gmail.com
Fri Feb 20 14:45:08 PST 2015
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Fri, Feb 20, 2015 at 11:01 PM, Jose Fonseca <jfonseca at vmware.com> wrote:
> We might want to have some OS abstractions for aligned memory if more
> tests need it, but go for a simple solution for now, as it seems a
> special case.
> ---
> tests/spec/amd_pinned_memory/test.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/tests/spec/amd_pinned_memory/test.c b/tests/spec/amd_pinned_memory/test.c
> index 239e620..a2d8b7e 100644
> --- a/tests/spec/amd_pinned_memory/test.c
> +++ b/tests/spec/amd_pinned_memory/test.c
> @@ -136,13 +136,24 @@ enum piglit_result piglit_display(void)
> {
> GLboolean pass = GL_TRUE;
> float white[] = {1, 1, 1, 1};
> - unsigned i, vbo, size, page_size;
> + unsigned i, vbo, size;
> + size_t page_size;
> GLsync fence = 0;
> float x, y, *mem;
>
> +#ifdef _WIN32
> + SYSTEM_INFO system_info;
> + GetSystemInfo(&system_info);
> + page_size = system_info.dwPageSize;
> +#else
> page_size = sysconf(_SC_PAGESIZE);
> +#endif
> size = ALIGN(NUM_PRIMS * TRI_SIZE, page_size);
> +#ifdef _WIN32
> + mem = _aligned_malloc(size, page_size);
> +#else
> mem = aligned_alloc(page_size, size);
> +#endif
>
> glClear(GL_COLOR_BUFFER_BIT);
> glEnableClientState(GL_VERTEX_ARRAY);
> @@ -211,6 +222,13 @@ enum piglit_result piglit_display(void)
> glDeleteBuffers(1, &vbo);
> if (!piglit_check_gl_error(GL_NO_ERROR))
> piglit_report_result(PIGLIT_FAIL);
> +
> +#ifdef _WIN32
> + _aligned_free(mem);
> +#else
> + free(mem);
> +#endif
> +
> piglit_present_results();
>
> return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> --
> 2.1.0
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list