2 * Copyright 2012 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include "util/u_inlines.h"
27 #include "nv30/nv30_context.h"
30 nv40_verttex_validate(struct nv30_context
*nv30
)
32 struct nouveau_pushbuf
*push
= nv30
->base
.pushbuf
;
33 unsigned dirty
= nv30
->vertprog
.dirty_samplers
;
36 unsigned unit
= ffs(dirty
) - 1;
37 struct nv30_sampler_view
*sv
= (void *)nv30
->fragprog
.textures
[unit
];
38 struct nv30_sampler_state
*ss
= nv30
->fragprog
.samplers
[unit
];
42 BEGIN_NV04(push
, NV40_3D(VTXTEX_ENABLE(unit
)), 1);
47 nv30
->vertprog
.dirty_samplers
= 0;
51 nv40_verttex_sampler_states_bind(struct pipe_context
*pipe
,
52 unsigned nr
, void **hwcso
)
54 struct nv30_context
*nv30
= nv30_context(pipe
);
57 for (i
= 0; i
< nr
; i
++) {
58 nv30
->vertprog
.samplers
[i
] = hwcso
[i
];
59 nv30
->vertprog
.dirty_samplers
|= (1 << i
);
62 for (; i
< nv30
->vertprog
.num_samplers
; i
++) {
63 nv30
->vertprog
.samplers
[i
] = NULL
;
64 nv30
->vertprog
.dirty_samplers
|= (1 << i
);
67 nv30
->vertprog
.num_samplers
= nr
;
68 nv30
->dirty
|= NV30_NEW_VERTTEX
;
73 nv40_verttex_set_sampler_views(struct pipe_context
*pipe
, unsigned nr
,
74 struct pipe_sampler_view
**views
)
76 struct nv30_context
*nv30
= nv30_context(pipe
);
79 for (i
= 0; i
< nr
; i
++) {
80 nouveau_bufctx_reset(nv30
->bufctx
, BUFCTX_VERTTEX(i
));
81 pipe_sampler_view_reference(&nv30
->vertprog
.textures
[i
], views
[i
]);
82 nv30
->vertprog
.dirty_samplers
|= (1 << i
);
85 for (; i
< nv30
->vertprog
.num_textures
; i
++) {
86 nouveau_bufctx_reset(nv30
->bufctx
, BUFCTX_VERTTEX(i
));
87 pipe_sampler_view_reference(&nv30
->vertprog
.textures
[i
], NULL
);
88 nv30
->vertprog
.dirty_samplers
|= (1 << i
);
91 nv30
->vertprog
.num_textures
= nr
;
92 nv30
->dirty
|= NV30_NEW_VERTTEX
;
96 nv40_verttex_init(struct pipe_context
*pipe
)