---
 src/gallium/drivers/svga/svga_tgsi.c |  128 +++++++++++++++++-----------------
 1 file changed, 65 insertions(+), 63 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_tgsi.c 
b/src/gallium/drivers/svga/svga_tgsi.c
index 8bea7f8..56529c6 100644
--- a/src/gallium/drivers/svga/svga_tgsi.c
+++ b/src/gallium/drivers/svga/svga_tgsi.c
@@ -50,7 +50,8 @@
 static char err_buf[128];
 
 #if 0
-static void svga_destroy_shader_emitter( struct svga_shader_emitter *emit )
+static void
+svga_destroy_shader_emitter(struct svga_shader_emitter *emit)
 {
    if (emit->buf != err_buf)
       FREE(emit->buf);
@@ -58,12 +59,13 @@ static void svga_destroy_shader_emitter( struct 
svga_shader_emitter *emit )
 #endif
 
 
-static boolean svga_shader_expand( struct svga_shader_emitter *emit )
+static boolean
+svga_shader_expand(struct svga_shader_emitter *emit)
 {
    char *new_buf;
    unsigned newsize = emit->size * 2;
 
-   if(emit->buf != err_buf)
+   if (emit->buf != err_buf)
       new_buf = REALLOC(emit->buf, emit->size, newsize);
    else
       new_buf = NULL;
@@ -79,70 +81,76 @@ static boolean svga_shader_expand( struct 
svga_shader_emitter *emit )
    emit->ptr = new_buf + (emit->ptr - emit->buf);
    emit->buf = new_buf;
    return TRUE;
-}   
+}
+
 
-static INLINE boolean reserve(  struct svga_shader_emitter *emit,
-                                unsigned nr_dwords )
+static INLINE boolean
+reserve(struct svga_shader_emitter *emit, unsigned nr_dwords)
 {
    if (emit->ptr - emit->buf + nr_dwords * sizeof(unsigned) >= emit->size) {
-      if (!svga_shader_expand( emit ))
+      if (!svga_shader_expand(emit)) {
          return FALSE;
+      }
    }
 
    return TRUE;
 }
 
-boolean svga_shader_emit_dword( struct svga_shader_emitter *emit,
-                                unsigned dword )
+
+boolean
+svga_shader_emit_dword(struct svga_shader_emitter * emit, unsigned dword)
 {
    if (!reserve(emit, 1))
       return FALSE;
 
-   *(unsigned *)emit->ptr = dword;
+   *(unsigned *) emit->ptr = dword;
    emit->ptr += sizeof dword;
    return TRUE;
 }
 
-boolean svga_shader_emit_dwords( struct svga_shader_emitter *emit,
-                                 const unsigned *dwords,
-                                 unsigned nr )
+
+boolean
+svga_shader_emit_dwords(struct svga_shader_emitter * emit,
+                        const unsigned *dwords, unsigned nr)
 {
    if (!reserve(emit, nr))
       return FALSE;
 
-   memcpy( emit->ptr, dwords, nr * sizeof *dwords );
+   memcpy(emit->ptr, dwords, nr * sizeof *dwords);
    emit->ptr += nr * sizeof *dwords;
    return TRUE;
 }
 
-boolean svga_shader_emit_opcode( struct svga_shader_emitter *emit,
-                                 unsigned opcode )
+
+boolean
+svga_shader_emit_opcode(struct svga_shader_emitter * emit, unsigned opcode)
 {
    SVGA3dShaderInstToken *here;
 
    if (!reserve(emit, 1))
       return FALSE;
 
-   here = (SVGA3dShaderInstToken *)emit->ptr;
+   here = (SVGA3dShaderInstToken *) emit->ptr;
    here->value = opcode;
 
    if (emit->insn_offset) {
-      SVGA3dShaderInstToken *prev = (SVGA3dShaderInstToken *)(emit->buf + 
-                                                              
emit->insn_offset);
+      SVGA3dShaderInstToken *prev =
+         (SVGA3dShaderInstToken *) (emit->buf + emit->insn_offset);
       prev->size = (here - prev) - 1;
    }
-   
+
    emit->insn_offset = emit->ptr - emit->buf;
    emit->ptr += sizeof(unsigned);
    return TRUE;
 }
 
 
-static boolean svga_shader_emit_header( struct svga_shader_emitter *emit )
+static boolean
+svga_shader_emit_header(struct svga_shader_emitter *emit)
 {
    SVGA3dShaderVersion header;
 
-   memset( &header, 0, sizeof header );
+   memset(&header, 0, sizeof header);
 
    switch (emit->unit) {
    case PIPE_SHADER_FRAGMENT:
@@ -152,8 +160,8 @@ static boolean svga_shader_emit_header( struct 
svga_shader_emitter *emit )
       header.value = SVGA3D_VS_30;
       break;
    }
- 
-   return svga_shader_emit_dword( emit, header.value );
+
+   return svga_shader_emit_dword(emit, header.value);
 }
 
 
@@ -248,17 +256,17 @@ svga_remap_generic_index(int8_t 
remap_table[MAX_GENERIC_VARYING],
 }
 
 
-/* Parse TGSI shader and translate to SVGA/DX9 serialized
- * representation.  
+/**
+ * Parse TGSI shader and translate to SVGA/DX9 serialized
+ * representation.
  *
  * In this function SVGA shader is emitted to an in-memory buffer that
  * can be dynamically grown.  Once we've finished and know how large
  * it is, it will be copied to a hardware buffer for upload.
  */
 static struct svga_shader_result *
