it seems tgsi has not been linked into gallium driver, there is undefined symbol, for instance, ureg_create.<br><br>
<div class="gmail_quote">On Thu, Aug 13, 2009 at 5:04 AM, Keith Whitwell <span dir="ltr"><<a href="mailto:keithw@kemper.freedesktop.org">keithw@kemper.freedesktop.org</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Module: Mesa<br>Branch: master<br>Commit: 002c76cfefe8c1ab12fb7031a649a30fb349a3e3<br>URL:    <a href="http://cgit.freedesktop.org/mesa/mesa/commit/?id=002c76cfefe8c1ab12fb7031a649a30fb349a3e3" target="_blank">http://cgit.freedesktop.org/mesa/mesa/commit/?id=002c76cfefe8c1ab12fb7031a649a30fb349a3e3</a><br>

<br>Author: Keith Whitwell <<a href="mailto:keithw@vmware.com">keithw@vmware.com</a>><br>Date:   Thu Aug 13 12:46:32 2009 +0100<br><br>util: convert u_simple_shaders to use tgsi_ureg<br><br>Much nicer now.<br><br>---<br>

<br> src/gallium/auxiliary/util/u_simple_shaders.c |  318 +++++--------------------<br> 1 files changed, 60 insertions(+), 258 deletions(-)<br><br>diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c<br>

index e519c35..1152d62 100644<br>--- a/src/gallium/auxiliary/util/u_simple_shaders.c<br>+++ b/src/gallium/auxiliary/util/u_simple_shaders.c<br>@@ -42,9 +42,7 @@<br> #include "util/u_memory.h"<br> #include "util/u_simple_shaders.h"<br>

