Clone of mesa.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

draw_gs.h 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**************************************************************************
  2. *
  3. * Copyright 2009 VMware, Inc.
  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 VMWARE 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. #ifndef DRAW_GS_H
  28. #define DRAW_GS_H
  29. #include "draw_context.h"
  30. #include "draw_private.h"
  31. #define MAX_TGSI_PRIMITIVES 4
  32. struct draw_context;
  33. #ifdef HAVE_LLVM
  34. struct draw_gs_jit_context;
  35. struct draw_gs_llvm_variant;
  36. /**
  37. * Structure holding the inputs to the geometry shader. It uses SOA layout.
  38. * The dimensions are as follows:
  39. * - maximum number of vertices for a geometry shader input primitive
  40. * (6 for triangle_adjacency)
  41. * - maximum number of attributes for each vertex
  42. * - four channels per each attribute (x,y,z,w)
  43. * - number of input primitives equal to the SOA vector length
  44. */
  45. struct draw_gs_inputs {
  46. float data[6][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS][TGSI_NUM_CHANNELS];
  47. };
  48. #endif
  49. /**
  50. * Private version of the compiled geometry shader
  51. */
  52. struct draw_geometry_shader {
  53. struct draw_context *draw;
  54. struct tgsi_exec_machine *machine;
  55. /* This member will disappear shortly:*/
  56. struct pipe_shader_state state;
  57. struct tgsi_shader_info info;
  58. unsigned position_output;
  59. unsigned viewport_index_output;
  60. unsigned clipdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
  61. unsigned culldistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
  62. unsigned max_output_vertices;
  63. unsigned primitive_boundary;
  64. unsigned input_primitive;
  65. unsigned output_primitive;
  66. unsigned *primitive_lengths;
  67. unsigned emitted_vertices;
  68. unsigned emitted_primitives;
  69. float (*tmp_output)[4];
  70. unsigned vertex_size;
  71. unsigned in_prim_idx;
  72. unsigned input_vertex_stride;
  73. unsigned fetched_prim_count;
  74. const float (*input)[4];
  75. const struct tgsi_shader_info *input_info;
  76. unsigned vector_length;
  77. unsigned max_out_prims;
  78. #ifdef HAVE_LLVM
  79. struct draw_gs_inputs *gs_input;
  80. struct draw_gs_jit_context *jit_context;
  81. struct draw_gs_llvm_variant *current_variant;
  82. struct vertex_header *gs_output;
  83. int **llvm_prim_lengths;
  84. int *llvm_emitted_primitives;
  85. int *llvm_emitted_vertices;
  86. int *llvm_prim_ids;
  87. #endif
  88. void (*fetch_inputs)(struct draw_geometry_shader *shader,
  89. unsigned *indices,
  90. unsigned num_vertices,
  91. unsigned prim_idx);
  92. void (*fetch_outputs)(struct draw_geometry_shader *shader,
  93. unsigned num_primitives,
  94. float (**p_output)[4]);
  95. void (*prepare)(struct draw_geometry_shader *shader,
  96. const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
  97. const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS]);
  98. unsigned (*run)(struct draw_geometry_shader *shader,
  99. unsigned input_primitives);
  100. };
  101. void draw_geometry_shader_new_instance(struct draw_geometry_shader *gs);
  102. /*
  103. * Returns the number of vertices emitted.
  104. * The vertex shader can emit any number of vertices as long as it's
  105. * smaller than the GS_MAX_OUTPUT_VERTICES shader property.
  106. */
  107. int draw_geometry_shader_run(struct draw_geometry_shader *shader,
  108. const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
  109. const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
  110. const struct draw_vertex_info *input_verts,
  111. const struct draw_prim_info *input_prim,
  112. const struct tgsi_shader_info *input_info,
  113. struct draw_vertex_info *output_verts,
  114. struct draw_prim_info *output_prims );
  115. void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
  116. struct draw_context *draw);
  117. int draw_gs_max_output_vertices(struct draw_geometry_shader *shader,
  118. unsigned pipe_prim);
  119. #ifdef HAVE_LLVM
  120. void draw_gs_set_current_variant(struct draw_geometry_shader *shader,
  121. struct draw_gs_llvm_variant *variant);
  122. #endif
  123. #endif