From: Brian Paul Date: Tue, 5 Jun 2012 15:03:45 +0000 (-0600) Subject: translate_test: add support for half floats X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a62e8bcac75ca296619adb7fe4ea806a98beef9;p=mesa.git translate_test: add support for half floats Fixes assertion reported in https://bugs.freedesktop.org/show_bug.cgi?id=44519 but there's still failing cases. --- diff --git a/src/gallium/tests/unit/translate_test.c b/src/gallium/tests/unit/translate_test.c index b9e7e25b29a..60a0501559b 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