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) {
21
OUT_RING(chan, RING_3D(0x1fd8, 1));
23
OUT_RING(chan, RING_3D(0x1fd8, 1));
33
nvfx_destroy(struct pipe_context *pipe)
35
struct nvfx_context *nvfx = nvfx_context(pipe);
38
pipe->delete_fs_state(pipe, nvfx->dummy_fs);
40
for(unsigned i = 0; i < nvfx->vtxbuf_nr; ++i)
41
pipe_resource_reference(&nvfx->vtxbuf[i].buffer, 0);
42
pipe_resource_reference(&nvfx->idxbuf.buffer, 0);
43
util_unreference_framebuffer_state(&nvfx->framebuffer);
44
for(unsigned i = 0; i < PIPE_MAX_SAMPLERS; ++i)
45
pipe_sampler_view_reference(&nvfx->fragment_sampler_views[i], 0);
48
draw_destroy(nvfx->draw);
50
if(nvfx->screen->cur_ctx == nvfx)
51
nvfx->screen->cur_ctx = NULL;
57
nvfx_create(struct pipe_screen *pscreen, void *priv)
59
struct nvfx_screen *screen = nvfx_screen(pscreen);
60
struct pipe_winsys *ws = pscreen->winsys;
61
struct nvfx_context *nvfx;
62
struct nouveau_winsys *nvws = screen->nvws;
64
nvfx = CALLOC(1, sizeof(struct nvfx_context));
67
nvfx->screen = screen;
71
nvfx->pipe.winsys = ws;
72
nvfx->pipe.screen = pscreen;
73
nvfx->pipe.priv = priv;
74
nvfx->pipe.destroy = nvfx_destroy;
75
nvfx->pipe.draw_vbo = nvfx_draw_vbo;
76
nvfx->pipe.clear = nvfx_clear;
77
nvfx->pipe.flush = nvfx_flush;
79
nvfx->is_nv4x = screen->is_nv4x;
80
nvfx->use_nv4x = screen->use_nv4x;
81
/* TODO: it seems that nv30 might have fixed function clipping usable with vertex programs
82
* However, my code for that doesn't work, so use vp clipping for all cards, which works.
84
nvfx->use_vp_clipping = TRUE;
86
nvfx_init_query_functions(nvfx);
87
nvfx_init_surface_functions(nvfx);
88
nvfx_init_state_functions(nvfx);
89
nvfx_init_sampling_functions(nvfx);
90
nvfx_init_vbo_functions(nvfx);
91
nvfx_init_fragprog_functions(nvfx);
92
nvfx_init_vertprog_functions(nvfx);
93
nvfx_init_resource_functions(&nvfx->pipe);
94
nvfx_init_transfer_functions(&nvfx->pipe);
96
/* Create, configure, and install fallback swtnl path */
97
nvfx->draw = draw_create(&nvfx->pipe);
98
draw_wide_point_threshold(nvfx->draw, 9999999.0);
99
draw_wide_line_threshold(nvfx->draw, 9999999.0);
100
draw_enable_line_stipple(nvfx->draw, FALSE);
101
draw_enable_point_sprites(nvfx->draw, FALSE);
102
draw_set_rasterize_stage(nvfx->draw, nvfx_draw_render_stage(nvfx));
104
/* set these to that we init them on first validation */
105
nvfx->state.scissor_enabled = ~0;
106
nvfx->hw_pointsprite_control = -1;
107
nvfx->hw_vp_output = -1;
108
nvfx->use_vertex_buffers = -1;
109
nvfx->relocs_needed = NVFX_RELOCATE_ALL;
111
LIST_INITHEAD(&nvfx->render_cache);