| 1 |
/* |
| 2 |
* Copyright 2012 Red Hat Inc. |
| 3 |
* |
| 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: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included in |
| 12 |
* all copies or substantial portions of the Software. |
| 13 |
* |
| 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. |
| 21 |
* |
| 22 |
* Authors: Ben Skeggs |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "util/u_inlines.h" |
| 27 |
#include "nv30/nv30_context.h" |
| 28 |
#include "nv30/nv30_winsys.h" |
| 29 |
|
| 30 |
void |
| 31 |
nv40_verttex_validate(struct nv30_context *nv30) |
| 32 |
{ |
| 33 |
struct nouveau_pushbuf *push = nv30->base.pushbuf; |
| 34 |
unsigned dirty = nv30->vertprog.dirty_samplers; |
| 35 |
|
| 36 |
while (dirty) { |
| 37 |
unsigned unit = ffs(dirty) - 1; |
| 38 |
struct nv30_sampler_view *sv = (void *)nv30->fragprog.textures[unit]; |
| 39 |
struct nv30_sampler_state *ss = nv30->fragprog.samplers[unit]; |
| 40 |
|
| 41 |
if (ss && sv) { |
| 42 |
} else { |
| 43 |
BEGIN_NV04(push, NV40_3D(VTXTEX_ENABLE(unit)), 1); |
| 44 |
PUSH_DATA (push, 0); |
| 45 |
} |
| 46 |
dirty &= ~(1 << unit); |
| 47 |
} |
| 48 |
|
| 49 |
nv30->vertprog.dirty_samplers = 0; |
| 50 |
} |
| 51 |
|
| 52 |
void |
| 53 |
nv40_verttex_sampler_states_bind(struct pipe_context *pipe, |
| 54 |
unsigned nr, void **hwcso) |
| 55 |
{ |
| 56 |
struct nv30_context *nv30 = nv30_context(pipe); |
| 57 |
unsigned i; |
| 58 |
|
| 59 |
for (i = 0; i < nr; i++) { |
| 60 |
nv30->vertprog.samplers[i] = hwcso[i]; |
| 61 |
nv30->vertprog.dirty_samplers |= (1 << i); |
| 62 |
} |
| 63 |
|
| 64 |
for (; i < nv30->vertprog.num_samplers; i++) { |
| 65 |
nv30->vertprog.samplers[i] = NULL; |
| 66 |
nv30->vertprog.dirty_samplers |= (1 << i); |
| 67 |
} |
| 68 |
|
| 69 |
nv30->vertprog.num_samplers = nr; |
| 70 |
nv30->dirty |= NV30_NEW_VERTTEX; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
void |
| 75 |
nv40_verttex_set_sampler_views(struct pipe_context *pipe, unsigned nr, |
| 76 |
struct pipe_sampler_view **views) |
| 77 |
{ |
| 78 |
struct nv30_context *nv30 = nv30_context(pipe); |
| 79 |
unsigned i; |
| 80 |
|
| 81 |
for (i = 0; i < nr; i++) { |
| 82 |
nouveau_bufctx_reset(nv30->bufctx, BUFCTX_VERTTEX(i)); |
| 83 |
pipe_sampler_view_reference(&nv30->vertprog.textures[i], views[i]); |
| 84 |
nv30->vertprog.dirty_samplers |= (1 << i); |
| 85 |
} |
| 86 |
|
| 87 |
for (; i < nv30->vertprog.num_textures; i++) { |
| 88 |
nouveau_bufctx_reset(nv30->bufctx, BUFCTX_VERTTEX(i)); |
| 89 |
pipe_sampler_view_reference(&nv30->vertprog.textures[i], NULL); |
| 90 |
nv30->vertprog.dirty_samplers |= (1 << i); |
| 91 |
} |
| 92 |
|
| 93 |
nv30->vertprog.num_textures = nr; |
| 94 |
nv30->dirty |= NV30_NEW_VERTTEX; |
| 95 |
} |
| 96 |
|
| 97 |
void |
| 98 |
nv40_verttex_init(struct pipe_context *pipe) |
| 99 |
{ |
| 100 |
/* nothing */ |
| 101 |
} |