st/nine: Move pipe and cso to nine_context
authorAxel Davy <axel.davy@ens.fr>
Fri, 28 Oct 2016 17:03:59 +0000 (19:03 +0200)
committerAxel Davy <axel.davy@ens.fr>
Tue, 20 Dec 2016 22:44:22 +0000 (23:44 +0100)
Part of the refactor to move all gallium calls to
nine_state.c, and have all internal states required
for those calls in nine_context.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/device9.c
src/gallium/state_trackers/nine/device9.h
src/gallium/state_trackers/nine/nine_ff.c
src/gallium/state_trackers/nine/nine_pipe.c
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/nine_state.h

index a0b2de230fc926227c39ab5af4707609bd865bb4..05fa71cec7cd1994e046ba4eca2607aa7165b8e1 100644 (file)
@@ -191,18 +191,18 @@ NineDevice9_ctor( struct NineDevice9 *This,
     if (This->may_swvp)
         This->caps.MaxVertexShaderConst = NINE_MAX_CONST_F_SWVP;
 
-    This->pipe = This->screen->context_create(This->screen, NULL, 0);
-    if (!This->pipe) { return E_OUTOFMEMORY; } /* guess */
+    This->context.pipe = This->screen->context_create(This->screen, NULL, 0);
+    if (!This->context.pipe) { return E_OUTOFMEMORY; } /* guess */
     This->pipe_sw = This->screen_sw->context_create(This->screen_sw, NULL, 0);
     if (!This->pipe_sw) { return E_OUTOFMEMORY; }
 
-    This->cso = cso_create_context(This->pipe);
-    if (!This->cso) { return E_OUTOFMEMORY; } /* also a guess */
+    This->context.cso = cso_create_context(This->context.pipe);
+    if (!This->context.cso) { return E_OUTOFMEMORY; } /* also a guess */
     This->cso_sw = cso_create_context(This->pipe_sw);
     if (!This->cso_sw) { return E_OUTOFMEMORY; }
 
     /* Create first, it messes up our state. */
-    This->hud = hud_create(This->pipe, This->cso); /* NULL result is fine */
+    This->hud = hud_create(This->context.pipe, This->context.cso); /* NULL result is fine */
 
     /* Available memory counter. Updated only for allocations with this device
      * instance. This is the Win 7 behavior.
@@ -289,14 +289,14 @@ NineDevice9_ctor( struct NineDevice9 *This,
             return D3DERR_OUTOFVIDEOMEMORY;
 
         u_box_1d(0, 16, &box);
-        data = This->pipe->transfer_map(This->pipe, This->dummy_vbo, 0,
+        data = This->context.pipe->transfer_map(This->context.pipe, This->dummy_vbo, 0,
                                         PIPE_TRANSFER_WRITE |
                                         PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE,
                                         &box, &transfer);
         assert(data);
         assert(transfer);
         memset(data, 0, 16);
-        This->pipe->transfer_unmap(This->pipe, transfer);
+        This->context.pipe->transfer_unmap(This->context.pipe, transfer);
     }
 
     This->cursor.software = FALSE;
@@ -423,7 +423,7 @@ NineDevice9_ctor( struct NineDevice9 *This,
         templ.swizzle_a = PIPE_SWIZZLE_1;
         templ.target = This->dummy_texture->target;
 
-        This->dummy_sampler_view = This->pipe->create_sampler_view(This->pipe, This->dummy_texture, &templ);
+        This->dummy_sampler_view = This->context.pipe->create_sampler_view(This->context.pipe, This->dummy_texture, &templ);
         if (!This->dummy_sampler_view)
             return D3DERR_DRIVERINTERNALERROR;
 
@@ -450,16 +450,16 @@ NineDevice9_ctor( struct NineDevice9 *This,
     This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS);
 
     if (!This->driver_caps.user_vbufs)
-        This->vertex_uploader = u_upload_create(This->pipe, 65536,
+        This->vertex_uploader = u_upload_create(This->context.pipe, 65536,
                                                 PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM);
     This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536,
                                             PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM);
     if (!This->driver_caps.user_ibufs)
-        This->index_uploader = u_upload_create(This->pipe, 128 * 1024,
+        This->index_uploader = u_upload_create(This->context.pipe, 128 * 1024,
                                                PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM);
     if (!This->driver_caps.user_cbufs) {
         This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
-        This->constbuf_uploader = u_upload_create(This->pipe, This->vs_const_size,
+        This->constbuf_uploader = u_upload_create(This->context.pipe, This->vs_const_size,
                                                   PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM);
     }
 
@@ -478,7 +478,7 @@ NineDevice9_ctor( struct NineDevice9 *This,
     {
         struct pipe_poly_stipple stipple;
         memset(&stipple, ~0, sizeof(stipple));
-        This->pipe->set_polygon_stipple(This->pipe, &stipple);
+        This->context.pipe->set_polygon_stipple(This->context.pipe, &stipple);
     }
 
     This->update = &This->state;
@@ -498,7 +498,7 @@ NineDevice9_dtor( struct NineDevice9 *This )
 
     DBG("This=%p\n", This);
 
-    if (This->pipe && This->cso)
+    if (This->context.pipe && This->context.cso)
         nine_pipe_context_clear(This);
     nine_ff_fini(This);
     nine_state_destroy_sw(This);
@@ -545,9 +545,9 @@ NineDevice9_dtor( struct NineDevice9 *This )
     }
 
     /* Destroy cso first */
-    if (This->cso) { cso_destroy_context(This->cso); }
+    if (This->context.cso) { cso_destroy_context(This->context.cso); }
     if (This->cso_sw) { cso_destroy_context(This->cso_sw); }
-    if (This->pipe && This->pipe->destroy) { This->pipe->destroy(This->pipe); }
+    if (This->context.pipe && This->context.pipe->destroy) { This->context.pipe->destroy(This->context.pipe); }
     if (This->pipe_sw && This->pipe_sw->destroy) { This->pipe_sw->destroy(This->pipe_sw); }
 
     if (This->present) { ID3DPresentGroup_Release(This->present); }
@@ -565,7 +565,7 @@ NineDevice9_GetScreen( struct NineDevice9 *This )
 struct pipe_context *
 NineDevice9_GetPipe( struct NineDevice9 *This )
 {
-    return This->pipe;
+    return This->context.pipe;
 }
 
 const D3DCAPS9 *
index a1f3e45838d871fc9a88e357370482bef434bfb9..21e045c69dc12bcb3d6f4fb57e90c3c18780c31e 100644 (file)
@@ -53,9 +53,7 @@ struct NineDevice9
     /* G3D context */
     struct pipe_screen *screen;
     struct pipe_screen *screen_sw;
-    struct pipe_context *pipe;
     struct pipe_context *pipe_sw;
-    struct cso_context *cso;
     struct cso_context *cso_sw;
 
     /* creation parameters */
index e168bf87707bc12883c84b2e495ac22491622a0c..b18b00e4471cf366fffabccb5acb95e8f2cab5d5 100644 (file)
@@ -1057,7 +1057,7 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
 
     ureg_END(ureg);
     nine_ureg_tgsi_dump(ureg, FALSE);
-    return ureg_create_shader_and_destroy(ureg, device->pipe);
+    return ureg_create_shader_and_destroy(ureg, device->context.pipe);
 }
 
 /* PS FF constants layout:
@@ -1552,7 +1552,7 @@ nine_ff_build_ps(struct NineDevice9 *device, struct nine_ff_ps_key *key)
 
     ureg_END(ureg);
     nine_ureg_tgsi_dump(ureg, FALSE);
-    return ureg_create_shader_and_destroy(ureg, device->pipe);
+    return ureg_create_shader_and_destroy(ureg, device->context.pipe);
 }
 
 static struct NineVertexShader9 *
@@ -2159,7 +2159,7 @@ nine_ff_prune_vs(struct NineDevice9 *device)
 
     if (device->ff.num_vs > 100) {
         /* could destroy the bound one here, so unbind */
