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

lp_bld_tgsi_action.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright 2011-2012 Advanced Micro Devices, Inc.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sub license, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial portions
  15. * of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  20. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  21. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. **************************************************************************/
  26. /**
  27. *
  28. * @author Tom Stellard <thomas.stellard@amd.com>
  29. *
  30. */
  31. #ifndef LP_BLD_TGSI_ACTION_H
  32. #define LP_BLD_TGSI_ACTION_H
  33. #include <llvm-c/Core.h>
  34. struct lp_build_tgsi_context;
  35. struct lp_build_emit_data {
  36. /** Arguments that are passed to lp_build_tgsi_action::emit. The
  37. * order of the arguments should be as follows:
  38. * SOA: s0.x, s0.y, s0.z, s0.w, s1.x, s1.y, s1.z, s1.w, s2.x, s2.y, s2.x, s2.w
  39. * AOS: s0.xyzw, s1.xyzw, s2.xyzw
  40. * TEXTURE Instructions: coord.xyzw
  41. *
  42. * Arguments should be packed into the args array. For example an SOA
  43. * instructions that reads s0.x and s1.x args should look like this:
  44. * args[0] = s0.x;
  45. * args[1] = s1.x;
  46. */
  47. LLVMValueRef args[12];
  48. /**
  49. * Number of arguments in the args array.
  50. */
  51. unsigned arg_count;
  52. /**
  53. * The type output type of the opcode. This should be set in the
  54. * lp_build_tgsi_action::fetch_args function.
  55. */
  56. LLVMTypeRef dst_type;
  57. /** This is used by the lp_build_tgsi_action::fetch_args function to
  58. * determine which channel to read from the opcode arguments. It also
  59. * specifies which index of the output array should be written to by
  60. * the lp_build_tgsi_action::emit function. However, this value is
  61. * usually ignored by any opcodes that are not TGSI_OUTPUT_COMPONENTWISE.
  62. */
  63. unsigned chan;
  64. /** The lp_build_tgsi_action::emit 'executes' the opcode and writes the
  65. * results to this array.
  66. */
  67. LLVMValueRef output[4];
  68. /**
  69. * The current instruction that is being 'executed'.
  70. */
  71. const struct tgsi_full_instruction * inst;
  72. const struct tgsi_opcode_info * info;
  73. };
  74. struct lp_build_tgsi_action
  75. {
  76. /**
  77. * This function is responsible for doing 2-3 things:
  78. * 1. Fetching the instruction arguments into the emit_data->args array.
  79. * 2. Setting the number of arguments in emit_data->arg_count.
  80. * 3. Setting the destination type in emit_data->dst_type (usually only
  81. * necessary for opcodes that are TGSI_OUTPUT_COMPONENTWISE).
  82. */
  83. void (*fetch_args)(struct lp_build_tgsi_context *,
  84. struct lp_build_emit_data *);
  85. /**
  86. * This function is responsible for emitting LLVM IR for a TGSI opcode.
  87. * It should store the values it generates in the emit_data->output array
  88. * and for TGSI_OUTPUT_COMPONENTWISE and TGSI_OUTPUT_REPLICATE instructions
  89. * (and possibly others depending on the specific implementation), it should
  90. * make sure to store the values in the array slot indexed by emit_data->chan.
  91. */
  92. void (*emit)(const struct lp_build_tgsi_action *,
  93. struct lp_build_tgsi_context *,
  94. struct lp_build_emit_data *);
  95. /**
  96. * This variable can be used to store an intrinsic name, in case the TGSI
  97. * opcode will be replaced by a target specific intrinsic. (There is a
  98. * convenience function in lp_bld_tgsi.c called lp_build_tgsi_intrinsic()
  99. * that can be assigned to lp_build_tgsi_action::emit and used for
  100. * generating intrinsics).
  101. */
  102. const char * intr_name;
  103. };
  104. /**
  105. * This function initializes the bld_base->op_actions array with some
  106. * generic operand actions.
  107. */
  108. void
  109. lp_set_default_actions(
  110. struct lp_build_tgsi_context * bld_base);
  111. /*
  112. * This function initialize the bld_base->op_actions array with some
  113. * operand actions that are intended only for use when generating
  114. * instructions to be executed on a CPU.
  115. */
  116. void
  117. lp_set_default_actions_cpu(
  118. struct lp_build_tgsi_context * bld_base);
  119. #endif /* LP_BLD_TGSI_ACTION_H */