summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2015-01-30 14:14:43 -0800
committerMatt Turner <[email protected]>2015-02-03 12:25:14 -0800
commitdbd4c22a37b3605dd51833f3ecf69679b52b7bde (patch)
tree317323a26415485a15697dfb664929df83a894da
parent638beee24ae097633c34261943aeb8b86fd2a5ee (diff)
i965: Add function to take the abs of immediates.
Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_shader.cpp39
-rw-r--r--src/mesa/drivers/dri/i965/brw_shader.h1
2 files changed, 40 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index c5a666cf2cc..807b81ddd1d 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -659,6 +659,45 @@ brw_negate_immediate(enum brw_reg_type type, struct brw_reg *reg)
return false;
}
+bool
+brw_abs_immediate(enum brw_reg_type type, struct brw_reg *reg)
+{
+ switch (type) {
+ case BRW_REGISTER_TYPE_D:
+ reg->dw1.d = abs(reg->dw1.d);
+ return true;
+ case BRW_REGISTER_TYPE_W:
+ reg->dw1.d = abs((int16_t)reg->dw1.ud);
+ return true;
+ case BRW_REGISTER_TYPE_F:
+ reg->dw1.f = fabsf(reg->dw1.f);
+ return true;
+ case BRW_REGISTER_TYPE_VF:
+ reg->dw1.ud &= ~0x80808080;
+ return true;
+ case BRW_REGISTER_TYPE_UB:
+ case BRW_REGISTER_TYPE_B:
+ unreachable("no UB/B immediates");
+ case BRW_REGISTER_TYPE_UQ:
+ case BRW_REGISTER_TYPE_UD:
+ case BRW_REGISTER_TYPE_UW:
+ case BRW_REGISTER_TYPE_UV:
+ /* Presumably the absolute value modifier on an unsigned source is a
+ * nop, but it would be nice to confirm.
+ */
+ assert(!"unimplemented: abs unsigned immediate");
+ case BRW_REGISTER_TYPE_V:
+ assert(!"unimplemented: abs V immediate");
+ case BRW_REGISTER_TYPE_Q:
+ assert(!"unimplemented: abs Q immediate");
+ case BRW_REGISTER_TYPE_DF:
+ case BRW_REGISTER_TYPE_HF:
+ assert(!"unimplemented: abs DF/HF immediate");
+ }
+
+ return false;
+}
+
backend_visitor::backend_visitor(struct brw_context *brw,
struct gl_shader_program *shader_prog,
struct gl_program *prog,
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 2b9b72e3ece..5ad87d6278b 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -196,6 +196,7 @@ uint32_t brw_math_function(enum opcode op);
const char *brw_instruction_name(enum opcode op);
bool brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg);
bool brw_negate_immediate(enum brw_reg_type type, struct brw_reg *reg);
+bool brw_abs_immediate(enum brw_reg_type type, struct brw_reg *reg);
#ifdef __cplusplus
extern "C" {