summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_reg.h
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2015-11-02 10:29:45 -0800
committerMatt Turner <mattst88@gmail.com>2015-11-19 11:12:24 -0800
commitc15a407eb49d3b26bdbf039816636adb184c276a (patch)
treeb6a2593c167e1f2c68993426b359936286f05001 /src/mesa/drivers/dri/i965/brw_reg.h
parente8c5ef3ecaafae0ad6c300019c489401a9af714c (diff)
downloadexternal_mesa3d-c15a407eb49d3b26bdbf039816636adb184c276a.zip
external_mesa3d-c15a407eb49d3b26bdbf039816636adb184c276a.tar.gz
external_mesa3d-c15a407eb49d3b26bdbf039816636adb184c276a.tar.bz2
i965: Make brw_imm_vf4() take 8-bit restricted floats.
This partially reverts commit bbf8239f92ecd79431dfa41402e1c85318e7267f. I didn't like that commit to begin with -- computing things at compile time is fine -- but for purposes of verifying that the resulting values are correct, looking up 0x00 and 0x30 in a table is a lot better than evaluating a recursive function. Anyway, by making brw_imm_vf4() take the actual 8-bit restricted floats directly (instead of only integral values that would be converted to restricted float), we can use this function as a replacement for the vector float src_reg/fs_reg constructors. brw_float_to_vf() is not currently an inline function, so it will not be evaluated at compile time. I'll address that in a follow-up patch. Reviewed-by: Emil Velikov <emil.velikov@collabora.co.uk> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_reg.h')
-rw-r--r--src/mesa/drivers/dri/i965/brw_reg.h38
1 files changed, 7 insertions, 31 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_reg.h b/src/mesa/drivers/dri/i965/brw_reg.h
index 3da83b4..e34e7ea 100644
--- a/src/mesa/drivers/dri/i965/brw_reg.h
+++ b/src/mesa/drivers/dri/i965/brw_reg.h
@@ -43,7 +43,6 @@
#define BRW_REG_H
#include <stdbool.h>
-#include "main/imports.h"
#include "main/compiler.h"
#include "main/macros.h"
#include "program/prog_instruction.h"
@@ -638,38 +637,15 @@ brw_imm_vf(unsigned v)
return imm;
}
-/**
- * Convert an integer into a "restricted" 8-bit float, used in vector
- * immediates. The 8-bit floating point format has a sign bit, an
- * excess-3 3-bit exponent, and a 4-bit mantissa. All integer values
- * from -31 to 31 can be represented exactly.
- */
-static inline uint8_t
-int_to_float8(int x)
-{
- if (x == 0) {
- return 0;
- } else if (x < 0) {
- return 1 << 7 | int_to_float8(-x);
- } else {
- const unsigned exponent = _mesa_logbase2(x);
- const unsigned mantissa = (x - (1 << exponent)) << (4 - exponent);
- assert(exponent <= 4);
- return (exponent + 3) << 4 | mantissa;
- }
-}
-
-/**
- * Construct a floating-point packed vector immediate from its integer
- * values. \sa int_to_float8()
- */
static inline struct brw_reg
-brw_imm_vf4(int v0, int v1, int v2, int v3)
+brw_imm_vf4(unsigned v0, unsigned v1, unsigned v2, unsigned v3)
{
- return brw_imm_vf((int_to_float8(v0) << 0) |
- (int_to_float8(v1) << 8) |
- (int_to_float8(v2) << 16) |
- (int_to_float8(v3) << 24));
+ struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF);
+ imm.vstride = BRW_VERTICAL_STRIDE_0;
+ imm.width = BRW_WIDTH_4;
+ imm.hstride = BRW_HORIZONTAL_STRIDE_1;
+ imm.ud = ((v0 << 0) | (v1 << 8) | (v2 << 16) | (v3 << 24));
+ return imm;
}