Mesa (master): gallivm: Use debug_printf in lp_build_printf.
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Wed May 2 09:25:59 UTC 2012
Module: Mesa
Branch: master
Commit: 494619ebacb632a879ebeecf0a1d732c10ddf25b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=494619ebacb632a879ebeecf0a1d732c10ddf25b
Author: José Fonseca <jfonseca at vmware.com>
Date: Wed Apr 25 16:35:05 2012 +0100
gallivm: Use debug_printf in lp_build_printf.
So that its output can be seen on GUI window apps.
Tested-by: James Benton <jbenton at vmware.com>
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
---
src/gallium/auxiliary/gallivm/lp_bld_printf.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
index 806b8e0..5e359ce 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
@@ -81,17 +81,20 @@ lp_build_printf(struct gallivm_state *gallivm, const char *fmt, ...)
int argcount = lp_get_printf_arg_count(fmt);
LLVMBuilderRef builder = gallivm->builder;
LLVMContextRef context = gallivm->context;
- LLVMModuleRef module = gallivm->module;
LLVMValueRef params[50];
LLVMValueRef fmtarg = lp_build_const_string(gallivm, fmt);
- LLVMValueRef func_printf = LLVMGetNamedFunction(module, "printf");
+ LLVMTypeRef printf_type;
+ LLVMValueRef func_printf;
assert(Elements(params) >= argcount + 1);
- if (!func_printf) {
- LLVMTypeRef printf_type = LLVMFunctionType(LLVMIntTypeInContext(context, 32), NULL, 0, 1);
- func_printf = LLVMAddFunction(module, "printf", printf_type);
- }
+ printf_type = LLVMFunctionType(LLVMIntTypeInContext(context, 32), NULL, 0, 1);
+
+ func_printf = lp_build_const_int_pointer(gallivm, func_to_pointer((func_pointer)debug_printf));
+
+ func_printf = LLVMBuildBitCast(gallivm->builder, func_printf,
+ LLVMPointerType(printf_type, 0),
+ "debug_printf");
params[0] = fmtarg;
More information about the mesa-commit
mailing list