~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/r300/compiler/r300_fragprog.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
#include "../r300_reg.h"
33
33
 
34
 
static struct rc_src_register shadow_ambient(struct radeon_compiler * c, int tmu)
35
 
{
36
 
        struct rc_src_register reg = { 0, };
37
 
 
38
 
        reg.File = RC_FILE_CONSTANT;
39
 
        reg.Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_SHADOW_AMBIENT, tmu);
40
 
        reg.Swizzle = RC_SWIZZLE_WWWW;
41
 
        return reg;
42
 
}
43
 
 
44
 
/**
45
 
 * Transform TEX, TXP, TXB, and KIL instructions in the following way:
46
 
 *  - premultiply texture coordinates for RECT
47
 
 *  - extract operand swizzles
48
 
 *  - introduce a temporary register when write masks are needed
49
 
 */
50
 
int r300_transform_TEX(
51
 
        struct radeon_compiler * c,
52
 
        struct rc_instruction* inst,
53
 
        void* data)
54
 
{
55
 
        struct r300_fragment_program_compiler *compiler =
56
 
                (struct r300_fragment_program_compiler*)data;
57
 
 
58
 
        if (inst->U.I.Opcode != RC_OPCODE_TEX &&
59
 
            inst->U.I.Opcode != RC_OPCODE_TXB &&
60
 
            inst->U.I.Opcode != RC_OPCODE_TXP &&
61
 
            inst->U.I.Opcode != RC_OPCODE_KIL)
62
 
                return 0;
63
 
 
64
 
        /* ARB_shadow & EXT_shadow_funcs */
65
 
        if (inst->U.I.Opcode != RC_OPCODE_KIL &&
66
 
            c->Program.ShadowSamplers & (1 << inst->U.I.TexSrcUnit)) {
67
 
                rc_compare_func comparefunc = compiler->state.unit[inst->U.I.TexSrcUnit].texture_compare_func;
68
 
 
69
 
                if (comparefunc == RC_COMPARE_FUNC_NEVER || comparefunc == RC_COMPARE_FUNC_ALWAYS) {
70
 
                        inst->U.I.Opcode = RC_OPCODE_MOV;
71
 
 
72
 
                        if (comparefunc == RC_COMPARE_FUNC_ALWAYS) {
73
 
                                inst->U.I.SrcReg[0].File = RC_FILE_NONE;
74
 
                                inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_1111;
75
 
                        } else {
76
 
                                inst->U.I.SrcReg[0] = shadow_ambient(c, inst->U.I.TexSrcUnit);
77
 
                        }
78
 
 
79
 
                        return 1;
80
 
                } else {
81
 
                        rc_compare_func comparefunc = compiler->state.unit[inst->U.I.TexSrcUnit].texture_compare_func;
82
 
                        unsigned int depthmode = compiler->state.unit[inst->U.I.TexSrcUnit].depth_texture_mode;
83
 
                        struct rc_instruction * inst_rcp = rc_insert_new_instruction(c, inst);
84
 
                        struct rc_instruction * inst_mad = rc_insert_new_instruction(c, inst_rcp);
85
 
                        struct rc_instruction * inst_cmp = rc_insert_new_instruction(c, inst_mad);
86
 
                        int pass, fail;
87
 
 
88
 
                        inst_rcp->U.I.Opcode = RC_OPCODE_RCP;
89
 
                        inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY;
90
 
                        inst_rcp->U.I.DstReg.Index = rc_find_free_temporary(c);
91
 
                        inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
92
 
                        inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
93
 
                        inst_rcp->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW;
94
 
 
95
 
                        inst_cmp->U.I.DstReg = inst->U.I.DstReg;
96
 
                        inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
97
 
                        inst->U.I.DstReg.Index = rc_find_free_temporary(c);
98
 
                        inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
99
 
 
100
 
                        inst_mad->U.I.Opcode = RC_OPCODE_MAD;
101
 
                        inst_mad->U.I.DstReg.File = RC_FILE_TEMPORARY;
102
 
                        inst_mad->U.I.DstReg.Index = rc_find_free_temporary(c);
103
 
                        inst_mad->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
104
 
                        inst_mad->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_ZZZZ;
105
 
                        inst_mad->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
106
 
                        inst_mad->U.I.SrcReg[1].Index = inst_rcp->U.I.DstReg.Index;
107
 
                        inst_mad->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
108
 
                        inst_mad->U.I.SrcReg[2].File = RC_FILE_TEMPORARY;
109
 
                        inst_mad->U.I.SrcReg[2].Index = inst->U.I.DstReg.Index;
110
 
                        if (depthmode == 0) /* GL_LUMINANCE */
111
 
                                inst_mad->U.I.SrcReg[2].Swizzle = RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_Z);
112
 
                        else if (depthmode == 2) /* GL_ALPHA */
113
 
                                inst_mad->U.I.SrcReg[2].Swizzle = RC_SWIZZLE_WWWW;
114
 
 
115
 
                        /* Recall that SrcReg[0] is tex, SrcReg[2] is r and:
116
 
                         *   r  < tex  <=>      -tex+r < 0
117
 
                         *   r >= tex  <=> not (-tex+r < 0 */
118
 
                        if (comparefunc == RC_COMPARE_FUNC_LESS || comparefunc == RC_COMPARE_FUNC_GEQUAL)
119
 
                                inst_mad->U.I.SrcReg[2].Negate = inst_mad->U.I.SrcReg[2].Negate ^ RC_MASK_XYZW;
120
 
                        else
121
 
                                inst_mad->U.I.SrcReg[0].Negate = inst_mad->U.I.SrcReg[0].Negate ^ RC_MASK_XYZW;
122
 
 
123
 
                        inst_cmp->U.I.Opcode = RC_OPCODE_CMP;
124
 
                        /* DstReg has been filled out above */
125
 
                        inst_cmp->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
126
 
                        inst_cmp->U.I.SrcReg[0].Index = inst_mad->U.I.DstReg.Index;
127
 
 
128
 
                        if (comparefunc == RC_COMPARE_FUNC_LESS || comparefunc == RC_COMPARE_FUNC_GREATER) {
129
 
                                pass = 1;
130
 
                                fail = 2;
131
 
                        } else {
132
 
                                pass = 2;
133
 
                                fail = 1;
134
 
                        }
135
 
 
136
 
                        inst_cmp->U.I.SrcReg[pass].File = RC_FILE_NONE;
137
 
                        inst_cmp->U.I.SrcReg[pass].Swizzle = RC_SWIZZLE_1111;
138
 
                        inst_cmp->U.I.SrcReg[fail] = shadow_ambient(c, inst->U.I.TexSrcUnit);
139
 
                }
140
 
        }
