6c8934d3a4a2a6d61d23892b0ee6f7fe2f0d94d1
1 #include "draw/draw_context.h"
2 #include "pipe/p_defines.h"
3 #include "util/u_framebuffer.h"
5 #include "nvfx_context.h"
6 #include "nvfx_screen.h"
7 #include "nvfx_resource.h"
10 nvfx_flush(struct pipe_context
*pipe
, unsigned flags
,
11 struct pipe_fence_handle
**fence
)
13 struct nvfx_context
*nvfx
= nvfx_context(pipe
);
14 struct nvfx_screen
*screen
= nvfx
->screen
;
15 struct nouveau_channel
*chan
= screen
->base
.channel
;
16 struct nouveau_grobj
*eng3d
= screen
->eng3d
;
18 /* XXX: we need to actually be intelligent here */
19 if (flags
& PIPE_FLUSH_TEXTURE_CACHE
) {
20 BEGIN_RING(chan
, eng3d
, 0x1fd8, 1);
22 BEGIN_RING(chan
, eng3d
, 0x1fd8, 1);
32 nvfx_destroy(struct pipe_context
*pipe
)
34 struct nvfx_context
*nvfx
= nvfx_context(pipe
);
37 pipe
->delete_fs_state(pipe
, nvfx
->dummy_fs
);
39 for(unsigned i
= 0; i
< nvfx
->vtxbuf_nr
; ++i
)
40 pipe_resource_reference(&nvfx
->vtxbuf
[i
].buffer
, 0);
41 pipe_resource_reference(&nvfx
->idxbuf
.buffer
, 0);
42 util_unreference_framebuffer_state(&nvfx
->framebuffer
);
43 for(unsigned i
= 0; i
< PIPE_MAX_SAMPLERS
; ++i
)
44 pipe_sampler_view_reference(&nvfx
->fragment_sampler_views
[i
], 0);
47 draw_destroy(nvfx
->draw
);
49 if(nvfx
->screen
->cur_ctx
== nvfx
)
50 nvfx
->screen
->cur_ctx
= NULL
;
56 nvfx_create(struct pipe_screen
*pscreen
, void *priv
)
58 struct nvfx_screen
*screen
= nvfx_screen(pscreen
);
59 struct pipe_winsys
*ws
= pscreen
->winsys
;
60 struct nvfx_context
*nvfx
;
61 struct nouveau_winsys
*nvws
= screen
->nvws
;
63 nvfx
= CALLOC(1, sizeof(struct nvfx_context
));
66 nvfx
->screen
= screen
;
70 nvfx
->pipe
.winsys
= ws
;
71 nvfx
->pipe
.screen
= pscreen
;
72 nvfx
->pipe
.priv
= priv
;
73 nvfx
->pipe
.destroy
= nvfx_destroy
;
74 nvfx
->pipe
.draw_vbo
= nvfx_draw_vbo
;
75 nvfx
->pipe
.clear
= nvfx_clear
;
76 nvfx
->pipe
.flush
= nvfx_flush
;
78 nvfx
->is_nv4x
= screen
->is_nv4x
;
79 nvfx
->use_nv4x
= screen
->use_nv4x
;
80 /* TODO: it seems that nv30 might have fixed function clipping usable with vertex programs
81 * However, my code for that doesn't work, so use vp clipping for all cards, which works.
83 nvfx
->use_vp_clipping
= TRUE
;
85 nvfx_init_query_functions(nvfx
);
86 nvfx_init_surface_functions(nvfx
);
87 nvfx_init_state_functions(nvfx
);
88 nvfx_init_sampling_functions(nvfx
);
89 nvfx_init_vbo_functions(nvfx
);
90 nvfx_init_fragprog_functions(nvfx
);
91 nvfx_init_vertprog_functions(nvfx
);
92 nvfx_init_resource_functions(&nvfx
->pipe
);
93 nvfx_init_transfer_functions(&nvfx
->pipe
);
95 /* Create, configure, and install fallback swtnl path */
96 nvfx
->draw
= draw_create(&nvfx
->pipe
);
97 draw_wide_point_threshold(nvfx
->draw
, 9999999.0);
98 draw_wide_line_threshold(nvfx
->draw
, 9999999.0);
99 draw_enable_line_stipple(nvfx
->draw
, FALSE
);
100 draw_enable_point_sprites(nvfx
->draw
, FALSE
);
101 draw_set_rasterize_stage(nvfx
->draw
, nvfx_draw_render_stage(nvfx
));
103 /* set these to that we init them on first validation */
104 nvfx
->state
.scissor_enabled
= ~0;
105 nvfx
->hw_pointsprite_control
= -1;
106 nvfx
->hw_vp_output
= -1;
107 nvfx
->use_vertex_buffers
= -1;
108 nvfx
->relocs_needed
= NVFX_RELOCATE_ALL
;
110 LIST_INITHEAD(&nvfx
->render_cache
);