source: OGRE/trunk/ogrenew/RenderSystems/GL/src/nvparse/ts1.0_inst.h @ 692

Revision 692, 5.6 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1#ifndef _INST_H
2#define _INST_H
3
4#define TSP_MAX_ARGS 7
5#define TSP_NUM_TEXTURE_UNITS 4
6
7#ifdef _WIN32
8# define BYTE_ORDER !BIG_ENDIAN
9#endif
10#include <stdlib.h> 
11
12typedef union _InstructionEnum {
13  struct {
14#if BYTE_ORDER != BIG_ENDIAN
15    unsigned int instruction   :10; // instruction id
16    unsigned int stage         : 4; // stage number
17    unsigned int dependent     : 1; // dependent operation
18    unsigned int noOutput      : 1; // no RGBA output
19#else
20    unsigned int noOutput      : 1;
21    unsigned int dependent     : 1;
22    unsigned int stage         : 4;
23    unsigned int instruction   :10;
24#endif
25  } bits;
26  unsigned int word;
27} InstructionEnum;
28
29// WARNING:  Don't monkey with the above structure or this macro
30// unless you're absolutely sure of what you're doing!
31// This constant allocation makes validation *much* cleaner.
32#define TSP_SET_INSTRUCTION_ENUM(inst, st, dep, noout) \
33         ((noout << 15) | (dep << 14) | (st << 10) | inst)
34
35#define TSP_NOP                                 TSP_SET_INSTRUCTION_ENUM(0, 0, 0, 1)
36#define TSP_TEXTURE_1D                  TSP_SET_INSTRUCTION_ENUM(1, 0, 0, 0)
37#define TSP_TEXTURE_2D                  TSP_SET_INSTRUCTION_ENUM(2, 0, 0, 0)
38#define TSP_TEXTURE_RECTANGLE   TSP_SET_INSTRUCTION_ENUM(3, 0, 0, 0)
39#define TSP_TEXTURE_3D                  TSP_SET_INSTRUCTION_ENUM(4, 0, 0, 0)
40#define TSP_TEXTURE_CUBE_MAP    TSP_SET_INSTRUCTION_ENUM(5, 0, 0, 0)
41#define TSP_CULL_FRAGMENT               TSP_SET_INSTRUCTION_ENUM(6, 0, 0, 1)
42#define TSP_PASS_THROUGH                TSP_SET_INSTRUCTION_ENUM(7, 0, 0, 0)
43#define TSP_DEPENDENT_AR                TSP_SET_INSTRUCTION_ENUM(8, 0, 1, 0)
44#define TSP_DEPENDENT_GB                TSP_SET_INSTRUCTION_ENUM(9, 0, 1, 0)
45#define TSP_OFFSET_2D                   TSP_SET_INSTRUCTION_ENUM(10, 0, 1, 0)
46#define TSP_OFFSET_2D_SCALE             TSP_SET_INSTRUCTION_ENUM(11, 0, 1, 0)
47#define TSP_OFFSET_RECTANGLE                    TSP_SET_INSTRUCTION_ENUM(12, 0, 1, 0)
48#define TSP_OFFSET_RECTANGLE_SCALE              TSP_SET_INSTRUCTION_ENUM(13, 0, 1, 0)
49
50#define TSP_DOT_PRODUCT_2D_1_OF_2                               TSP_SET_INSTRUCTION_ENUM(14, 0, 1, 1)
51#define TSP_DOT_PRODUCT_2D_2_OF_2                               TSP_SET_INSTRUCTION_ENUM(14, 1, 1, 0)
52
53#define TSP_DOT_PRODUCT_RECTANGLE_1_OF_2                                TSP_SET_INSTRUCTION_ENUM(15, 0, 1, 1)
54#define TSP_DOT_PRODUCT_RECTANGLE_2_OF_2                                TSP_SET_INSTRUCTION_ENUM(15, 1, 1, 0)
55
56#define TSP_DOT_PRODUCT_DEPTH_REPLACE_1_OF_2    TSP_SET_INSTRUCTION_ENUM(16, 0, 1, 1)
57#define TSP_DOT_PRODUCT_DEPTH_REPLACE_2_OF_2    TSP_SET_INSTRUCTION_ENUM(16, 1, 1, 0)
58
59#define TSP_DOT_PRODUCT_3D_1_OF_3               TSP_SET_INSTRUCTION_ENUM(17, 0, 1, 1)
60#define TSP_DOT_PRODUCT_3D_2_OF_3               TSP_SET_INSTRUCTION_ENUM(17, 1, 1, 1)
61#define TSP_DOT_PRODUCT_3D_3_OF_3               TSP_SET_INSTRUCTION_ENUM(17, 2, 1, 0)
62
63#define TSP_DOT_PRODUCT_CUBE_MAP_1_OF_3 TSP_SET_INSTRUCTION_ENUM(18, 0, 1, 1)
64#define TSP_DOT_PRODUCT_CUBE_MAP_2_OF_3 TSP_SET_INSTRUCTION_ENUM(18, 1, 1, 1)
65#define TSP_DOT_PRODUCT_CUBE_MAP_3_OF_3 TSP_SET_INSTRUCTION_ENUM(18, 2, 1, 0)
66
67#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_1_OF_3     TSP_SET_INSTRUCTION_ENUM(19, 0, 1, 1)
68#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_2_OF_3     TSP_SET_INSTRUCTION_ENUM(19, 1, 1, 1)
69#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_3_OF_3     TSP_SET_INSTRUCTION_ENUM(19, 2, 1, 0)
70
71#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_1_OF_3       TSP_SET_INSTRUCTION_ENUM(20, 0, 1, 1)
72#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_2_OF_3       TSP_SET_INSTRUCTION_ENUM(20, 1, 1, 1)
73#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_3_OF_3       TSP_SET_INSTRUCTION_ENUM(20, 2, 1, 0)
74
75#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_1_OF_3        TSP_SET_INSTRUCTION_ENUM(21, 0, 1, 1)
76#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_2_OF_3        TSP_SET_INSTRUCTION_ENUM(21, 1, 1, 0)
77#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_3_OF_3        TSP_SET_INSTRUCTION_ENUM(21, 2, 1, 0)
78
79#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_1_OF_3          TSP_SET_INSTRUCTION_ENUM(22, 0, 1, 1)
80#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_2_OF_3          TSP_SET_INSTRUCTION_ENUM(22, 1, 1, 0)
81#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_3_OF_3          TSP_SET_INSTRUCTION_ENUM(22, 2, 1, 0)
82
83typedef struct _MappedVariable {
84        float var;
85        int expand;
86} MappedVariable, *MappedVariablePtr;
87
88typedef class Inst {
89public:
90        Inst(int inst, float arg0 = 0., float arg1 = 0., float arg2 = 0., float arg3 = 0., float arg4 = 0., float arg5 = 0., float arg6 = 0.);
91        Inst(int inst, MappedVariablePtr arg0, float arg1 = 0., float arg2 = 0., float arg3 = 0., float arg4 = 0., float arg5 = 0., float arg6 = 0.);
92        void Invoke();
93        InstructionEnum opcode;
94        float args[TSP_MAX_ARGS];
95private:
96        int expand;
97} *InstPtr;
98
99#ifdef TEST_BIT_FIELDS
100
101#include <stdio.h>
102
103class InstructionEnumTest {
104  public:
105    InstructionEnumTest()
106    {
107      InstructionEnum inst;
108      bool error = false;
109
110      if (sizeof(inst.bits) != sizeof(inst.word))
111        error = true;
112
113      inst.word = 0; inst.bits.instruction = 0x3FF;
114      if (TSP_SET_INSTRUCTION_ENUM(0x3FF, 0, 0, 0) != inst.word)
115        error = true;
116
117      inst.word = 0; inst.bits.stage = 0x0F;
118      if (TSP_SET_INSTRUCTION_ENUM(0, 0x0F, 0, 0) != inst.word)
119        error = true;
120
121      inst.word = 0; inst.bits.dependent = true;
122      if (TSP_SET_INSTRUCTION_ENUM(0, 0, 1, 0) != inst.word)
123        error = true;
124
125      inst.word = 0; inst.bits.noOutput = true;
126      if (TSP_SET_INSTRUCTION_ENUM(0, 0, 0, 1) != inst.word)
127        error = true;
128
129      if (error) {
130        fprintf(stderr, "ERROR: Bit Fields were not compiled correctly in " __FILE__ "!\n");
131        exit(1);
132      }
133    }
134};
135
136static InstructionEnumTest instructionEnumTest;
137
138#endif /* TEST_BIT_FIELDS */
139
140#endif
Note: See TracBrowser for help on using the repository browser.