<br>-#include "tgsi/tgsi_build.h"<br>-#include "tgsi/tgsi_dump.h"<br>-#include "tgsi/tgsi_parse.h"<br>+#include "tgsi/tgsi_ureg.h"<br><br><br><br>@@ -58,93 +56,31 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,<br>

                                    const uint *semantic_indexes)<br><br> {<br>-   struct pipe_shader_state shader;<br>-   struct tgsi_token tokens[100];<br>-   struct tgsi_header *header;<br>-   struct tgsi_processor *processor;<br>

-   struct tgsi_full_declaration decl;<br>-   struct tgsi_full_instruction inst;<br>-   const uint procType = TGSI_PROCESSOR_VERTEX;<br>-   uint ti, i;<br>+   struct ureg_program *ureg;<br>+   uint i;<br><br>-   /* shader header<br>

-    */<br>-   *(struct tgsi_version *) &tokens[0] = tgsi_build_version();<br>+   ureg = ureg_create( pipe, TGSI_PROCESSOR_VERTEX );<br>+   if (ureg == NULL)<br>+      return NULL;<br><br>-   header = (struct tgsi_header *) &tokens[1];<br>

-   *header = tgsi_build_header();<br>-<br>-   processor = (struct tgsi_processor *) &tokens[2];<br>-   *processor = tgsi_build_processor( procType, header );<br>-<br>-   ti = 3;<br>-<br>-   /* declare inputs */<br>-   for (i = 0; i < num_attribs; i++) {<br>

-      decl = tgsi_default_full_declaration();<br>-      decl.Declaration.File = TGSI_FILE_INPUT;<br>-<br>-      decl.Declaration.Semantic = 1;<br>-      decl.Semantic.SemanticName = semantic_names[i];<br>-      decl.Semantic.SemanticIndex = semantic_indexes[i];<br>

-<br>-      decl.DeclarationRange.First =<br>-      decl.DeclarationRange.Last = i;<br>-      ti += tgsi_build_full_declaration(&decl,<br>-                                        &tokens[ti],<br>-                                        header,<br>

-                                        Elements(tokens) - ti);<br>-   }<br>-<br>-   /* declare outputs */<br>   for (i = 0; i < num_attribs; i++) {<br>-      decl = tgsi_default_full_declaration();<br>-      decl.Declaration.File = TGSI_FILE_OUTPUT;<br>

-      decl.Declaration.Semantic = 1;<br>-      decl.Semantic.SemanticName = semantic_names[i];<br>-      decl.Semantic.SemanticIndex = semantic_indexes[i];<br>-      decl.DeclarationRange.First =<br>-         decl.DeclarationRange.Last = i;<br>

-      ti += tgsi_build_full_declaration(&decl,<br>-                                        &tokens[ti],<br>-                                        header,<br>-                                        Elements(tokens) - ti);<br>

+      struct ureg_src src;<br>+      struct ureg_dst dst;<br>+<br>+      src = ureg_DECL_vs_input( ureg,<br>+                                semantic_names[i],<br>+                                semantic_indexes[i]);<br>

+<br>+      dst = ureg_DECL_output( ureg,<br>+                              semantic_names[i],<br>+                              semantic_indexes[i]);<br>+<br>+      ureg_MOV( ureg, dst, src );<br>   }<br><br>-   /* emit MOV instructions */<br>

-   for (i = 0; i < num_attribs; i++) {<br>-      /* MOVE out[i], in[i]; */<br>-      inst = tgsi_default_full_instruction();<br>-      inst.Instruction.Opcode = TGSI_OPCODE_MOV;<br>-      inst.Instruction.NumDstRegs = 1;<br>

-      inst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;<br>-      inst.FullDstRegisters[0].DstRegister.Index = i;<br>-      inst.Instruction.NumSrcRegs = 1;<br>-      inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;<br>

-      inst.FullSrcRegisters[0].SrcRegister.Index = i;<br>-      ti += tgsi_build_full_instruction(&inst,<br>-                                        &tokens[ti],<br>-                                        header,<br>

-                                        Elements(tokens) - ti );<br>-   }<br>-<br>-   /* END instruction */<br>-   inst = tgsi_default_full_instruction();<br>-   inst.Instruction.Opcode = TGSI_OPCODE_END;<br>-   inst.Instruction.NumDstRegs = 0;<br>

-   inst.Instruction.NumSrcRegs = 0;<br>-   ti += tgsi_build_full_instruction(&inst,<br>-                                     &tokens[ti],<br>-                                     header,<br>-                                     Elements(tokens) - ti );<br>

-<br>-#if 0 /*debug*/<br>-   tgsi_dump(tokens, 0);<br>-#endif<br>-<br>-   shader.tokens = tokens;<br>+   ureg_END( ureg );<br><br>-   return pipe->create_vs_state(pipe, &shader);<br>+   return ureg_create_shader_and_destroy( ureg );<br>

 }<br><br><br>@@ -158,99 +94,29 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,<br> void *<br> util_make_fragment_tex_shader(struct pipe_context *pipe)<br> {<br>-   struct pipe_shader_state shader;<br>-   struct tgsi_token tokens[100];<br>

-   struct tgsi_header *header;<br>-   struct tgsi_processor *processor;<br>-   struct tgsi_full_declaration decl;<br>-   struct tgsi_full_instruction inst;<br>-   const uint procType = TGSI_PROCESSOR_FRAGMENT;<br>-   uint ti;<br>

-<br>-   /* shader header<br>-    */<br>-   *(struct tgsi_version *) &tokens[0] = tgsi_build_version();<br>-<br>-   header = (struct tgsi_header *) &tokens[1];<br>-   *header = tgsi_build_header();<br>-<br>-   processor = (struct tgsi_processor *) &tokens[2];<br>

-   *processor = tgsi_build_processor( procType, header );<br>-<br>-   ti = 3;<br>-<br>-   /* declare TEX[0] input */<br>-   decl = tgsi_default_full_declaration();<br>-   decl.Declaration.File = TGSI_FILE_INPUT;<br>-   /* XXX this could be linear... */<br>

-   decl.Declaration.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE;<br>-   decl.Declaration.Semantic = 1;<br>-   decl.Semantic.SemanticName = TGSI_SEMANTIC_GENERIC;<br>-   decl.Semantic.SemanticIndex = 0;<br>-   decl.DeclarationRange.First =<br>

-   decl.DeclarationRange.Last = 0;<br>-   ti += tgsi_build_full_declaration(&decl,<br>-                                     &tokens[ti],<br>-                                     header,<br>-                                     Elements(tokens) - ti);<br>

-<br>-   /* declare color[0] output */<br>-   decl = tgsi_default_full_declaration();<br>-   decl.Declaration.File = TGSI_FILE_OUTPUT;<br>-   decl.Declaration.Semantic = 1;<br>-   decl.Semantic.SemanticName = TGSI_SEMANTIC_COLOR;<br>

-   decl.Semantic.SemanticIndex = 0;<br>-   decl.DeclarationRange.First =<br>-   decl.DeclarationRange.Last = 0;<br>-   ti += tgsi_build_full_declaration(&decl,<br>-                                     &tokens[ti],<br>

-                                     header,<br>-                                     Elements(tokens) - ti);<br>-<br>-   /* declare sampler */<br>-   decl = tgsi_default_full_declaration();<br>-   decl.Declaration.File = TGSI_FILE_SAMPLER;<br>

-   decl.DeclarationRange.First =<br>-   decl.DeclarationRange.Last = 0;<br>-   ti += tgsi_build_full_declaration(&decl,<br>-                                     &tokens[ti],<br>-                                     header,<br>

-                                     Elements(tokens) - ti);<br>-<br>-   /* TEX instruction */<br>-   inst = tgsi_default_full_instruction();<br>-   inst.Instruction.Opcode = TGSI_OPCODE_TEX;<br>-   inst.Instruction.NumDstRegs = 1;<br>

-   inst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;<br>-   inst.FullDstRegisters[0].DstRegister.Index = 0;<br>-   inst.Instruction.NumSrcRegs = 2;<br>-   inst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;<br>

-   inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;<br>-   inst.FullSrcRegisters[0].SrcRegister.Index = 0;<br>-   inst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;<br>-   inst.FullSrcRegisters[1].SrcRegister.Index = 0;<br>

-   ti += tgsi_build_full_instruction(&inst,<br>-                                     &tokens[ti],<br>-                                     header,<br>-                                     Elements(tokens) - ti );<br>

-<br>-   /* END instruction */<br>-   inst = tgsi_default_full_instruction();<br>-   inst.Instruction.Opcode = TGSI_OPCODE_END;<br>-   inst.Instruction.NumDstRegs = 0;<br>-   inst.Instruction.NumSrcRegs = 0;<br>-   ti += tgsi_build_full_instruction(&inst,<br>

-                                     &tokens[ti],<br>-                                     header,<br>-                                     Elements(tokens) - ti );<br>-<br>-#if 0 /*debug*/<br>-   tgsi_dump(tokens, 0);<br>

-#endif<br>-<br>-   shader.tokens = tokens;<br>-<br>-   return pipe->create_fs_state(pipe, &shader);<br>+   struct ureg_program *ureg;<br>+   struct ureg_src sampler;<br>+   struct ureg_src tex;<br>+   struct ureg_dst out;<br>

+<br>+   ureg = ureg_create( pipe, TGSI_PROCESSOR_FRAGMENT );<br>+   if (ureg == NULL)<br>+      return NULL;<br>+<br>+   sampler = ureg_DECL_sampler( ureg );<br>+<br>+   tex = ureg_DECL_fs_input( ureg,<br>+                             TGSI_SEMANTIC_GENERIC, 0,<br>

+                             TGSI_INTERPOLATE_PERSPECTIVE );<br>+<br>+   out = ureg_DECL_output( ureg,<br>+                           TGSI_SEMANTIC_COLOR,<br>+                           0 );<br>+<br>+   ureg_TEX( ureg, out, TGSI_TEXTURE_2D, tex, sampler );<br>

+   ureg_END( ureg );<br>+<br>+   return ureg_create_shader_and_destroy( ureg );<br> }<br><br><br>@@ -263,87 +129,23 @@ util_make_fragment_tex_shader(struct pipe_context *pipe)<br> void *<br> util_make_fragment_passthrough_shader(struct pipe_context *pipe)<br>

 {<br>-   struct pipe_shader_state shader;<br>-   struct tgsi_token tokens[40];<br>-   struct tgsi_header *header;<br>-   struct tgsi_processor *processor;<br>-   struct tgsi_full_declaration decl;<br>-   struct tgsi_full_instruction inst;<br>

-   const uint procType = TGSI_PROCESSOR_FRAGMENT;<br>-   uint ti;<br>-<br>-   /* shader header<br>-    */<br>-   *(struct tgsi_version *) &tokens[0] = tgsi_build_version();<br>-<br>-   header = (struct tgsi_header *) &tokens[1];<br>

-   *header = tgsi_build_header();<br>-<br>-   processor = (struct tgsi_processor *) &tokens[2];<br>-   *processor = tgsi_build_processor( procType, header );<br>-<br>-   ti = 3;<br>-<br>-   /* declare input */<br>-   decl = tgsi_default_full_declaration();<br>

-   decl.Declaration.File = TGSI_FILE_INPUT;<br>-   decl.Declaration.Semantic = 1;<br>-   decl.Semantic.SemanticName = TGSI_SEMANTIC_COLOR;<br>-   decl.Semantic.SemanticIndex = 0;<br>-   decl.DeclarationRange.First =<br>
-      decl.DeclarationRange.Last = 0;<br>
-   ti += tgsi_build_full_declaration(&decl,<br>-                                     &tokens[ti],<br>-                                     header,<br>-                                     Elements(tokens) - ti);<br>

-<br>-   /* declare output */<br>-   decl = tgsi_default_full_declaration();<br>-   decl.Declaration.File = TGSI_FILE_OUTPUT;<br>-   decl.Declaration.Semantic = 1;<br>-   decl.Semantic.SemanticName = TGSI_SEMANTIC_COLOR;<br>

-   decl.Semantic.SemanticIndex = 0;<br>-   decl.DeclarationRange.First =<br>-      decl.DeclarationRange.Last = 0;<br>-   ti += tgsi_build_full_declaration(&decl,<br>-                                     &tokens[ti],<br>

-                                     header,<br>-                                     Elements(tokens) - ti);<br>-<br>-<br>-   /* MOVE out[0], in[0]; */<br>-   inst = tgsi_default_full_instruction();<br>-   inst.Instruction.Opcode = TGSI_OPCODE_MOV;<br>

-   inst.Instruction.NumDstRegs = 1;<br>-   inst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;<br>-   inst.FullDstRegisters[0].DstRegister.Index = 0;<br>-   inst.Instruction.NumSrcRegs = 1;<br>-   inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;<br>

-   inst.FullSrcRegisters[0].SrcRegister.Index = 0;<br>-   ti += tgsi_build_full_instruction(&inst,<br>-                                     &tokens[ti],<br>-                                     header,<br>-                                     Elements(tokens) - ti );<br>

-<br>-   /* END instruction */<br>-   inst = tgsi_default_full_instruction();<br>-   inst.Instruction.Opcode = TGSI_OPCODE_END;<br>-   inst.Instruction.NumDstRegs = 0;<br>-   inst.Instruction.NumSrcRegs = 0;<br>-   ti += tgsi_build_full_instruction(&inst,<br>

-                                     &tokens[ti],<br>-                                     header,<br>-                                     Elements(tokens) - ti );<br>-<br>-   assert(ti < Elements(tokens));<br>-<br>

-#if 0 /*debug*/<br>-   tgsi_dump(tokens, 0);<br>-#endif<br>-<br>-   shader.tokens = tokens;<br>-<br>-   return pipe->create_fs_state(pipe, &shader);<br>+   struct ureg_program *ureg;<br>+   struct ureg_src src;<br>

+   struct ureg_dst dst;<br>+<br>+   ureg = ureg_create( pipe, TGSI_PROCESSOR_FRAGMENT );<br>+   if (ureg == NULL)<br>+      return NULL;<br>+<br>+   src = ureg_DECL_fs_input( ureg, TGSI_SEMANTIC_COLOR, 0,<br>+                             TGSI_INTERPOLATE_PERSPECTIVE );<br>

+<br>+   dst = ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, 0 );<br>+<br>+   ureg_MOV( ureg, dst, src );<br>+   ureg_END( ureg );<br>+<br>+   return ureg_create_shader_and_destroy( ureg );<br> }<br><br><br><br>_______________________________________________<br>

mesa-commit mailing list<br><a href="mailto:mesa-commit@lists.freedesktop.org">mesa-commit@lists.freedesktop.org</a><br><a href="http://lists.freedesktop.org/mailman/listinfo/mesa-commit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-commit</a><br>

</blockquote></div><br>