glsl/blob.h \
glsl/builtin_functions.cpp \
glsl/builtin_functions.h \
+ glsl/builtin_int64.h \
glsl/builtin_types.cpp \
glsl/builtin_variables.cpp \
+ glsl/generate_ir.cpp \
glsl/glsl_parser_extras.cpp \
glsl/glsl_parser_extras.h \
glsl/glsl_symbol_table.cpp \
return state->ARB_shader_group_vote_enable;
}
+static bool
+integer_functions_supported(const _mesa_glsl_parse_state *state)
+{
+ return state->extensions->MESA_shader_integer_functions;
+}
/** @} */
/******************************************************************************/
add_function("allInvocationsARB", _vote(ir_unop_vote_all), NULL);
add_function("allInvocationsEqualARB", _vote(ir_unop_vote_eq), NULL);
+ add_function("__builtin_umul64",
+ generate_ir::umul64(mem_ctx, integer_functions_supported),
+ NULL);
+
#undef F
#undef FI
#undef FIUD_VEC
extern void
_mesa_glsl_release_builtin_functions(void);
+namespace generate_ir {
+
+ir_function_signature *
+umul64(void *mem_ctx, builtin_available_predicate avail);
+
+}
+
#endif /* BULITIN_FUNCTIONS_H */
--- /dev/null
+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;
+}
--- /dev/null
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include "ir_builder.h"
+#include "builtin_functions.h"
+#include "program/prog_instruction.h" /* for SWIZZLE_X, &c. */
+
+using namespace ir_builder;
+
+namespace generate_ir {
+
+#include "builtin_int64.h"
+
+}
}
glcpp_parser_t *
-glcpp_parser_create(glcpp_extension_iterator extensions, void *state, gl_api api)
+glcpp_parser_create(const struct gl_extensions *extension_list,
+ glcpp_extension_iterator extensions, void *state, gl_api api)
{
glcpp_parser_t *parser;
parser->error = 0;
parser->extensions = extensions;
+ parser->extension_list = extension_list;
parser->state = state;
parser->api = api;
parser->version = 0;
parser->extensions(parser->state, add_builtin_define, parser,
version, parser->is_gles);
+ if (parser->extension_list) {
+ /* If MESA_shader_integer_functions is supported, then the building
+ * blocks required for the 64x64 => 64 multiply exist. Add defines for
+ * those functions so that they can be tested.
+ */
+ if (parser->extension_list->MESA_shader_integer_functions) {
+ add_builtin_define(parser, "__have_builtin_builtin_umul64", 1);
+ }
+ }
+
if (explicitly_set) {
ralloc_asprintf_rewrite_tail(&parser->output, &parser->output_length,
"#version %" PRIiMAX "%s%s", version,
size_t info_log_length;
int error;
glcpp_extension_iterator extensions;
+ const struct gl_extensions *extension_list;
void *state;
gl_api api;
unsigned version;
};
glcpp_parser_t *
-glcpp_parser_create (glcpp_extension_iterator extensions, void *state, gl_api api);
+glcpp_parser_create(const struct gl_extensions *extension_list,
+ glcpp_extension_iterator extensions, void *state, gl_api api);
int
glcpp_parser_parse (glcpp_parser_t *parser);
{
int errors;
glcpp_parser_t *parser =
- glcpp_parser_create(extensions, state, gl_ctx->API);
+ glcpp_parser_create(&gl_ctx->Extensions, extensions, state, gl_ctx->API);
if (! gl_ctx->Const.DisableGLSLLineContinuations)
*shader = remove_line_continuations(parser, *shader);
--- /dev/null
+/* Compile with:
+ *
+ * glsl_compiler --version 140 --dump-builder int64.glsl > builtin_int64.h
+ *
+ * Using version 1.40+ prevents built-in variables from being included.
+ */
+#version 140
+#extension GL_MESA_shader_integer_functions: require
+
+uvec2
+umul64(uvec2 a, uvec2 b)
+{
+ uvec2 result;
+
+ umulExtended(a.x, b.x, result.y, result.x);
+ result.y += a.x * b.y + a.y * b.x;
+
+ return result;
+}