-        device->pipe->bind_vs_state(device->pipe, NULL);
+        context->pipe->bind_vs_state(context->pipe, NULL);
         util_hash_table_foreach(device->ff.ht_vs, nine_ff_ht_delete_cb, NULL);
         util_hash_table_clear(device->ff.ht_vs);
         device->ff.num_vs = 0;
@@ -2173,7 +2173,7 @@ nine_ff_prune_ps(struct NineDevice9 *device)
 
     if (device->ff.num_ps > 100) {
         /* could destroy the bound one here, so unbind */
-        device->pipe->bind_fs_state(device->pipe, NULL);
+        context->pipe->bind_fs_state(context->pipe, NULL);
         util_hash_table_foreach(device->ff.ht_ps, nine_ff_ht_delete_cb, NULL);
         util_hash_table_clear(device->ff.ht_ps);
         device->ff.num_ps = 0;
index 46ac801ec865aee5732540e90d519476187c163c..2970b27e0e8583f63a0e46514537ea447096ed11 100644 (file)
@@ -253,7 +253,7 @@ void
 nine_pipe_context_clear(struct NineDevice9 *This)
 {
     struct pipe_context *pipe = NineDevice9_GetPipe(This);
-    struct cso_context *cso = This->cso;
+    struct cso_context *cso = This->context.cso;
     pipe->bind_vs_state(pipe, NULL);
     pipe->bind_fs_state(pipe, NULL);
 
index 9d2b1a8f67c3208455ef426c49486bfc579cd16f..2ae917c4faaabefc4b1c59577b81cdaa9af151a7 100644 (file)
@@ -413,8 +413,8 @@ prepare_ps(struct NineDevice9 *device, uint8_t shader_changed)
 static void
 update_framebuffer(struct NineDevice9 *device, bool is_clear)
 {
-    struct pipe_context *pipe = device->pipe;
     struct nine_context *context = &device->context;
+    struct pipe_context *pipe = context->pipe;
     struct pipe_framebuffer_state *fb = &context->pipe_data.fb;
     unsigned i;
     struct NineSurface9 *rt0 = context->rt[0];
@@ -489,7 +489,8 @@ update_framebuffer(struct NineDevice9 *device, bool is_clear)
 static void
 update_viewport(struct NineDevice9 *device)
 {
-    const D3DVIEWPORT9 *vport = &device->context.viewport;
+    struct nine_context *context = &device->context;
+    const D3DVIEWPORT9 *vport = &context->viewport;
     struct pipe_viewport_state pvport;
 
     /* D3D coordinates are:
@@ -527,7 +528,7 @@ update_viewport(struct NineDevice9 *device)
         pvport.translate[1] -= 1.0f / 128.0f;
     }
 
-    cso_set_viewport(device->cso, &pvport);
+    cso_set_viewport(context->cso, &pvport);
 }
 
 /* Loop through VS inputs and pick the vertex elements with the declared
@@ -617,14 +618,14 @@ update_vertex_elements(struct NineDevice9 *device)
         context->dummy_vbo_bound_at = dummy_vbo_stream;
     }
 
-    cso_set_vertex_elements(device->cso, vs->num_inputs, ve);
+    cso_set_vertex_elements(context->cso, vs->num_inputs, ve);
 }
 
 static void
 update_vertex_buffers(struct NineDevice9 *device)
 {
-    struct pipe_context *pipe = device->pipe;
     struct nine_context *context = &device->context;
+    struct pipe_context *pipe = context->pipe;
     struct pipe_vertex_buffer dummy_vtxbuf;
     uint32_t mask = context->changed.vtxbuf;
     unsigned i;
@@ -722,7 +723,7 @@ update_textures_and_samplers(struct NineDevice9 *device)
             if (update_sampler_derived(context, s) || (context->changed.sampler[s] & 0x05fe)) {
                 context->changed.sampler[s] = 0;
                 commit_samplers = TRUE;
-                nine_convert_sampler_state(device->cso, s, context->samp[s]);
+                nine_convert_sampler_state(context->cso, s, context->samp[s]);
             }
         } else {
             /* Bind dummy sampler. We do not bind dummy sampler when
@@ -734,7 +735,7 @@ update_textures_and_samplers(struct NineDevice9 *device)
             view[i] = device->dummy_sampler_view;
             num_textures = i + 1;
 
-            cso_single_sampler(device->cso, PIPE_SHADER_FRAGMENT,
+            cso_single_sampler(context->cso, PIPE_SHADER_FRAGMENT,
                                s - NINE_SAMPLER_PS(0), &device->dummy_sampler_state);
 
             commit_samplers = TRUE;
@@ -744,10 +745,10 @@ update_textures_and_samplers(struct NineDevice9 *device)
         context->bound_samplers_mask_ps |= (1 << s);
     }
 
-    cso_set_sampler_views(device->cso, PIPE_SHADER_FRAGMENT, num_textures, view);
+    cso_set_sampler_views(context->cso, PIPE_SHADER_FRAGMENT, num_textures, view);
 
     if (commit_samplers)
-        cso_single_sampler_done(device->cso, PIPE_SHADER_FRAGMENT);
+        cso_single_sampler_done(context->cso, PIPE_SHADER_FRAGMENT);
 
     commit_samplers = FALSE;
     sampler_mask = context->programmable_vs ? context->vs->sampler_mask : 0;
@@ -770,7 +771,7 @@ update_textures_and_samplers(struct NineDevice9 *device)
             if (update_sampler_derived(context, s) || (context->changed.sampler[s] & 0x05fe)) {
                 context->changed.sampler[s] = 0;
                 commit_samplers = TRUE;
-                nine_convert_sampler_state(device->cso, s, context->samp[s]);
+                nine_convert_sampler_state(context->cso, s, context->samp[s]);
             }
         } else {
             /* Bind dummy sampler. We do not bind dummy sampler when
@@ -782,7 +783,7 @@ update_textures_and_samplers(struct NineDevice9 *device)
             view[i] = device->dummy_sampler_view;
             num_textures = i + 1;
 
-            cso_single_sampler(device->cso, PIPE_SHADER_VERTEX,
+            cso_single_sampler(context->cso, PIPE_SHADER_VERTEX,
                                s - NINE_SAMPLER_VS(0), &device->dummy_sampler_state);
 
             commit_samplers = TRUE;
@@ -792,10 +793,10 @@ update_textures_and_samplers(struct NineDevice9 *device)
         context->bound_samplers_mask_vs |= (1 << s);
     }
 
-    cso_set_sampler_views(device->cso, PIPE_SHADER_VERTEX, num_textures, view);
+    cso_set_sampler_views(context->cso, PIPE_SHADER_VERTEX, num_textures, view);
 
     if (commit_samplers)
-        cso_single_sampler_done(device->cso, PIPE_SHADER_VERTEX);
+        cso_single_sampler_done(context->cso, PIPE_SHADER_VERTEX);
 }
 
 /* State commit only */
@@ -803,35 +804,43 @@ update_textures_and_samplers(struct NineDevice9 *device)
 static inline void
 commit_blend(struct NineDevice9 *device)
 {
-    cso_set_blend(device->cso, &device->context.pipe_data.blend);
+    struct nine_context *context = &device->context;
+
+    cso_set_blend(context->cso, &context->pipe_data.blend);
 }
 
 static inline void
 commit_dsa(struct NineDevice9 *device)
 {
-    cso_set_depth_stencil_alpha(device->cso, &device->context.pipe_data.dsa);
+    struct nine_context *context = &device->context;
+
+    cso_set_depth_stencil_alpha(context->cso, &context->pipe_data.dsa);
 }
 
 static inline void
 commit_scissor(struct NineDevice9 *device)
 {
-    struct pipe_context *pipe = device->pipe;
+    struct nine_context *context = &device->context;
+    struct pipe_context *pipe = context->pipe;
 
-    pipe->set_scissor_states(pipe, 0, 1, &device->context.scissor);
+    pipe->set_scissor_states(pipe, 0, 1, &context->scissor);
 }
 
 static inline void
 commit_rasterizer(struct NineDevice9 *device)
 {
-    cso_set_rasterizer(device->cso, &device->context.pipe_data.rast);
+    struct nine_context *context = &device->context;
+
+    cso_set_rasterizer(context->cso, &context->pipe_data.rast);
 }
 
 static inline void
 commit_index_buffer(struct NineDevice9 *device)
 {
-    struct pipe_context *pipe = device->pipe;
-    if (device->context.idxbuf.buffer)
-        pipe->set_index_buffer(pipe, &device->context.idxbuf);
+    struct nine_context *context = &device->context;
+    struct pipe_context *pipe = context->pipe;
+    if (context->idxbuf.buffer)
+        pipe->set_index_buffer(pipe, &context->idxbuf);
     else
         pipe->set_index_buffer(pipe, NULL);
 }
@@ -839,18 +848,19 @@ commit_index_buffer(struct NineDevice9 *device)
 static inline void
 commit_vs_constants(struct NineDevice9 *device)
 {
-    struct pipe_context *pipe = device->pipe;
+    struct nine_context *context = &device->context;
+    struct pipe_context *pipe = context->pipe;
 
-    if (unlikely(!device->context.programmable_vs))
-        pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &device->context.pipe_data.cb_vs_ff);
+    if (unlikely(!context->programmable_vs))
+        pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->pipe_data.cb_vs_ff);
     else {
         if (device->swvp) {
-            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &device->context.pipe_data.cb0_swvp);
-            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 1, &device->context.pipe_data.cb1_swvp);
-            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 2, &device->context.pipe_data.cb2_swvp);
-            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 3, &device->context.pipe_data.cb3_swvp);
+            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->pipe_data.cb0_swvp);
+            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 1, &context->pipe_data.cb1_swvp);
+            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 2, &context->pipe_data.cb2_swvp);
+            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 3, &context->pipe_data.cb3_swvp);
         } else {
-            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &device->context.pipe_data.cb_vs);
+            pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->pipe_data.cb_vs);
         }
     }
 }
