From c3712702977ebeb3fb1de71b1b3770e41be5b7b3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 Jun 2012 09:03:45 -0600 Subject: [PATCH] translate_test: add support for half floats --- src/gallium/tests/unit/translate_test.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/gallium/tests/unit/translate_test.c b/src/gallium/tests/unit/translate_test.c index b9e7e25..60a0501 100644 --- a/src/gallium/tests/unit/translate_test.c +++ b/src/gallium/tests/unit/translate_test.c @@ -27,6 +27,7 @@ #include "translate/translate.h" #include "util/u_memory.h" #include "util/u_format.h" +#include "util/u_half.h" #include "util/u_cpu_detect.h" #include "rtasm/rtasm_cpu.h" @@ -57,6 +58,7 @@ int main(int argc, char** argv) unsigned char* byte_buffer; float* float_buffer; double* double_buffer; + uint16_t *half_buffer; unsigned * elts; unsigned count = 4; unsigned i, j, k; @@ -137,6 +139,7 @@ int main(int argc, char** argv) byte_buffer = align_malloc(buffer_size, 4096); float_buffer = align_malloc(buffer_size, 4096); double_buffer = align_malloc(buffer_size, 4096); + half_buffer = align_malloc(buffer_size, 4096); elts = align_malloc(count * sizeof *elts, 4096); @@ -159,6 +162,9 @@ int main(int argc, char** argv) for (i = 0; i < buffer_size / sizeof(double); ++i) double_buffer[i] = rand_double(); + for (i = 0; i < buffer_size / sizeof(double); ++i) + half_buffer[i] = util_float_to_half((float) rand_double()); + for (i = 0; i < count; ++i) elts[i] = i; @@ -246,6 +252,8 @@ int main(int argc, char** argv) buffer[0] = (unsigned char*)float_buffer; else if(input_is_float && input_format_desc->channel[0].size == 64) buffer[0] = (unsigned char*)double_buffer; + else if(input_is_float && input_format_desc->channel[0].size == 16) + buffer[0] = (unsigned char*)half_buffer; else if(input_is_float) abort(); else -- 1.7.3.4