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

« back to all changes in this revision

Viewing changes to src/gallium/drivers/nvfx/nv40_fragtex.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:
1
 
#include "util/u_format.h"
2
 
#include "nvfx_context.h"
3
 
#include "nvfx_tex.h"
4
 
#include "nvfx_resource.h"
5
 
 
6
 
void
7
 
nv40_sampler_state_init(struct pipe_context *pipe,
8
 
                          struct nvfx_sampler_state *ps,
9
 
                          const struct pipe_sampler_state *cso)
10
 
{
11
 
        if (cso->max_anisotropy >= 2) {
12
 
                /* no idea, binary driver sets it, works without it.. meh.. */
13
 
                ps->wrap |= (1 << 5);
14
 
 
15
 
                if (cso->max_anisotropy >= 16)
16
 
                        ps->en |= NV40_3D_TEX_ENABLE_ANISO_16X;
17
 
                else if (cso->max_anisotropy >= 12)
18
 
                        ps->en |= NV40_3D_TEX_ENABLE_ANISO_12X;
19
 
                else if (cso->max_anisotropy >= 10)
20
 
                        ps->en |= NV40_3D_TEX_ENABLE_ANISO_10X;
21
 
                else if (cso->max_anisotropy >= 8)
22
 
                        ps->en |= NV40_3D_TEX_ENABLE_ANISO_8X;
23
 
                else if (cso->max_anisotropy >= 6)
24
 
                        ps->en |= NV40_3D_TEX_ENABLE_ANISO_6X;
25
 
                else if (cso->max_anisotropy >= 4)
26
 
                        ps->en |= NV40_3D_TEX_ENABLE_ANISO_4X;
27
 
                else
28
 
                        ps->en |= NV40_3D_TEX_ENABLE_ANISO_2X;
29
 
        }
30
 
 
31
 
        ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
32
 
 
33
 
        ps->max_lod = (int)(CLAMP(cso->max_lod, 0.0, 15.0 + (255.0 / 256.0)) * 256.0);
34
 
        ps->min_lod = (int)(CLAMP(cso->min_lod, 0.0, 15.0 + (255.0 / 256.0)) * 256.0);
35
 
 
36
 
        ps->en |= NV40_3D_TEX_ENABLE_ENABLE;
37
 
}
38
 
 
39
 
void
40
 
nv40_sampler_view_init(struct pipe_context *pipe,
41
 
                          struct nvfx_sampler_view *sv)
42
 
{
43
 
        struct pipe_resource* pt = sv->base.texture;
44
 
        struct nvfx_miptree* mt = (struct nvfx_miptree*)pt;
45
 
        struct nvfx_texture_format *tf = &nvfx_texture_formats[sv->base.format];
46
 
        unsigned txf;
47
 
        unsigned level = pt->target == PIPE_TEXTURE_CUBE ? 0 : sv->base.u.tex.first_level;
48
 
        assert(tf->fmt[4] >= 0);
49
 
 
50
 
        txf = sv->u.init_fmt;
51
 
        txf |= 0x8000;
52
 
        if(pt->target == PIPE_TEXTURE_CUBE)
53
 
                txf |= ((pt->last_level + 1) << NV40_3D_TEX_FORMAT_MIPMAP_COUNT__SHIFT);
54
 
        else
55
 
                txf |= (((sv->base.u.tex.last_level - sv->base.u.tex.first_level) + 1) << NV40_3D_TEX_FORMAT_MIPMAP_COUNT__SHIFT);
56
 
 
57
 
        if (!mt->linear_pitch)
58
 
                sv->u.nv40.npot_size2 = 0;
59
 
        else {
60
 
                sv->u.nv40.npot_size2  = mt->linear_pitch;
61
 
                txf |= NV40_3D_TEX_FORMAT_LINEAR;
62
 
        }
63
 
 
64
 
        sv->u.nv40.fmt[0] = tf->fmt[4] | txf;
65
 
        sv->u.nv40.fmt[1] = tf->fmt[5] | txf;
66
 
 
67
 
        sv->u.nv40.npot_size2 |= (u_minify(pt->depth0, level) << NV40_3D_TEX_SIZE1_DEPTH__SHIFT);
68
 
 
69
 
        sv->lod_offset = (sv->base.u.tex.first_level - level) * 256;
70
 
        sv->max_lod_limit = (sv->base.u.tex.last_level - level) * 256;
71
 
}
72
 
 
73
 
void
74
 
nv40_fragtex_set(struct nvfx_context *nvfx, int unit)
75
 
{
76
 
        struct nouveau_channel* chan = nvfx->screen->base.channel;
77
 
        struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
78
 
        struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
79
 
        struct nvfx_sampler_view* sv = (struct nvfx_sampler_view*)nvfx->fragment_sampler_views[unit];
80
 
        struct nouveau_bo *bo = ((struct nvfx_miptree *)sv->base.texture)->base.bo;
81
 
        unsigned tex_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
82
 
        unsigned txf;
83
 
        unsigned max_lod = MIN2(ps->max_lod + sv->lod_offset, sv->max_lod_limit);
84
 
        unsigned min_lod = MIN2(ps->min_lod + sv->lod_offset, max_lod);
85
 
 
86
 
        txf = sv->u.nv40.fmt[ps->compare] | ps->fmt;
87
 
 
88
 
        MARK_RING(chan, 11, 2);
89
 
        BEGIN_RING(chan, eng3d, NV30_3D_TEX_OFFSET(unit), 8);
90
 
        OUT_RELOC(chan, bo, sv->offset, tex_flags | NOUVEAU_BO_LOW, 0, 0);
91
 
        OUT_RELOC(chan, bo, txf, tex_flags | NOUVEAU_BO_OR,
92
 
                        NV30_3D_TEX_FORMAT_DMA0, NV30_3D_TEX_FORMAT_DMA1);
93
 
        OUT_RING(chan, (ps->wrap & sv->wrap_mask) | sv->wrap);
94
 
        OUT_RING(chan, ps->en | (min_lod << 19) | (max_lod << 7));
95
 
        OUT_RING(chan, sv->swizzle);
96
 
        OUT_RING(chan, ps->filt | sv->filt);
97
 
        OUT_RING(chan, sv->npot_size);
98
 
        OUT_RING(chan, ps->bcol);
99
 
        BEGIN_RING(chan, eng3d, NV40_3D_TEX_SIZE1(unit), 1);
100
 
        OUT_RING(chan, sv->u.nv40.npot_size2);
101
 
 
102
 
        nvfx->hw_txf[unit] = txf;
103
 
        nvfx->hw_samplers |= (1 << unit);
104
 
}