⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.h

📁 Ray tracing on PS3, using the acceleration of PPU, No SPE acceleration is used. The code must be com
💻 H
字号:
/* Copyright (c) 2007 Massachusetts Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *//** * common.h - blue-steel common definitions file * @author Brian Sweatt * @author Russel Ryan *  * Contains definitions for SPU opcodes, the total number of SPUs in the system, DMA tags for data, and the image size * Additionally, contains contains the number of bounces for recursive rays, and flags to turn shading * and shadows on/off */#ifndef _COMMON_H_#define _COMMON_H_extern unsigned int NUM_RENDERING_SPES;#define TOTAL_SPES 6// The opcodes used for dispatching SPEs for work on a task// Many have been deprecated, and haven't been removed for compatability reasons// This will be remedied in future releases#define NUM_OPCODES 20#define SPE_NOP 0#define SPE_READ_SCENE 1#define SPE_RENDER_REGION 2#define SPE_UPDATE_CAMERA 3#define SPE_UPDATE_CAMERA_POS 4#define SPE_UPDATE_BALL1 5#define SPE_SPLAT_RGB 6#define SPE_SPLAT_REGION 7#define SPE_ADD_SPHERE 8#define SPE_ADD_TRIANGLE 9#define SPE_ADD_PLANE 10#define SPE_SET_NUM_SPHERES 11#define SPE_SET_NUM_TRIANGLES 12#define SPE_SET_NUM_PLANES 13#define SPE_TRANSLATE_SPHERE 14#define SPE_SET_NUM_SPES 15#define SPE_INIT_RAYTRACER 16#define SPE_UPDATE_CAMERA_DIR 17#define SPE_LOOK_AT 18#define SPE_SET_AMBIENT 19#define DMA_TAG_OBJECTSET 6#define DMA_TAG_SPHERES 7#define DMA_TAG_TRIANGLES 8#define DMA_TAG_PLANES 9#define DMA_TAG_CYLINDERS 10#define DMA_TAG_BOXES 11#define DMA_TAG_LIGHTS 12#define DMA_TAG_MATERIALS 13#define IMG_WIDTH 420#define IMG_HEIGHT 420#define STRIP_WIDTH 105  //NOTE: STRIP_WIDTH MUST MUST MUST be IMG_WIDTH/4!!!!!!#define STRIP_HEIGHT 1#define MAX_BOUNCES 2// #define SHADOWS 0 or SHADING 0 to turn off shadows and shading, respectively#define SHADOWS 1#define SHADING 1// #define FRAME_BUFFER 1 if using the FRAME_BUFFER. Otherwise #define FRAME_BUFFER 0#define FRAME_BUFFER 1// Since multiplying a number by the actual value of FLT_MAX from float.h yields undesired behavior, we define// a sufficiently large FLT_MAX for our purposes#define MAX_FLOAT ((float)99999999.0f)//#define DEBUG#ifdef DEBUG#define dprintf(...) printf(__VA_ARGS__)#else#define dprintf(...) #endif#define PRINTF_VECTOR_FLOAT(s, v) printf("%s, %f, %f, %f, %f\r\n", s, spu_extract(v,0), spu_extract(v,1), spu_extract(v,2), spu_extract(v,3));#define PRINTF_VECTOR_INT(s, v) printf("%s, %u, %u, %u, %u\r\n", s, spu_extract(v,0), spu_extract(v,1), spu_extract(v,2), spu_extract(v,3));#ifdef DEBUG#define PRINT_VECTOR_FLOAT(s, v) printf("%s, %f, %f, %f, %f\r\n", s, spu_extract(v,0), spu_extract(v,1), spu_extract(v,2), spu_extract(v,3));#define PRINT_VECTOR_INT(s, v) printf("%s, %u, %u, %u, %u\r\n", s, spu_extract(v,0), spu_extract(v,1), spu_extract(v,2), spu_extract(v,3));#else#define PRINT_VECTOR_FLOAT(s, v)#define PRINT_VECTOR_INT(s, v)#endiftypedef unsigned int uint32_t;struct CameraControl {  vector float c,d,u;  float a;};/** * Used to trick the mailbox system into sending floats as uint32_t's */inline uint32_t float_as_uint32(float f) {  union {    float f;    uint32_t u;  } haha;  haha.f = f;  return haha.u;}/** * Used to trick the mailbox system into receiving floats as uint32_t's */inline float uint32_as_float(uint32_t u) {  union {    float f;    uint32_t u;  } haha;  haha.u=u;  return haha.f;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -