~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/nouveau/nv20_state_tex.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-08-23 15:37:30 UTC
  • mfrom: (1.7.6)
  • Revision ID: package-import@ubuntu.com-20120823153730-c499sefj7btu4386
Tags: 9.0~git20120821.c1114c61-0ubuntu1
* Merge from unreleased debian git.
  - Includes support for ATI Trinity PCI IDs (LP: #1009089)
* rules, control, libgl1-mesa-swx11*: Remove swx11 support.
* Refresh patches:
  - drop 115_llvm_dynamic_linking.diff,
    117_nullptr_check_in_query_version.patch, and
    118_glsl_initialize_samplers.patch, all upstream
  - disable 116_use_shared_galliumcore.diff until it's reviewed and
    reworked to apply
* not-installed, libegl1-mesa-drivers-install.linux.in: Updated to
  match the single-pass build.
* libgl1-mesa-dri.*install.in: Drop libglsl.so, it's included in
  libdricore.so now.
* rules: Don't disable GLU on the common flags, we need to build it
  on the dri target.
* libglu*install.in: Fix the source file paths to match the build target.
  Drop the static lib from -dev since only shared libs get built.
* libgl1-mesa-dev.install.in: Fix the source file paths to match the
  build target.
* libgl1-mesa-dri.install.linux.in: Don't try to install libgallium.so,
  which isn't built yet.
* rules: Enable llvmpipe on armhf to see if it works or not.
* rules: Remove bin/install-sh on clean, and don't create a symlink for
  it.
* control: Add Pre-Depends on dpkg-dev due to the binaries using xz
  compression.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "nv20_3d.xml.h"
32
32
#include "nouveau_util.h"
33
33
#include "nv20_driver.h"
 
34
#include "main/samplerobj.h"
34
35
 
35
36
void
36
37
nv20_emit_tex_gen(struct gl_context *ctx, int emit)
37
38
{
38
39
        const int i = emit - NOUVEAU_STATE_TEX_GEN0;
39
40
        struct nouveau_context *nctx = to_nouveau_context(ctx);
40
 
        struct nouveau_channel *chan = context_chan(ctx);
41
 
        struct nouveau_grobj *kelvin = context_eng3d(ctx);
 
41
        struct nouveau_pushbuf *push = context_push(ctx);
42
42
        struct gl_texture_unit *unit = &ctx->Texture.Unit[i];
43
43
        int j;
44
44
 
48
48
                        float *k = get_texgen_coeff(coord);
49
49
 
50
50
                        if (k) {
51
 
                                BEGIN_RING(chan, kelvin,
52
 
                                           NV20_3D_TEX_GEN_COEFF(i, j), 4);
53
 
                                OUT_RINGp(chan, k, 4);
 
51
                                BEGIN_NV04(push, NV20_3D(TEX_GEN_COEFF(i, j)), 4);
 
52
                                PUSH_DATAp(push, k, 4);
54
53
                        }
55
54
 
56
 
                        BEGIN_RING(chan, kelvin, NV20_3D_TEX_GEN_MODE(i, j), 1);
57
 
                        OUT_RING(chan, nvgl_texgen_mode(coord->Mode));
 
55
                        BEGIN_NV04(push, NV20_3D(TEX_GEN_MODE(i, j)), 1);
 
56
                        PUSH_DATA (push, nvgl_texgen_mode(coord->Mode));
58
57
 
59
58
                } else {
60
 
                        BEGIN_RING(chan, kelvin, NV20_3D_TEX_GEN_MODE(i, j), 1);
61
 
                        OUT_RING(chan, 0);
 
59
                        BEGIN_NV04(push, NV20_3D(TEX_GEN_MODE(i, j)), 1);
 
60
                        PUSH_DATA (push, 0);
62
61
                }
63
62
        }
64
63
}
68
67
{
69
68
        const int i = emit - NOUVEAU_STATE_TEX_MAT0;
70
69
        struct nouveau_context *nctx = to_nouveau_context(ctx);
71
 
        struct nouveau_channel *chan = context_chan(ctx);
72
 
        struct nouveau_grobj *kelvin = context_eng3d(ctx);
 
70
        struct nouveau_pushbuf *push = context_push(ctx);
73
71
 
74
72
        if (nctx->fallback == HWTNL &&
75
73
            (ctx->Texture._TexMatEnabled & 1 << i)) {
76
 
                BEGIN_RING(chan, kelvin, NV20_3D_TEX_MATRIX_ENABLE(i), 1);
77
 
                OUT_RING(chan, 1);
 
74
                BEGIN_NV04(push, NV20_3D(TEX_MATRIX_ENABLE(i)), 1);
 
75
                PUSH_DATA (push, 1);
78
76
 
79
 
                BEGIN_RING(chan, kelvin, NV20_3D_TEX_MATRIX(i,0), 16);
80
 
                OUT_RINGm(chan, ctx->TextureMatrixStack[i].Top->m);
 
77
                BEGIN_NV04(push, NV20_3D(TEX_MATRIX(i,0)), 16);
 
78
                PUSH_DATAm(push, ctx->TextureMatrixStack[i].Top->m);
81
79
 
82
80
        } else {
83
 
                BEGIN_RING(chan, kelvin, NV20_3D_TEX_MATRIX_ENABLE(i), 1);
84
 
                OUT_RING(chan, 0);
 
81
                BEGIN_NV04(push, NV20_3D(TEX_MATRIX_ENABLE(i)), 1);
 
82
                PUSH_DATA (push, 0);
85
83
        }
86
84
}
87
85
 
111
109
        case MESA_FORMAT_L8:
112
110
                return NV20_3D_TEX_FORMAT_FORMAT_L8;
113
111
 
 
112
        case MESA_FORMAT_RGB_DXT1:
 
113
        case MESA_FORMAT_RGBA_DXT1:
 
114
                return NV20_3D_TEX_FORMAT_FORMAT_DXT1;
 
115
 
 
116
        case MESA_FORMAT_RGBA_DXT3:
 
117
                return NV20_3D_TEX_FORMAT_FORMAT_DXT3;
 
118
 
 
119
        case MESA_FORMAT_RGBA_DXT5:
 
120
                return NV20_3D_TEX_FORMAT_FORMAT_DXT5;
 
121
 
114
122
        default:
115
123
                assert(0);
116
124
        }
151
159
nv20_emit_tex_obj(struct gl_context *ctx, int emit)
152
160
{
153
161
        const int i = emit - NOUVEAU_STATE_TEX_OBJ0;
154
 
        struct nouveau_channel *chan = context_chan(ctx);
155
 
        struct nouveau_grobj *kelvin = context_eng3d(ctx);
156
 
        struct nouveau_bo_context *bctx = context_bctx_i(ctx, TEXTURE, i);
 
162
        struct nouveau_pushbuf *push = context_push(ctx);
157
163
        const int bo_flags = NOUVEAU_BO_RD | NOUVEAU_BO_GART | NOUVEAU_BO_VRAM;
158
164
        struct gl_texture_object *t;
159
165
        struct nouveau_surface *s;
160
166
        struct gl_texture_image *ti;
 
167
        const struct gl_sampler_object *sa;
161
168
        uint32_t tx_format, tx_filter, tx_wrap, tx_enable;
162
169
 
 
170
        PUSH_RESET(push, BUFCTX_TEX(i));
 
171
 
163
172
        if (!ctx->Texture.Unit[i]._ReallyEnabled) {
164
 
                BEGIN_RING(chan, kelvin, NV20_3D_TEX_ENABLE(i), 1);
165
 
                OUT_RING(chan, 0);
 
173
                BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1);
 
174
                PUSH_DATA (push, 0);
166
175
 
167
176
                context_dirty(ctx, TEX_SHADER);
168
177
                return;
171
180
        t = ctx->Texture.Unit[i]._Current;
172
181
        s = &to_nouveau_texture(t)->surfaces[t->BaseLevel];
173
182
        ti = t->Image[0][t->BaseLevel];
 
183
        sa = _mesa_get_samplerobj(ctx, i);
174
184
 
175
185
        if (!nouveau_texture_validate(ctx, t))
176
186
                return;
183
193
                | NV20_3D_TEX_FORMAT_NO_BORDER
184
194
                | 1 << 16;
185
195
 
186
 
        tx_wrap = nvgl_wrap_mode(t->Sampler.WrapR) << 16
187
 
                | nvgl_wrap_mode(t->Sampler.WrapT) << 8
188
 
                | nvgl_wrap_mode(t->Sampler.WrapS) << 0;
 
196
        tx_wrap = nvgl_wrap_mode(sa->WrapR) << 16
 
197
                | nvgl_wrap_mode(sa->WrapT) << 8
 
198
                | nvgl_wrap_mode(sa->WrapS) << 0;
189
199
 
190
 
        tx_filter = nvgl_filter_mode(t->Sampler.MagFilter) << 24
191
 
                | nvgl_filter_mode(t->Sampler.MinFilter) << 16
 
200
        tx_filter = nvgl_filter_mode(sa->MagFilter) << 24
 
201
                | nvgl_filter_mode(sa->MinFilter) << 16
192
202
                | 2 << 12;
193
203
 
194
204
        tx_enable = NV20_3D_TEX_ENABLE_ENABLE
195
 
                | log2i(t->Sampler.MaxAnisotropy) << 4;
 
205
                | log2i(sa->MaxAnisotropy) << 4;
196
206
 
197
207
        if (t->Target == GL_TEXTURE_RECTANGLE) {
198
 
                BEGIN_RING(chan, kelvin, NV20_3D_TEX_NPOT_PITCH(i), 1);
199
 
                OUT_RING(chan, s->pitch << 16);
200
 
                BEGIN_RING(chan, kelvin, NV20_3D_TEX_NPOT_SIZE(i), 1);
201
 
                OUT_RING(chan, s->width << 16 | s->height);
 
208
                BEGIN_NV04(push, NV20_3D(TEX_NPOT_PITCH(i)), 1);
 
209
                PUSH_DATA (push, s->pitch << 16);
 
210
                BEGIN_NV04(push, NV20_3D(TEX_NPOT_SIZE(i)), 1);
 
211
                PUSH_DATA (push, s->width << 16 | s->height);
202
212
 
203
213
                tx_format |= get_tex_format_rect(ti);
204
214
        } else {
205
215
                tx_format |= get_tex_format_pot(ti);
206
216
        }
207
217
 
208
 
        if (t->Sampler.MinFilter != GL_NEAREST &&
209
 
            t->Sampler.MinFilter != GL_LINEAR) {
210
 
                int lod_min = t->Sampler.MinLod;
211
 
                int lod_max = MIN2(t->Sampler.MaxLod, t->_MaxLambda);
212
 
                int lod_bias = t->Sampler.LodBias
 
218
        if (sa->MinFilter != GL_NEAREST &&
 
219
            sa->MinFilter != GL_LINEAR) {
 
220
                int lod_min = sa->MinLod;
 
221
                int lod_max = MIN2(sa->MaxLod, t->_MaxLambda);
 
222
                int lod_bias = sa->LodBias
213
223
                        + ctx->Texture.Unit[i].LodBias;
214
224
 
215
225
                lod_max = CLAMP(lod_max, 0, 15);
223
233
        }
224
234
 
225
235
        /* Write it to the hardware. */
226
 
        nouveau_bo_mark(bctx, kelvin, NV20_3D_TEX_FORMAT(i),
227
 
                        s->bo, tx_format, 0,
228
 
                        NV20_3D_TEX_FORMAT_DMA0,
229
 
                        NV20_3D_TEX_FORMAT_DMA1,
230
 
                        bo_flags | NOUVEAU_BO_OR);
 
236
        BEGIN_NV04(push, NV20_3D(TEX_FORMAT(i)), 1);
 
237
        PUSH_MTHD (push, NV20_3D(TEX_FORMAT(i)), BUFCTX_TEX(i),
 
238
                         s->bo, tx_format, bo_flags | NOUVEAU_BO_OR,
 
239
                         NV20_3D_TEX_FORMAT_DMA0,
 
240
                         NV20_3D_TEX_FORMAT_DMA1);
231
241
 
232
 
        nouveau_bo_markl(bctx, kelvin, NV20_3D_TEX_OFFSET(i),
 
242
        BEGIN_NV04(push, NV20_3D(TEX_OFFSET(i)), 1);
 
243
        PUSH_MTHDl(push, NV20_3D(TEX_OFFSET(i)), BUFCTX_TEX(i),
233
244
                         s->bo, s->offset, bo_flags);
234
245
 
235
 
        BEGIN_RING(chan, kelvin, NV20_3D_TEX_WRAP(i), 1);
236
 
        OUT_RING(chan, tx_wrap);
237
 
 
238
 
        BEGIN_RING(chan, kelvin, NV20_3D_TEX_FILTER(i), 1);
239
 
        OUT_RING(chan, tx_filter);
240
 
 
241
 
        BEGIN_RING(chan, kelvin, NV20_3D_TEX_ENABLE(i), 1);
242
 
        OUT_RING(chan, tx_enable);
 
246
        BEGIN_NV04(push, NV20_3D(TEX_WRAP(i)), 1);
 
247
        PUSH_DATA (push, tx_wrap);
 
248
 
 
249
        BEGIN_NV04(push, NV20_3D(TEX_FILTER(i)), 1);
 
250
        PUSH_DATA (push, tx_filter);
 
251
 
 
252
        BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1);
 
253
        PUSH_DATA (push, tx_enable);
243
254
 
244
255
        context_dirty(ctx, TEX_SHADER);
245
256
}
247
258
void
248
259
nv20_emit_tex_shader(struct gl_context *ctx, int emit)
249
260
{
250
 
        struct nouveau_channel *chan = context_chan(ctx);
251
 
        struct nouveau_grobj *kelvin = context_eng3d(ctx);
 
261
        struct nouveau_pushbuf *push = context_push(ctx);
252
262
        uint32_t tx_shader_op = 0;
253
263
        int i;
254
264
 
259
269
                tx_shader_op |= NV20_3D_TEX_SHADER_OP_TX0_TEXTURE_2D << 5 * i;
260
270
        }
261
271
 
262
 
        BEGIN_RING(chan, kelvin, NV20_3D_TEX_SHADER_OP, 1);
263
 
        OUT_RING(chan, tx_shader_op);
 
272
        BEGIN_NV04(push, NV20_3D(TEX_SHADER_OP), 1);
 
273
        PUSH_DATA (push, tx_shader_op);
264
274
}