From d76a7b61bb2de2425289f462e07a678cf3c4ba59 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 24 Oct 2007 08:34:01 -0400 Subject: [PATCH] Cleanup some code. --- configs/default | 3 +-- configs/linux-llvm | 16 ++++++++-------- src/mesa/pipe/draw/draw_private.h | 2 ++ src/mesa/pipe/draw/draw_vertex_fetch.c | 4 ++-- src/mesa/pipe/draw/draw_vertex_shader.c | 7 +++++++ src/mesa/pipe/draw/draw_vertex_shader_llvm.c | 4 ++++ src/mesa/pipe/llvm/llvmtgsi.cpp | 6 ++++-- src/mesa/pipe/llvm/llvmtgsi.h | 4 ++++ src/mesa/pipe/softpipe/sp_quad_fs.c | 4 +++- src/mesa/sources | 2 +- src/mesa/state_tracker/st_program.c | 6 +++++- 11 files changed, 41 insertions(+), 17 deletions(-) diff --git a/configs/default b/configs/default index 9379833..a7de3f8 100644 --- a/configs/default +++ b/configs/default @@ -40,8 +40,6 @@ GLUT_LIB = glut GLW_LIB = GLw OSMESA_LIB = OSMesa -LLVM_CFLAGS=-DMESA_NO_LLVM=1 -LLVM_CXXFLAGS=-DMESA_NO_LLVM=1 # Library names (actual file names) GL_LIB_NAME = lib$(GL_LIB).so @@ -67,6 +65,7 @@ DRIVER_DIRS = x11 osmesa # Which subdirs under $(TOP)/progs/ to enter: PROGRAM_DIRS = demos redbook samples glsl xdemos + # Library/program dependencies #EXTRA_LIB_PATH ?= GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread diff --git a/configs/linux-llvm b/configs/linux-llvm index addefaa..8e9b408 100644 --- a/configs/linux-llvm +++ b/configs/linux-llvm @@ -11,21 +11,21 @@ LLVM_VERSION := $(shell llvm-config --version) ifeq ($(LLVM_VERSION),) $(warning Could not find LLVM! Make Sure 'llvm-config' is in the path) - MESA_NO_LLVM=1 + MESA_LLVM=0 else - MESA_NO_LLVM=0 + MESA_LLVM=1 $(info Using LLVM version: $(LLVM_VERSION)) endif -ifeq ($(MESA_NO_LLVM),0) -# LLVM_CFLAGS=`llvm-config --cflags` -DMESA_NO_LLVM=0 - LLVM_CFLAGS=-DMESA_NO_LLVM=0 - LLVM_CXXFLAGS=`llvm-config --cxxflags` -DMESA_NO_LLVM=0 -Wno-long-long +ifeq ($(MESA_LLVM),1) +# LLVM_CFLAGS=`llvm-config --cflags` -DMESA_LLVM=1 + LLVM_CFLAGS=-DMESA_LLVM=1 + LLVM_CXXFLAGS=`llvm-config --cxxflags` -DMESA_LLVM=1 -Wno-long-long LLVM_LDFLAGS=`llvm-config --ldflags` LLVM_LIBS=`llvm-config --libs` else - LLVM_CFLAGS=-DMESA_NO_LLVM=1 - LLVM_CXXFLAGS=-DMESA_NO_LLVM=1 + LLVM_CFLAGS= + LLVM_CXXFLAGS= endif GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index b672cc2..e4c0551 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -251,7 +251,9 @@ extern void draw_vertex_cache_reset_vertex_ids( struct draw_context *draw ); extern void draw_vertex_shader_queue_flush( struct draw_context *draw ); +#ifdef MESA_LLVM extern void draw_vertex_shader_queue_flush_llvm( struct draw_context *draw ); +#endif struct tgsi_exec_machine; diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index 1b093b7..de1cd06 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -96,7 +96,7 @@ void draw_vertex_fetch( struct draw_context *draw, for (j = 0; j < count; j++) { uint attr; - printf("fetch vertex %u: \n", j); + /*printf("fetch vertex %u: \n", j);*/ /* loop over vertex attributes (vertex shader inputs) */ for (attr = 0; attr < draw->vertex_shader->state->num_inputs; attr++) { @@ -111,7 +111,7 @@ void draw_vertex_fetch( struct draw_context *draw, fetch_attrib4(src, draw->vertex_element[attr].src_format, p); - printf("> %u: %f %f %f %f\n", attr, p[0], p[1], p[2], p[3]); + /*printf(" %u: %f %f %f %f\n", attr, p[0], p[1], p[2], p[3]);*/ /* Transform to AoS xxxx/yyyy/zzzz/wwww representation: */ diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index fb20dfa..24cbf20 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -161,6 +161,10 @@ run_vertex_program(struct draw_context *draw, vOut[j]->data[slot][3] = machine->Outputs[slot].xyzw[3].f[j]; #if DBG printf("output[%d][%d]: %f %f %f %f\n", j, slot, + vOut[j]->data[slot][0], + vOut[j]->data[slot][1], + vOut[j]->data[slot][2], + vOut[j]->data[slot][3]); #endif } } /* loop over vertices */ @@ -175,10 +179,13 @@ void draw_vertex_shader_queue_flush( struct draw_context *draw ) { unsigned i, j; +// fprintf(stderr, " q(%d) ", draw->vs.queue_nr ); +#ifdef MESA_LLVM if (draw->vertex_shader->state->llvm_prog) { draw_vertex_shader_queue_flush_llvm(draw); return; } +#endif /* run vertex shader on vertex cache entries, four per invokation */ for (i = 0; i < draw->vs.queue_nr; i += 4) { diff --git a/src/mesa/pipe/draw/draw_vertex_shader_llvm.c b/src/mesa/pipe/draw/draw_vertex_shader_llvm.c index bcc44f7..99f0aca 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader_llvm.c +++ b/src/mesa/pipe/draw/draw_vertex_shader_llvm.c @@ -35,6 +35,8 @@ #include "draw_context.h" #include "draw_vertex.h" +#ifdef MESA_LLVM + #include "pipe/llvm/llvmtgsi.h" #include "pipe/tgsi/exec/tgsi_core.h" @@ -199,3 +201,5 @@ void draw_vertex_shader_queue_flush_llvm(struct draw_context *draw) draw->vs.queue_nr = 0; } + +#endif /* MESA_LLVM */ diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp index ade4573..066175c 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.cpp +++ b/src/mesa/pipe/llvm/llvmtgsi.cpp @@ -10,7 +10,6 @@ #include "pipe/tgsi/exec/tgsi_util.h" #include "pipe/tgsi/exec/tgsi_parse.h" #include "pipe/tgsi/exec/tgsi_dump.h" -//#include "pipe/tgsi/tgsi_platform.h" #include #include @@ -36,6 +35,7 @@ #include #include +#ifdef MESA_LLVM struct ga_llvm_prog { void *module; @@ -159,7 +159,7 @@ translate_instruction(llvm::Module *module, } else if (src->SrcRegister.File == TGSI_FILE_TEMPORARY) { val = storage->tempElement(src->SrcRegister.Index); } else { - fprintf(stderr, "ERROR: not support llvm source\n"); + fprintf(stderr, "ERROR: not supported llvm source\n"); return; } @@ -751,3 +751,5 @@ void ga_llvm_prog_dump(struct ga_llvm_prog *prog, const char *file_prefix) std::cout<<"; ---------- End shader "<id<InterpCoefs ); } else { - //ga_llvm_prog_exec(softpipe->fs->llvm_prog); +#ifdef MESA_LLVM + /*ga_llvm_prog_exec(softpipe->fs->llvm_prog);*/ +#endif quad->mask &= tgsi_exec_machine_run( machine ); } diff --git a/src/mesa/sources b/src/mesa/sources index 1bc45c9..6d1ba9b 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -189,7 +189,7 @@ TGSIDECO_SOURCES = \ TGSIMESA_SOURCES = \ pipe/tgsi/mesa/mesa_to_tgsi.c -ifeq ($(MESA_NO_LLVM),0) +ifeq ($(MESA_LLVM),1) LLVMTGSI_SOURCES = \ pipe/llvm/llvmtgsi.cpp \ pipe/llvm/storage.cpp \ diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 0f9d769..6794227 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -251,7 +251,9 @@ st_translate_vertex_program(struct st_context *st, tokensOut, maxTokens); vs.tokens = tokensOut; +#ifdef MESA_LLVM vs.llvm_prog = ga_llvm_from_tgsi(st->pipe, vs.tokens); +#endif cso = st_cached_vs_state(st, &vs); stvp->vs = cso; @@ -407,7 +409,9 @@ st_translate_fragment_program(struct st_context *st, tokensOut, maxTokens); fs.tokens = tokensOut; - fs.llvm_prog = ga_llvm_from_tgsi(st->pipe, fs.tokens); +#ifdef MESA_LLVM + /*fs.llvm_prog = ga_llvm_from_tgsi(st->pipe, fs.tokens);*/ +#endif cso = st_cached_fs_state(st, &fs); stfp->fs = cso; -- 2.7.4