PageRenderTime 21ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 41
 42#include "stdafx.h"
 43#include "CodeGenerator.h"
 44#include "Rasterizer.h"
 45#include "FunctionCache.h"
 46#include "Surface.h"
 47#include "Texture.h"
 48#include "codegen.h"
 49#include "instruction.h"
 50#include "emit.h"
 51#include "arm-dis.h"
 52
 53
 54using namespace EGL;
 55
 56
 57namespace {
 58
 59	inline cg_virtual_reg_t * LOAD_DATA(cg_block_t * block, cg_virtual_reg_t * base, I32 constant) {
 60		cg_virtual_reg_t * offset = cg_virtual_reg_create(block->proc, cg_reg_type_general);
 61		cg_virtual_reg_t * addr = cg_virtual_reg_create(block->proc, cg_reg_type_general);
 62		cg_virtual_reg_t * value = cg_virtual_reg_create(block->proc, cg_reg_type_general);
 63
 64		LDI(offset, constant);
 65		ADD(addr, base, offset);
 66		LDW(value, addr);
 67
 68		return value;
 69	}
 70
 71#define ALLOC_REG(reg) reg = cg_virtual_reg_create(procedure, cg_reg_type_general)
 72#define ALLOC_FLAGS(reg) reg = cg_virtual_reg_create(procedure, cg_reg_type_flags)
 73#define DECL_REG(reg) cg_virtual_reg_t * reg = cg_virtual_reg_create(procedure, cg_reg_type_general)
 74#define DECL_FLAGS(reg) cg_virtual_reg_t * reg = cg_virtual_reg_create(procedure, cg_reg_type_flags)
 75#define DECL_CONST_REG(reg, value) cg_virtual_reg_t * reg = cg_virtual_reg_create(procedure, cg_reg_type_general); LDI(reg, value)
 76
 77	U32 Log(U32 value) {
 78		U32 result = 0;
 79		U32 mask = 1;
 80
 81		while ((value & mask) != value) {
 82			++result;
 83			mask = (mask << 1) | 1;
 84		}
 85
 86		return result;
 87	}
 88}
 89
 90
 91
 92
 93void CodeGenerator :: GenerateRasterTriangle() {
 94
 95#if 0
 96	cg_proc_t * procedure = cg_proc_create(m_Module);
 97
 98	// The signature of the generated function is:
 99	//	(const RasterInfo * info, const EdgePos& start, const EdgePos& end);
100	// Do not pass in y coordinate but rather assume that raster info pointers have been
101	// adjusted to point to current scanline in memory
102	// In the edge buffers, z, tu and tv are actually divided by w
103
104	DECL_REG	(regInfo);		// virtual register containing info structure pointer
105	DECL_REG	(regStart);		// virtual register containing start edge buffer pointer
106	DECL_REG	(regEnd);		// virtual register containing end edge buffer pointer
107
108	procedure->num_args = 3;	// the previous three declarations make up the arguments
109
110	cg_block_t * block = cg_block_create(procedure, 1);
111
112	RET();
113
114# endif
115}
116