5548286a73ee8bbf0b44a1bcf52b9c580dfad245
2 * Copyright (C) 2009 Francisco Jerez.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include "nouveau_driver.h"
28 #include "nouveau_context.h"
29 #include "nouveau_fbo.h"
30 #include "nouveau_util.h"
31 #include "nouveau_class.h"
32 #include "nv04_driver.h"
34 struct nouveau_grobj
*
35 nv04_context_engine(GLcontext
*ctx
)
37 struct nv04_context
*nctx
= to_nv04_context(ctx
);
38 struct nouveau_screen
*screen
= nctx
->base
.screen
;
39 struct nouveau_grobj
*fahrenheit
;
41 if (ctx
->Texture
.Unit
[0].EnvMode
== GL_COMBINE
||
42 ctx
->Texture
.Unit
[0].EnvMode
== GL_BLEND
||
43 ctx
->Texture
.Unit
[1]._ReallyEnabled
||
45 fahrenheit
= screen
->eng3dm
;
47 fahrenheit
= screen
->eng3d
;
49 if (fahrenheit
!= nctx
->eng3d
) {
50 nctx
->eng3d
= fahrenheit
;
52 if (nv04_mtex_engine(fahrenheit
)) {
53 context_dirty_i(ctx
, TEX_ENV
, 0);
54 context_dirty_i(ctx
, TEX_ENV
, 1);
55 context_dirty_i(ctx
, TEX_OBJ
, 0);
56 context_dirty_i(ctx
, TEX_OBJ
, 1);
57 context_dirty(ctx
, CONTROL
);
58 context_dirty(ctx
, BLEND
);
60 context_bctx_i(ctx
, TEXTURE
, 1);
61 context_dirty_i(ctx
, TEX_ENV
, 0);
62 context_dirty_i(ctx
, TEX_OBJ
, 0);
63 context_dirty(ctx
, CONTROL
);
64 context_dirty(ctx
, BLEND
);
72 init_dummy_texture(GLcontext
*ctx
)
74 struct nouveau_surface
*s
= &to_nv04_context(ctx
)->dummy_texture
;
76 nouveau_surface_alloc(ctx
, s
, SWIZZLED
,
77 NOUVEAU_BO_MAP
| NOUVEAU_BO_VRAM
,
78 MESA_FORMAT_ARGB8888
, 1, 1);
80 nouveau_bo_map(s
->bo
, NOUVEAU_BO_WR
);
81 *(uint32_t *)s
->bo
->map
= 0xffffffff;
82 nouveau_bo_unmap(s
->bo
);
86 nv04_context_create(struct nouveau_screen
*screen
, const GLvisual
*visual
,
89 struct nv04_context
*nctx
;
92 nctx
= CALLOC_STRUCT(nv04_context
);
96 ctx
= &nctx
->base
.base
;
97 nouveau_context_init(ctx
, screen
, visual
, share_ctx
);
99 ctx
->Const
.MaxTextureCoordUnits
= NV04_TEXTURE_UNITS
;
100 ctx
->Const
.MaxTextureImageUnits
= NV04_TEXTURE_UNITS
;
101 ctx
->Const
.MaxTextureUnits
= NV04_TEXTURE_UNITS
;
102 ctx
->Const
.MaxTextureMaxAnisotropy
= 2;
103 ctx
->Const
.MaxTextureLodBias
= 15;
105 init_dummy_texture(ctx
);
106 nv04_render_init(ctx
);
112 nv04_context_destroy(GLcontext
*ctx
)
114 nv04_render_destroy(ctx
);
115 nouveau_surface_ref(NULL
, &to_nv04_context(ctx
)->dummy_texture
);