Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #include "pipe/p_compiler.h"
  3. #include "pipe/p_context.h"
  4. #include "pipe/p_shader_tokens.h"
  5. #include "pipe/p_state.h"
  6. #include "tgsi/tgsi_text.h"
  7. #include "util/u_debug.h"
  8. #include "util/u_memory.h"
  9. #include "state_tracker/graw.h"
  10.  
  11. #if 0
  12. /* Helper functions.  These are the same for all graw implementations.
  13.  */
  14. PUBLIC void *
  15. graw_parse_geometry_shader(struct pipe_context *pipe,
  16.                            const char *text)
  17. {
  18.    struct tgsi_token tokens[1024];
  19.    struct pipe_shader_state state;
  20.  
  21.    if (!tgsi_text_translate(text, tokens, Elements(tokens)))
  22.       return NULL;
  23.  
  24.    memset(&state, 0, sizeof state);
  25.    state.tokens = tokens;
  26.    return pipe->create_gs_state(pipe, &state);
  27. }
  28.  
  29. PUBLIC void *
  30. graw_parse_vertex_shader(struct pipe_context *pipe,
  31.                          const char *text)
  32. {
  33.    struct tgsi_token tokens[1024];
  34.    struct pipe_shader_state state;
  35.  
  36.    if (!tgsi_text_translate(text, tokens, Elements(tokens)))
  37.       return NULL;
  38.  
  39.    memset(&state, 0, sizeof state);
  40.    state.tokens = tokens;
  41.    return pipe->create_vs_state(pipe, &state);
  42. }
  43.  
  44. PUBLIC void *
  45. graw_parse_fragment_shader(struct pipe_context *pipe,
  46.                            const char *text)
  47. {
  48.    struct tgsi_token tokens[1024];
  49.    struct pipe_shader_state state;
  50.  
  51.    if (!tgsi_text_translate(text, tokens, Elements(tokens)))
  52.       return NULL;
  53.  
  54.    memset(&state, 0, sizeof state);
  55.    state.tokens = tokens;
  56.    return pipe->create_fs_state(pipe, &state);
  57. }
  58. #endif
  59.  
  60. static char out_filename[256] = "";
  61.  
  62. PUBLIC boolean
  63. graw_parse_args(int *argi,
  64.                 int argc,
  65.                 char *argv[])
  66. {
  67.    if (strcmp(argv[*argi], "-o") == 0) {
  68.       if (*argi + 1 >= argc) {
  69.          return FALSE;
  70.       }
  71.  
  72.       strncpy(out_filename, argv[*argi + 1], sizeof(out_filename) - 1);
  73.       out_filename[sizeof(out_filename) - 1] = '\0';
  74.       *argi += 2;
  75.       return TRUE;
  76.    }
  77.  
  78.    return FALSE;
  79. }
  80.  
  81. PUBLIC boolean
  82. graw_save_surface_to_file(struct pipe_context *pipe,
  83.                           struct pipe_surface *surface,
  84.                           const char *filename)
  85. {
  86.    if (!filename || !*filename) {
  87.       filename = out_filename;
  88.       if (!filename || !*filename) {
  89.          return FALSE;
  90.       }
  91.    }
  92.  
  93.    /* XXX: Make that working in release builds.
  94.     */
  95. //   debug_dump_surface_bmp(pipe, filename, surface);
  96.    return TRUE;
  97. }
  98.