@@ -858,12 +868,13 @@ commit_vs_constants(struct NineDevice9 *device)
 static inline void
 commit_ps_constants(struct NineDevice9 *device)
 {
-    struct pipe_context *pipe = device->pipe;
+    struct nine_context *context = &device->context;
+    struct pipe_context *pipe = context->pipe;
 
-    if (unlikely(!device->context.ps))
-        pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &device->context.pipe_data.cb_ps_ff);
+    if (unlikely(!context->ps))
+        pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &context->pipe_data.cb_ps_ff);
     else
-        pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &device->context.pipe_data.cb_ps);
+        pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &context->pipe_data.cb_ps);
 }
 
 static inline void
@@ -871,7 +882,7 @@ commit_vs(struct NineDevice9 *device)
 {
     struct nine_context *context = &device->context;
 
-    device->pipe->bind_vs_state(device->pipe, context->cso_shader.vs);
+    context->pipe->bind_vs_state(context->pipe, context->cso_shader.vs);
 }
 
 
@@ -880,7 +891,7 @@ commit_ps(struct NineDevice9 *device)
 {
     struct nine_context *context = &device->context;
 
-    device->pipe->bind_fs_state(device->pipe, context->cso_shader.ps);
+    context->pipe->bind_fs_state(context->pipe, context->cso_shader.ps);
 }
 /* State Update */
 
@@ -945,8 +956,8 @@ update_managed_buffers(struct NineDevice9 *device)
 static void
 nine_update_state(struct NineDevice9 *device)
 {
-    struct pipe_context *pipe = device->pipe;
     struct nine_context *context = &device->context;
+    struct pipe_context *pipe = context->pipe;
     uint32_t group;
 
     DBG("changed state groups: %x\n", context->changed.group);
@@ -1108,7 +1119,7 @@ NineDevice9_ResolveZ( struct NineDevice9 *device )
     blit.filter = PIPE_TEX_FILTER_NEAREST;
     blit.scissor_enable = FALSE;
 
-    device->pipe->blit(device->pipe, &blit);
+    context->pipe->blit(context->pipe, &blit);
 }
 
 #define ALPHA_TO_COVERAGE_ENABLE   MAKEFOURCC('A', '2', 'M', '1')
@@ -1850,7 +1861,7 @@ nine_context_clear_fb(struct NineDevice9 *device,
     struct nine_context *context = &device->context;
     const int sRGB = context->rs[D3DRS_SRGBWRITEENABLE] ? 1 : 0;
     struct pipe_surface *cbuf, *zsbuf;
-    struct pipe_context *pipe = device->pipe;
+    struct pipe_context *pipe = context->pipe;
     struct NineSurface9 *zsbuf_surf = context->ds;
     struct NineSurface9 *rt;
     unsigned bufs = 0;
@@ -2006,6 +2017,7 @@ nine_context_draw_primitive(struct NineDevice9 *device,
                             UINT StartVertex,
                             UINT PrimitiveCount)
 {
+    struct nine_context *context = &device->context;
     struct pipe_draw_info info;
 
     nine_update_state(device);
@@ -2017,7 +2029,7 @@ nine_context_draw_primitive(struct NineDevice9 *device,
     info.min_index = info.start;
     info.max_index = info.count - 1;
 
-    device->pipe->draw_vbo(device->pipe, &info);
+    context->pipe->draw_vbo(context->pipe, &info);
 }
 
 void
@@ -2029,6 +2041,7 @@ nine_context_draw_indexed_primitive(struct NineDevice9 *device,
                                     UINT StartIndex,
                                     UINT PrimitiveCount)
 {
+    struct nine_context *context = &device->context;
     struct pipe_draw_info info;
 
     nine_update_state(device);
@@ -2041,7 +2054,7 @@ nine_context_draw_indexed_primitive(struct NineDevice9 *device,
     info.min_index = MinVertexIndex;
     info.max_index = MinVertexIndex + NumVertices - 1;
 
-    device->pipe->draw_vbo(device->pipe, &info);
+    context->pipe->draw_vbo(context->pipe, &info);
 }
 
 void
@@ -2050,6 +2063,7 @@ nine_context_draw_primitive_from_vtxbuf(struct NineDevice9 *device,
                                         UINT PrimitiveCount,
                                         struct pipe_vertex_buffer *vtxbuf)
 {
+    struct nine_context *context = &device->context;
     struct pipe_draw_info info;
 
     nine_update_state(device);
@@ -2061,9 +2075,9 @@ nine_context_draw_primitive_from_vtxbuf(struct NineDevice9 *device,
     info.min_index = 0;
     info.max_index = info.count - 1;
 
-    device->pipe->set_vertex_buffers(device->pipe, 0, 1, vtxbuf);
+    context->pipe->set_vertex_buffers(context->pipe, 0, 1, vtxbuf);
 
-    device->pipe->draw_vbo(device->pipe, &info);
+    context->pipe->draw_vbo(context->pipe, &info);
 }
 
 void
@@ -2075,6 +2089,7 @@ nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *devic
                                                        struct pipe_vertex_buffer *vbuf,
                                                        struct pipe_index_buffer *ibuf)
 {
+    struct nine_context *context = &device->context;
     struct pipe_draw_info info;
 
     nine_update_state(device);
@@ -2085,34 +2100,42 @@ nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *devic
     info.index_bias = 0;
     info.min_index = MinVertexIndex;
     info.max_index = MinVertexIndex + NumVertices - 1;
-    device->pipe->set_vertex_buffers(device->pipe, 0, 1, vbuf);
-    device->pipe->set_index_buffer(device->pipe, ibuf);
+    context->pipe->set_vertex_buffers(context->pipe, 0, 1, vbuf);
+    context->pipe->set_index_buffer(context->pipe, ibuf);
 
-    device->pipe->draw_vbo(device->pipe, &info);
+    context->pipe->draw_vbo(context->pipe, &info);
 }
 
 struct pipe_query *
 nine_context_create_query(struct NineDevice9 *device, unsigned query_type)
 {
-    return device->pipe->create_query(device->pipe, query_type, 0);
+    struct nine_context *context = &device->context;
+
+    return context->pipe->create_query(context->pipe, query_type, 0);
 }
 
 void
 nine_context_destroy_query(struct NineDevice9 *device, struct pipe_query *query)
 {
-    device->pipe->destroy_query(device->pipe, query);
+    struct nine_context *context = &device->context;
+
+    context->pipe->destroy_query(context->pipe, query);
 }
 
 void
 nine_context_begin_query(struct NineDevice9 *device, struct pipe_query *query)
 {
-    (void) device->pipe->begin_query(device->pipe, query);
+    struct nine_context *context = &device->context;
+
+    (void) context->pipe->begin_query(context->pipe, query);
 }
 
 void
 nine_context_end_query(struct NineDevice9 *device, struct pipe_query *query)
 {
-    (void) device->pipe->end_query(device->pipe, query);
+    struct nine_context *context = &device->context;
+
+    (void) context->pipe->end_query(context->pipe, query);
 }
 
 boolean
@@ -2120,8 +2143,10 @@ nine_context_get_query_result(struct NineDevice9 *device, struct pipe_query *que
                               boolean flush, boolean wait,
                               union pipe_query_result *result)
 {
+    struct nine_context *context = &device->context;
+
     (void) flush;
-    return device->pipe->get_query_result(device->pipe, query, wait, result);
+    return context->pipe->get_query_result(context->pipe, query, wait, result);
 }
 
 /* State defaults */
@@ -2518,7 +2543,7 @@ update_vertex_elements_sw(struct NineDevice9 *device)
 static void
 update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int num_vertices)
 {
-    struct pipe_context *pipe = device->pipe;
+    struct pipe_context *pipe = NineDevice9_GetPipe(device);
     struct pipe_context *pipe_sw = device->pipe_sw;
     struct nine_state *state = &device->state;
     struct nine_state_sw_internal *sw_internal = &device->state_sw_internal;
@@ -2743,7 +2768,7 @@ void
 nine_state_after_draw_sw(struct NineDevice9 *device)
 {
     struct nine_state_sw_internal *sw_internal = &device->state_sw_internal;
-    struct pipe_context *pipe = device->pipe;
+    struct pipe_context *pipe = NineDevice9_GetPipe(device);
     struct pipe_context *pipe_sw = device->pipe_sw;
     int i;
 
index 921074df1bb14a925aa94dd5d82cfdabe6288e18..091902518bd2c82bcecdc4219f957efedc3439a1 100644 (file)
@@ -241,6 +241,9 @@ struct nine_context {
         void *ps;
     } cso_shader;
 
+    struct pipe_context *pipe;
+    struct cso_context *cso;
+
     uint8_t rt_mask;
 
     D3DVIEWPORT9 viewport;