-svga_tgsi_translate( const struct svga_shader *shader,
-                     struct svga_compile_key key,
-                     unsigned unit )
+svga_tgsi_translate(const struct svga_shader *shader,
+                    struct svga_compile_key key, unsigned unit)
 {
    struct svga_shader_result *result = NULL;
    struct svga_shader_emitter emit;
@@ -275,10 +283,10 @@ svga_tgsi_translate( const struct svga_shader *shader,
    emit.unit = unit;
    emit.key = key;
 
-   tgsi_scan_shader( shader->tokens, &emit.info);
+   tgsi_scan_shader(shader->tokens, &emit.info);
 
    emit.imm_start = emit.info.file_max[TGSI_FILE_CONSTANT] + 1;
-   
+
    if (unit == PIPE_SHADER_FRAGMENT)
       emit.imm_start += key.fkey.num_unnormalized_coords;
 
@@ -286,23 +294,25 @@ svga_tgsi_translate( const struct svga_shader *shader,
       emit.imm_start += key.vkey.need_prescale ? 2 : 0;
    }
 
-   emit.nr_hw_float_const = (emit.imm_start + 
emit.info.file_max[TGSI_FILE_IMMEDIATE] + 1);
+   emit.nr_hw_float_const =
+      (emit.imm_start + emit.info.file_max[TGSI_FILE_IMMEDIATE] + 1);
 
    emit.nr_hw_temp = emit.info.file_max[TGSI_FILE_TEMPORARY] + 1;
-   
+
    if (emit.nr_hw_temp >= SVGA3D_TEMPREG_MAX) {
-      debug_printf("svga: too many temporary registers (%u)\n", 
emit.nr_hw_temp);
+      debug_printf("svga: too many temporary registers (%u)\n",
+                   emit.nr_hw_temp);
       goto fail;
    }
 
    emit.in_main_func = TRUE;
 
-   if (!svga_shader_emit_header( &emit )) {
+   if (!svga_shader_emit_header(&emit)) {
       debug_printf("svga: emit header failed\n");
       goto fail;
    }
 
-   if (!svga_shader_emit_instructions( &emit, shader->tokens )) {
+   if (!svga_shader_emit_instructions(&emit, shader->tokens)) {
       debug_printf("svga: emit instructions failed\n");
       goto fail;
    }
@@ -312,39 +322,34 @@ svga_tgsi_translate( const struct svga_shader *shader,
       goto fail;
 
    result->shader = shader;
-   result->tokens = (const unsigned *)emit.buf;
+   result->tokens = (const unsigned *) emit.buf;
    result->nr_tokens = (emit.ptr - emit.buf) / sizeof(unsigned);
    memcpy(&result->key, &key, sizeof key);
    result->id = UTIL_BITMASK_INVALID_INDEX;
 
-   if (SVGA_DEBUG & DEBUG_TGSI) 
-   {
-      debug_printf( "#####################################\n" );
-      debug_printf( "Shader %u below\n", shader->id );
-      tgsi_dump( shader->tokens, 0 );
+   if (SVGA_DEBUG & DEBUG_TGSI) {
+      debug_printf("#####################################\n");
+      debug_printf("Shader %u below\n", shader->id);
+      tgsi_dump(shader->tokens, 0);
       if (SVGA_DEBUG & DEBUG_TGSI) {
-         debug_printf( "Shader %u compiled below\n", shader->id );
-         svga_shader_dump( result->tokens,
-                           result->nr_tokens ,
-                           FALSE );
+         debug_printf("Shader %u compiled below\n", shader->id);
+         svga_shader_dump(result->tokens, result->nr_tokens, FALSE);
       }
-      debug_printf( "#####################################\n" );
+      debug_printf("#####################################\n");
    }
 
    return result;
 
-fail:
+ fail:
    FREE(result);
    FREE(emit.buf);
    return NULL;
 }
 
 
-
-
 struct svga_shader_result *
-svga_translate_fragment_program( const struct svga_fragment_shader *fs,
-                                 const struct svga_fs_compile_key *fkey )
+svga_translate_fragment_program(const struct svga_fragment_shader *fs,
+                                const struct svga_fs_compile_key *fkey)
 {
    struct svga_compile_key key;
 
@@ -355,14 +360,13 @@ svga_translate_fragment_program( const struct 
svga_fragment_shader *fs,
    memcpy(key.generic_remap_table, fs->generic_remap_table,
           sizeof(fs->generic_remap_table));
 
-   return svga_tgsi_translate( &fs->base, 
-                               key,
-                               PIPE_SHADER_FRAGMENT );
+   return svga_tgsi_translate(&fs->base, key, PIPE_SHADER_FRAGMENT);
 }
 
+
 struct svga_shader_result *
-svga_translate_vertex_program( const struct svga_vertex_shader *vs,
-                               const struct svga_vs_compile_key *vkey )
+svga_translate_vertex_program(const struct svga_vertex_shader *vs,
+                              const struct svga_vs_compile_key *vkey)
 {
    struct svga_compile_key key;
 
@@ -375,15 +379,13 @@ svga_translate_vertex_program( const struct 
svga_vertex_shader *vs,
     */
    svga_remap_generics(vkey->fs_generic_inputs, key.generic_remap_table);
 
-   return svga_tgsi_translate( &vs->base, 
-                               key,
-                               PIPE_SHADER_VERTEX );
+   return svga_tgsi_translate(&vs->base, key, PIPE_SHADER_VERTEX);
 }
 
 
-void svga_destroy_shader_result( struct svga_shader_result *result )
+void
+svga_destroy_shader_result(struct svga_shader_result *result)
 {
-   FREE((unsigned *)result->tokens);
+   FREE((unsigned *) result->tokens);
    FREE(result);
 }
-
-- 
1.7.10.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to