1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2010 Christoph Bumiller
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the "Software"),
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to deal in the Software without restriction, including without limitation
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and/or sell copies of the Software, and to permit persons to whom the
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Software is furnished to do so, subject to the following conditions:
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice shall be included in
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * all copies or substantial portions of the Software.
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE.
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_defines.h"
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_framebuffer.h"
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef NV50_WITH_DRAW_MODULE
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "draw/draw_context.h"
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nv50_context.h"
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nv50_screen.h"
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nv50_resource.h"
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnv50_flush(struct pipe_context *pipe,
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org           struct pipe_fence_handle **fence)
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct nouveau_screen *screen = nouveau_screen(pipe->screen);
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (fence)
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      nouveau_fence_ref(screen->fence.current, (struct nouveau_fence **)fence);
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   PUSH_KICK(screen->pushbuf);
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnv50_texture_barrier(struct pipe_context *pipe)
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct nouveau_pushbuf *push = nv50_context(pipe)->base.pushbuf;
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   BEGIN_NV04(push, SUBC_3D(NV50_GRAPH_SERIALIZE), 1);
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   PUSH_DATA (push, 0);
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   BEGIN_NV04(push, NV50_3D(TEX_CACHE_CTL), 1);
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   PUSH_DATA (push, 0x20);
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnv50_default_kick_notify(struct nouveau_pushbuf *push)
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct nv50_screen *screen = push->user_priv;
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (screen) {
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      nouveau_fence_next(&screen->base);
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      nouveau_fence_update(&screen->base, TRUE);
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      if (screen->cur_ctx)
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         screen->cur_ctx->state.flushed = TRUE;
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnv50_context_unreference_resources(struct nv50_context *nv50)
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   unsigned s, i;
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nouveau_bufctx_del(&nv50->bufctx_3d);
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nouveau_bufctx_del(&nv50->bufctx);
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   util_unreference_framebuffer_state(&nv50->framebuffer);
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   for (i = 0; i < nv50->num_vtxbufs; ++i)
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      pipe_resource_reference(&nv50->vtxbuf[i].buffer, NULL);
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   pipe_resource_reference(&nv50->idxbuf.buffer, NULL);
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   for (s = 0; s < 3; ++s) {
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      for (i = 0; i < nv50->num_textures[s]; ++i)
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         pipe_sampler_view_reference(&nv50->textures[s][i], NULL);
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      for (i = 0; i < NV50_MAX_PIPE_CONSTBUFS; ++i)
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         if (!nv50->constbuf[s][i].user)
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org            pipe_resource_reference(&nv50->constbuf[s][i].u.buf, NULL);
92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnv50_destroy(struct pipe_context *pipe)
97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct nv50_context *nv50 = nv50_context(pipe);
99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (nv50_context_screen(nv50)->cur_ctx == nv50) {
101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      nv50->base.pushbuf->kick_notify = NULL;
102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      nv50_context_screen(nv50)->cur_ctx = NULL;
103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      nouveau_pushbuf_bufctx(nv50->base.pushbuf, NULL);
104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* need to flush before destroying the bufctx */
106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nouveau_pushbuf_kick(nv50->base.pushbuf, nv50->base.pushbuf->channel);
107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50_context_unreference_resources(nv50);
109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef NV50_WITH_DRAW_MODULE
111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   draw_destroy(nv50->draw);
112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nouveau_context_destroy(&nv50->base);
115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct pipe_context *
118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnv50_create(struct pipe_screen *pscreen, void *priv)
119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct nv50_screen *screen = nv50_screen(pscreen);
121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct nv50_context *nv50;
122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_context *pipe;
123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   int ret;
124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   uint32_t flags;
125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50 = CALLOC_STRUCT(nv50_context);
127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (!nv50)
128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return NULL;
129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   pipe = &nv50->base.pipe;
130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50->base.pushbuf = screen->base.pushbuf;
132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ret = nouveau_bufctx_new(screen->base.client, NV50_BIND_COUNT,
134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                            &nv50->bufctx_3d);
135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (!ret)
136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      ret = nouveau_bufctx_new(screen->base.client, 2, &nv50->bufctx);
137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (ret)
138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      goto out_err;
139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50->base.screen    = &screen->base;
141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50->base.copy_data = nv50_m2mf_copy_linear;
142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50->base.push_data = nv50_sifc_linear_u8;
143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50->base.push_cb   = nv50_cb_push;
144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50->screen = screen;
146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   pipe->screen = pscreen;
147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   pipe->priv = priv;
148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   pipe->destroy = nv50_destroy;
150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   pipe->draw_vbo = nv50_draw_vbo;
152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   pipe->clear = nv50_clear;
153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   pipe->flush = nv50_flush;
155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   pipe->texture_barrier = nv50_texture_barrier;
156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (!screen->cur_ctx) {
158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      screen->cur_ctx = nv50;
159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      nouveau_pushbuf_bufctx(screen->base.pushbuf, nv50->bufctx);
160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50_init_query_functions(nv50);
163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50_init_surface_functions(nv50);
164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50_init_state_functions(nv50);
165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50_init_resource_functions(pipe);
166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef NV50_WITH_DRAW_MODULE
168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* no software fallbacks implemented */
169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50->draw = draw_create(pipe);
170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   assert(nv50->draw);
171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   draw_set_rasterize_stage(nv50->draw, nv50_draw_render_stage(nv50));
172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nouveau_context_init_vdec(&nv50->base);
175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD;
177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   BCTX_REFN_bo(nv50->bufctx_3d, SCREEN, flags, screen->code);
179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   BCTX_REFN_bo(nv50->bufctx_3d, SCREEN, flags, screen->uniforms);
180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   BCTX_REFN_bo(nv50->bufctx_3d, SCREEN, flags, screen->txc);
181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   BCTX_REFN_bo(nv50->bufctx_3d, SCREEN, flags, screen->stack_bo);
182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   flags = NOUVEAU_BO_GART | NOUVEAU_BO_WR;
184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   BCTX_REFN_bo(nv50->bufctx_3d, SCREEN, flags, screen->fence.bo);
186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   BCTX_REFN_bo(nv50->bufctx, FENCE, flags, screen->fence.bo);
187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   nv50->base.scratch.bo_size = 2 << 20;
189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   return pipe;
191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgout_err:
193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (nv50) {
194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      if (nv50->bufctx_3d)
195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         nouveau_bufctx_del(&nv50->bufctx_3d);
196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      if (nv50->bufctx)
197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         nouveau_bufctx_del(&nv50->bufctx);
198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      FREE(nv50);
199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   return NULL;
201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnv50_bufctx_fence(struct nouveau_bufctx *bufctx, boolean on_flush)
205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct nouveau_list *list = on_flush ? &bufctx->current : &bufctx->pending;
207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct nouveau_list *it;
208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   for (it = list->next; it != list; it = it->next) {
210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      struct nouveau_bufref *ref = (struct nouveau_bufref *)it;
211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      struct nv04_resource *res = ref->priv;
212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      if (res)
213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         nv50_resource_validate(res, (unsigned)ref->priv_data);
214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
216