141
 
 
142
 
        /* Hardware uses [0..1]x[0..1] range for rectangle textures
143
 
         * instead of [0..Width]x[0..Height].
144
 
         * Add a scaling instruction.
145
 
         */
146
 
        if (inst->U.I.Opcode != RC_OPCODE_KIL && inst->U.I.TexSrcTarget == RC_TEXTURE_RECT) {
147
 
                struct rc_instruction * inst_mul = rc_insert_new_instruction(c, inst->Prev);
148
 
 
149
 
                inst_mul->U.I.Opcode = RC_OPCODE_MUL;
150
 
                inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
151
 
                inst_mul->U.I.DstReg.Index = rc_find_free_temporary(c);
152
 
                inst_mul->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
153
 
                inst_mul->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
154
 
                inst_mul->U.I.SrcReg[1].Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_R300_TEXRECT_FACTOR, inst->U.I.TexSrcUnit);
155
 
 
156
 
                reset_srcreg(&inst->U.I.SrcReg[0]);
157
 
                inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
158
 
                inst->U.I.SrcReg[0].Index = inst_mul->U.I.DstReg.Index;
159
 
        }
160
 
 
161
 
        /* Cannot write texture to output registers or with masks */
162
 
        if (inst->U.I.Opcode != RC_OPCODE_KIL &&
163
 
            (inst->U.I.DstReg.File != RC_FILE_TEMPORARY || inst->U.I.DstReg.WriteMask != RC_MASK_XYZW)) {
164
 
                struct rc_instruction * inst_mov = rc_insert_new_instruction(c, inst);
165
 
 
166
 
                inst_mov->U.I.Opcode = RC_OPCODE_MOV;
167
 
                inst_mov->U.I.DstReg = inst->U.I.DstReg;
168
 
                inst_mov->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
169
 
                inst_mov->U.I.SrcReg[0].Index = rc_find_free_temporary(c);
170
 
 
171
 
                inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
172
 
                inst->U.I.DstReg.Index = inst_mov->U.I.SrcReg[0].Index;
173
 
                inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
174
 
        }
175
 
 
176
 
 
177
 
        /* Cannot read texture coordinate from constants file */
178
 
        if (inst->U.I.SrcReg[0].File != RC_FILE_TEMPORARY && inst->U.I.SrcReg[0].File != RC_FILE_INPUT) {
179
 
                struct rc_instruction * inst_mov = rc_insert_new_instruction(c, inst->Prev);
180
 
 
181
 
                inst_mov->U.I.Opcode = RC_OPCODE_MOV;
182
 
                inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
183
 
                inst_mov->U.I.DstReg.Index = rc_find_free_temporary(c);
184
 
                inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
185
 
 
186
 
                reset_srcreg(&inst->U.I.SrcReg[0]);
187
 
                inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
188
 
                inst->U.I.SrcReg[0].Index = inst_mov->U.I.DstReg.Index;
189
 
        }
190
 
 
191
 
        return 1;
192
 
}
193
 
 
194
34
/* just some random things... */
195
 
void r300FragmentProgramDump(struct rX00_fragment_program_code *c)
 
35
void r300FragmentProgramDump(struct radeon_compiler *c, void *user)
196
36
{
197
 
        struct r300_fragment_program_code *code = &c->code.r300;
 
37
        struct r300_fragment_program_compiler *compiler = (struct r300_fragment_program_compiler*)c;
 
38
        struct r300_fragment_program_code *code = &compiler->code->code.r300;
198
39
        int n, i, j;
199
40
        static int pc = 0;
200
41