Clone of mesa.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

draw_vs.h 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /**************************************************************************
  2. *
  3. * Copyright 2007 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. /* Authors: Keith Whitwell <keith@tungstengraphics.com>
  28. */
  29. #ifndef DRAW_VS_H
  30. #define DRAW_VS_H
  31. #include "draw_context.h"
  32. #include "draw_private.h"
  33. struct draw_context;
  34. struct pipe_shader_state;
  35. struct draw_varient_input
  36. {
  37. enum pipe_format format;
  38. unsigned buffer;
  39. unsigned offset;
  40. };
  41. struct draw_varient_output
  42. {
  43. enum pipe_format format; /* output format */
  44. unsigned vs_output:8; /* which vertex shader output is this? */
  45. unsigned offset:24; /* offset into output vertex */
  46. };
  47. struct draw_varient_element {
  48. struct draw_varient_input in;
  49. struct draw_varient_output out;
  50. };
  51. struct draw_vs_varient_key {
  52. unsigned output_stride;
  53. unsigned nr_elements:8; /* max2(nr_inputs, nr_outputs) */
  54. unsigned nr_inputs:8;
  55. unsigned nr_outputs:8;
  56. unsigned viewport:1;
  57. unsigned clip:1;
  58. unsigned pad:5;
  59. struct draw_varient_element element[PIPE_MAX_ATTRIBS];
  60. };
  61. struct draw_vs_varient;
  62. typedef void (PIPE_CDECL *vsv_run_elts_func)( struct draw_vs_varient *,
  63. const unsigned *elts,
  64. unsigned count,
  65. void *output_buffer);
  66. typedef void (PIPE_CDECL *vsv_run_linear_func)( struct draw_vs_varient *,
  67. unsigned start,
  68. unsigned count,
  69. void *output_buffer);
  70. struct draw_vs_varient {
  71. struct draw_vs_varient_key key;
  72. struct draw_vertex_shader *vs;
  73. void (*set_input)( struct draw_vs_varient *,
  74. unsigned i,
  75. const void *ptr,
  76. unsigned stride );
  77. void (*set_constants)( struct draw_vs_varient *,
  78. const float (*constants)[4] );
  79. void (*set_viewport)( struct draw_vs_varient *,
  80. const struct pipe_viewport_state * );
  81. void (PIPE_CDECL *run_linear)( struct draw_vs_varient *shader,
  82. unsigned start,
  83. unsigned count,
  84. void *output_buffer );
  85. void (PIPE_CDECL *run_elts)( struct draw_vs_varient *shader,
  86. const unsigned *elts,
  87. unsigned count,
  88. void *output_buffer );
  89. void (*destroy)( struct draw_vs_varient * );
  90. };
  91. /**
  92. * Private version of the compiled vertex_shader
  93. */
  94. struct draw_vertex_shader {
  95. struct draw_context *draw;
  96. /* This member will disappear shortly:
  97. */
  98. struct pipe_shader_state state;
  99. struct tgsi_shader_info info;
  100. /*
  101. */
  102. struct draw_vs_varient *varient[16];
  103. unsigned nr_varients;
  104. struct draw_vs_varient *(*create_varient)( struct draw_vertex_shader *shader,
  105. const struct draw_vs_varient_key *key );
  106. void (*prepare)( struct draw_vertex_shader *shader,
  107. struct draw_context *draw );
  108. /* Run the shader - this interface will get cleaned up in the
  109. * future:
  110. */
  111. void (*run_linear)( struct draw_vertex_shader *shader,
  112. const float (*input)[4],
  113. float (*output)[4],
  114. const float (*constants)[4],
  115. unsigned count,
  116. unsigned input_stride,
  117. unsigned output_stride );
  118. void (*delete)( struct draw_vertex_shader * );
  119. };
  120. struct draw_vs_varient *
  121. draw_vs_lookup_varient( struct draw_vertex_shader *base,
  122. const struct draw_vs_varient_key *key );
  123. /********************************************************************************
  124. * Internal functions:
  125. */
  126. struct draw_vertex_shader *
  127. draw_create_vs_exec(struct draw_context *draw,
  128. const struct pipe_shader_state *templ);
  129. struct draw_vertex_shader *
  130. draw_create_vs_sse(struct draw_context *draw,
  131. const struct pipe_shader_state *templ);
  132. struct draw_vertex_shader *
  133. draw_create_vs_llvm(struct draw_context *draw,
  134. const struct pipe_shader_state *templ);
  135. struct draw_vs_varient_key;
  136. struct draw_vertex_shader;
  137. struct draw_vs_varient *draw_vs_varient_aos_sse( struct draw_vertex_shader *vs,
  138. const struct draw_vs_varient_key *key );
  139. /********************************************************************************
  140. * Helpers for vs implementations that don't do their own fetch/emit varients.
  141. * Means these can be shared between shaders.
  142. */
  143. struct translate;
  144. struct translate_key;
  145. struct translate *draw_vs_get_fetch( struct draw_context *draw,
  146. struct translate_key *key );
  147. struct translate *draw_vs_get_emit( struct draw_context *draw,
  148. struct translate_key *key );
  149. struct draw_vs_varient *draw_vs_varient_generic( struct draw_vertex_shader *vs,
  150. const struct draw_vs_varient_key *key );
  151. static INLINE int draw_vs_varient_keysize( const struct draw_vs_varient_key *key )
  152. {
  153. return 2 * sizeof(int) + key->nr_elements * sizeof(struct draw_varient_element);
  154. }
  155. static INLINE int draw_vs_varient_key_compare( const struct draw_vs_varient_key *a,
  156. const struct draw_vs_varient_key *b )
  157. {
  158. int keysize = draw_vs_varient_keysize(a);
  159. return memcmp(a, b, keysize);
  160. }
  161. #define MAX_TGSI_VERTICES 4
  162. #endif