/opengles/src/arm/GenTriangle.cpp

http://ftk.googlecode.com/ · C++ · 116 lines · 47 code · 25 blank · 44 comment · 2 complexity · 3a6464b6d33b44da4e88de182679a897 MD5 · raw file

  1. // ==========================================================================
  2. //
  3. // GenTriangle.cpp JIT Class for 3D Rendering Library
  4. //
  5. // This file contains the rasterizer functions that
  6. // implement the runtime code generation support
  7. // for optimized scan line rasterization routines.
  8. //
  9. // --------------------------------------------------------------------------
  10. //
  11. // 12-29-2003 Hans-Martin Will initial version
  12. //
  13. // --------------------------------------------------------------------------
  14. //
  15. // Copyright (c) 2004, Hans-Martin Will. All rights reserved.
  16. //
  17. // Redistribution and use in source and binary forms, with or without
  18. // modification, are permitted provided that the following conditions are
  19. // met:
  20. //
  21. // * Redistributions of source code must retain the above copyright
  22. // notice, this list of conditions and the following disclaimer.
  23. // * Redistributions in binary form must reproduce the above copyright
  24. // notice, this list of conditions and the following disclaimer in the
  25. // documentation and/or other materials provided with the distribution.
  26. //
  27. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  28. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  31. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  32. // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  33. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  35. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  36. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  37. // THE POSSIBILITY OF SUCH DAMAGE.
  38. //
  39. // ==========================================================================
  40. #include "stdafx.h"
  41. #include "CodeGenerator.h"
  42. #include "Rasterizer.h"
  43. #include "FunctionCache.h"
  44. #include "Surface.h"
  45. #include "Texture.h"
  46. #include "codegen.h"
  47. #include "instruction.h"
  48. #include "emit.h"
  49. #include "arm-dis.h"
  50. using namespace EGL;
  51. namespace {
  52. inline cg_virtual_reg_t * LOAD_DATA(cg_block_t * block, cg_virtual_reg_t * base, I32 constant) {
  53. cg_virtual_reg_t * offset = cg_virtual_reg_create(block->proc, cg_reg_type_general);
  54. cg_virtual_reg_t * addr = cg_virtual_reg_create(block->proc, cg_reg_type_general);
  55. cg_virtual_reg_t * value = cg_virtual_reg_create(block->proc, cg_reg_type_general);
  56. LDI(offset, constant);
  57. ADD(addr, base, offset);
  58. LDW(value, addr);
  59. return value;
  60. }
  61. #define ALLOC_REG(reg) reg = cg_virtual_reg_create(procedure, cg_reg_type_general)
  62. #define ALLOC_FLAGS(reg) reg = cg_virtual_reg_create(procedure, cg_reg_type_flags)
  63. #define DECL_REG(reg) cg_virtual_reg_t * reg = cg_virtual_reg_create(procedure, cg_reg_type_general)
  64. #define DECL_FLAGS(reg) cg_virtual_reg_t * reg = cg_virtual_reg_create(procedure, cg_reg_type_flags)
  65. #define DECL_CONST_REG(reg, value) cg_virtual_reg_t * reg = cg_virtual_reg_create(procedure, cg_reg_type_general); LDI(reg, value)
  66. U32 Log(U32 value) {
  67. U32 result = 0;
  68. U32 mask = 1;
  69. while ((value & mask) != value) {
  70. ++result;
  71. mask = (mask << 1) | 1;
  72. }
  73. return result;
  74. }
  75. }
  76. void CodeGenerator :: GenerateRasterTriangle() {
  77. #if 0
  78. cg_proc_t * procedure = cg_proc_create(m_Module);
  79. // The signature of the generated function is:
  80. // (const RasterInfo * info, const EdgePos& start, const EdgePos& end);
  81. // Do not pass in y coordinate but rather assume that raster info pointers have been
  82. // adjusted to point to current scanline in memory
  83. // In the edge buffers, z, tu and tv are actually divided by w
  84. DECL_REG (regInfo); // virtual register containing info structure pointer
  85. DECL_REG (regStart); // virtual register containing start edge buffer pointer
  86. DECL_REG (regEnd); // virtual register containing end edge buffer pointer
  87. procedure->num_args = 3; // the previous three declarations make up the arguments
  88. cg_block_t * block = cg_block_create(procedure, 1);
  89. RET();
  90. # endif
  91. }