Path: blob/21.2-virgl/src/gallium/drivers/nouveau/nv30/nv40_verttex.c
4574 views
/*1* Copyright 2012 Red Hat Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*21* Authors: Ben Skeggs22*23*/2425#include "util/u_inlines.h"26#include "nv30/nv30_context.h"2728void29nv40_verttex_validate(struct nv30_context *nv30)30{31struct nouveau_pushbuf *push = nv30->base.pushbuf;32unsigned dirty = nv30->vertprog.dirty_samplers;3334while (dirty) {35unsigned unit = ffs(dirty) - 1;36struct nv30_sampler_view *sv = (void *)nv30->fragprog.textures[unit];37struct nv30_sampler_state *ss = nv30->fragprog.samplers[unit];3839if (ss && sv) {40} else {41BEGIN_NV04(push, NV40_3D(VTXTEX_ENABLE(unit)), 1);42PUSH_DATA (push, 0);43}44dirty &= ~(1 << unit);45}4647nv30->vertprog.dirty_samplers = 0;48}4950void51nv40_verttex_sampler_states_bind(struct pipe_context *pipe,52unsigned nr, void **hwcso)53{54struct nv30_context *nv30 = nv30_context(pipe);55unsigned i;5657for (i = 0; i < nr; i++) {58nv30->vertprog.samplers[i] = hwcso[i];59nv30->vertprog.dirty_samplers |= (1 << i);60}6162for (; i < nv30->vertprog.num_samplers; i++) {63nv30->vertprog.samplers[i] = NULL;64nv30->vertprog.dirty_samplers |= (1 << i);65}6667nv30->vertprog.num_samplers = nr;68nv30->dirty |= NV30_NEW_VERTTEX;69}707172void73nv40_verttex_set_sampler_views(struct pipe_context *pipe, unsigned nr,74struct pipe_sampler_view **views)75{76struct nv30_context *nv30 = nv30_context(pipe);77unsigned i;7879for (i = 0; i < nr; i++) {80nouveau_bufctx_reset(nv30->bufctx, BUFCTX_VERTTEX(i));81pipe_sampler_view_reference(&nv30->vertprog.textures[i], views[i]);82nv30->vertprog.dirty_samplers |= (1 << i);83}8485for (; i < nv30->vertprog.num_textures; i++) {86nouveau_bufctx_reset(nv30->bufctx, BUFCTX_VERTTEX(i));87pipe_sampler_view_reference(&nv30->vertprog.textures[i], NULL);88nv30->vertprog.dirty_samplers |= (1 << i);89}9091nv30->vertprog.num_textures = nr;92nv30->dirty |= NV30_NEW_VERTTEX;93}9495void96nv40_verttex_init(struct pipe_context *pipe)97{98/* nothing */99}100101102