The MASM Forum

General => The Laboratory => Topic started by: aw27 on September 13, 2018, 01:01:37 AM

Title: Convert REAL4 to HALF
Post by: aw27 on September 13, 2018, 01:01:37 AM
As a follow up of this (http://masm32.com/board/index.php?topic=7394.msg81032#msg81032), I present here 2 methods of converting 1 REAL4 to 1 HALF, the VCVTPS2PH method and the no-VCVTPS2PH method.
The first one is the best but may not work on all computers.
I compare if the result obtained from both methods yields the same result. It does  :biggrin: (in this case)


HALF values are equal


BTW, I have not figured out yet know how to print a HALF (without converting it back of course). Anyone?
Title: Re: Convert REAL4 to HALF
Post by: Siekmanski on September 13, 2018, 01:44:54 AM
HALF values are equal  :t
Title: Re: Convert REAL4 to HALF
Post by: jj2007 on September 13, 2018, 01:55:37 AM
On my Core i5-2450M, vcvtps2ph xmm1, xmm0 is an illegal instruction.
Title: Re: Convert REAL4 to HALF
Post by: aw27 on September 13, 2018, 02:48:16 AM
Quote from: jj2007 on September 13, 2018, 01:55:37 AM
On my Core i5-2450M, vcvtps2ph xmm1, xmm0 is an illegal instruction.

You need an Ivy Bridge or later (https://en.wikipedia.org/wiki/F16C).
Title: Re: Convert REAL4 to HALF
Post by: FORTRANS on September 13, 2018, 03:47:31 AM
Hi,

   Intel Core i3 4005U.

HALF values are equal

Steve N.
Title: Re: Convert REAL4 to HALF
Post by: hutch-- on September 13, 2018, 04:29:38 PM
Haswell E/EP

HALF values are equal
Title: Re: Convert REAL4 to HALF
Post by: daydreamer on September 15, 2018, 12:15:07 AM
Quote from: AW on September 13, 2018, 01:01:37 AM
As a follow up of this (http://masm32.com/board/index.php?topic=7394.msg81032#msg81032), I present here 2 methods of converting 1 REAL4 to 1 HALF, the VCVTPS2PH method and the no-VCVTPS2PH method.
The first one is the best but may not work on all computers.
I compare if the result obtained from both methods yields the same result. It does  :biggrin: (in this case)

BTW, I have not figured out yet know how to print a HALF (without converting it back of course). Anyone?
doesnt work
I Think its more interesting to be able to store twice the amount meshes in a demo
isnt it actually what you get from importing 3d files,double values in ascii->half's much smaller?

Title: Re: Convert REAL4 to HALF
Post by: aw27 on September 15, 2018, 12:37:49 AM
Now, I will not use the modern instructions, some people still has pre- Ivy Bridge computers, and will print the HALF by converting it back and consider 4 significant digits (it has 3/4 significant digits), by luck in this case the 4th digit is still valid.


REAL4 Value=1.234567
HALF Value=1.234


@daydream
All depends on what you have in mind
Title: Re: Convert REAL4 to HALF
Post by: Siekmanski on September 15, 2018, 01:05:05 AM
Nice  :biggrin:

Daydreamer, to compress vertex data, use "vertex subdivision" and convert the data to half floats  ( the files will be incredible small ).
Title: Re: Convert REAL4 to HALF
Post by: daydreamer on September 15, 2018, 04:10:08 AM
Quote from: AW on September 15, 2018, 12:37:49 AM
Now, I will not use the modern instructions, some people still has pre- Ivy Bridge computers, and will print the HALF by converting it back and consider 4 significant digits (it has 3/4 significant digits), by luck in this case the 4th digit is still valid.


REAL4 Value=1.234567
HALF Value=1.234


@daydream
All depends on what you have in mind
Would be nice to add aircraft meshes and other meshes as small  together in my project with procedural terrain making