diff options
author | Ian Romanick <[email protected]> | 2016-10-14 18:11:51 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2017-01-20 15:41:23 -0800 |
commit | 330fc2413c61f0bd9c7bb9f3a0ecd91b09de267a (patch) | |
tree | 9f6fa4014c98f04b40539b268a7be7a34c1b56a1 /src/compiler/glsl/builtin_int64.h | |
parent | aa38bf1e593eba3e65c4e10154410158d6d263c5 (diff) |
glsl: Add "built-in" functions to do 64x64 => 64 multiplication
These functions are directly available in shaders. A #define is added
to detect the presence. This allows these functions to be tested using
piglit regardless of whether the driver uses them for lowering. The
GLSL spec says that functions and macros beginning with __ are reserved
for use by the implementation... hey, that's us!
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/compiler/glsl/builtin_int64.h')
-rw-r--r-- | src/compiler/glsl/builtin_int64.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/compiler/glsl/builtin_int64.h b/src/compiler/glsl/builtin_int64.h new file mode 100644 index 00000000000..108da08ee48 --- /dev/null +++ b/src/compiler/glsl/builtin_int64.h @@ -0,0 +1,30 @@ +ir_function_signature * +umul64(void *mem_ctx, builtin_available_predicate avail) +{ + ir_function_signature *const sig = + new(mem_ctx) ir_function_signature(glsl_type::uvec2_type, avail); + ir_factory body(&sig->body, mem_ctx); + sig->is_defined = true; + + exec_list sig_parameters; + + ir_variable *const r0001 = new(mem_ctx) ir_variable(glsl_type::uvec2_type, "a", ir_var_function_in); + sig_parameters.push_tail(r0001); + ir_variable *const r0002 = new(mem_ctx) ir_variable(glsl_type::uvec2_type, "b", ir_var_function_in); + sig_parameters.push_tail(r0002); + ir_variable *const r0003 = new(mem_ctx) ir_variable(glsl_type::uvec2_type, "result", ir_var_auto); + body.emit(r0003); + body.emit(assign(r0003, imul_high(swizzle_x(r0001), swizzle_x(r0002)), 0x02)); + + body.emit(assign(r0003, mul(swizzle_x(r0001), swizzle_x(r0002)), 0x01)); + + ir_expression *const r0004 = mul(swizzle_x(r0001), swizzle_y(r0002)); + ir_expression *const r0005 = mul(swizzle_y(r0001), swizzle_x(r0002)); + ir_expression *const r0006 = add(r0004, r0005); + body.emit(assign(r0003, add(swizzle_y(r0003), r0006), 0x02)); + + body.emit(ret(r0003)); + + sig->replace_parameters(&sig_parameters); + return sig; +} |