Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

st_program.h 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /**************************************************************************
  2. *
  3. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  22. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. /*
  28. * Authors:
  29. * Keith Whitwell <keith@tungstengraphics.com>
  30. */
  31. #ifndef ST_PROGRAM_H
  32. #define ST_PROGRAM_H
  33. #include "main/mtypes.h"
  34. #include "shader/program.h"
  35. #include "pipe/p_shader_tokens.h"
  36. struct cso_fragment_shader;
  37. struct cso_vertex_shader;
  38. struct translated_vertex_program;
  39. /**
  40. * Derived from Mesa gl_fragment_program:
  41. */
  42. struct st_fragment_program
  43. {
  44. struct gl_fragment_program Base;
  45. GLuint serialNo;
  46. GLuint input_to_slot[FRAG_ATTRIB_MAX]; /**< Maps FRAG_ATTRIB_x to slot */
  47. GLuint num_input_slots;
  48. /** map FP input back to VP output */
  49. GLuint input_map[PIPE_MAX_SHADER_INPUTS];
  50. ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
  51. ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
  52. struct pipe_shader_state state;
  53. void *driver_shader;
  54. GLuint param_state;
  55. /** List of vertex programs which have been translated such that their
  56. * outputs match this fragment program's inputs.
  57. */
  58. struct translated_vertex_program *vertex_programs;
  59. /** Program prefixed with glBitmap prologue */
  60. struct st_fragment_program *bitmap_program;
  61. uint bitmap_sampler;
  62. };
  63. /**
  64. * Derived from Mesa gl_fragment_program:
  65. */
  66. struct st_vertex_program
  67. {
  68. struct gl_vertex_program Base; /**< The Mesa vertex program */
  69. GLuint serialNo;
  70. /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */
  71. GLuint input_to_index[VERT_ATTRIB_MAX];
  72. /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
  73. GLuint index_to_input[PIPE_MAX_SHADER_INPUTS];
  74. GLuint num_inputs;
  75. struct pipe_shader_state state;
  76. void *driver_shader;
  77. /** For using our private draw module (glRasterPos) */
  78. struct draw_vertex_shader *draw_shader;
  79. GLuint param_state;
  80. };
  81. static INLINE struct st_fragment_program *
  82. st_fragment_program( struct gl_fragment_program *fp )
  83. {
  84. return (struct st_fragment_program *)fp;
  85. }
  86. static INLINE struct st_vertex_program *
  87. st_vertex_program( struct gl_vertex_program *vp )
  88. {
  89. return (struct st_vertex_program *)vp;
  90. }
  91. static INLINE void
  92. st_reference_vertprog(struct st_context *st,
  93. struct st_vertex_program **ptr,
  94. struct st_vertex_program *prog)
  95. {
  96. _mesa_reference_program(st->ctx,
  97. (struct gl_program **) ptr,
  98. (struct gl_program *) prog);
  99. }
  100. static INLINE void
  101. st_reference_fragprog(struct st_context *st,
  102. struct st_fragment_program **ptr,
  103. struct st_fragment_program *prog)
  104. {
  105. _mesa_reference_program(st->ctx,
  106. (struct gl_program **) ptr,
  107. (struct gl_program *) prog);
  108. }
  109. extern void
  110. st_translate_fragment_program(struct st_context *st,
  111. struct st_fragment_program *fp,
  112. const GLuint inputMapping[]);
  113. extern void
  114. st_translate_vertex_program(struct st_context *st,
  115. struct st_vertex_program *vp,
  116. const GLuint vert_output_to_slot[],
  117. const ubyte *fs_input_semantic_name,
  118. const ubyte *fs_input_semantic_index);
  119. extern void
  120. st_print_shaders(GLcontext *ctx);
  121. #endif