1bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez/* 2bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * Copyright (C) 2009 Francisco Jerez. 3bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * All Rights Reserved. 4bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * 5bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * Permission is hereby granted, free of charge, to any person obtaining 6bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * a copy of this software and associated documentation files (the 7bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * "Software"), to deal in the Software without restriction, including 8bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * without limitation the rights to use, copy, modify, merge, publish, 9bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * distribute, sublicense, and/or sell copies of the Software, and to 10bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * permit persons to whom the Software is furnished to do so, subject to 11bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * the following conditions: 12bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * 13bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * The above copyright notice and this permission notice (including the 14bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * next paragraph) shall be included in all copies or substantial 15bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * portions of the Software. 16bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * 17bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 21bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez * 25bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez */ 26bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 27bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#ifndef __NOUVEAU_CONTEXT_H__ 28bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#define __NOUVEAU_CONTEXT_H__ 29bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 30bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#include "nouveau_screen.h" 31bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#include "nouveau_state.h" 32f2098e0fefbbcd72df4c8283d195beae4a113f35Francisco Jerez#include "nouveau_scratch.h" 33bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#include "nouveau_render.h" 34bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 3562e968d6dab2339a530ba1176b6a433d95db938aJosé Fonseca#include "main/bitset.h" 3662e968d6dab2339a530ba1176b6a433d95db938aJosé Fonseca 37bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerezenum nouveau_fallback { 38bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez HWTNL = 0, 39bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez SWTNL, 40bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez SWRAST, 41bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez}; 42bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 432e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs#define BUFCTX_FB 0 442e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs#define BUFCTX_VTX 1 452e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs#define BUFCTX_TEX(i) (2 + (i)) 462e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs 4756dcd011b5ec33190f268cf546a4c68f81f5ebd0Francisco Jerezstruct nouveau_hw_state { 482e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *chan; 492e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_client *client; 502e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_pushbuf *pushbuf; 512e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_bufctx *bufctx; 5256dcd011b5ec33190f268cf546a4c68f81f5ebd0Francisco Jerez 532e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *null; 542e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *ntfy; 552e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *eng3d; 562e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *eng3dm; 572e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *surf3d; 582e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *m2mf; 592e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *surf2d; 602e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *rop; 612e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *patt; 622e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *rect; 632e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *swzsurf; 642e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs struct nouveau_object *sifm; 6556dcd011b5ec33190f268cf546a4c68f81f5ebd0Francisco Jerez}; 6656dcd011b5ec33190f268cf546a4c68f81f5ebd0Francisco Jerez 67bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerezstruct nouveau_context { 68f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg struct gl_context base; 69bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez __DRIcontext *dri_context; 70bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez struct nouveau_screen *screen; 71bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 72bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez BITSET_DECLARE(dirty, MAX_NOUVEAU_STATE); 73bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez enum nouveau_fallback fallback; 74bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 75666004148353fa46e818772e496f6d09bd979737Ben Skeggs struct nouveau_bo *fence; 76666004148353fa46e818772e496f6d09bd979737Ben Skeggs 7756dcd011b5ec33190f268cf546a4c68f81f5ebd0Francisco Jerez struct nouveau_hw_state hw; 78bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez struct nouveau_render_state render; 79f2098e0fefbbcd72df4c8283d195beae4a113f35Francisco Jerez struct nouveau_scratch_state scratch; 80065163bcd2df12494ca523538736282fc847fa6bFrancisco Jerez 81065163bcd2df12494ca523538736282fc847fa6bFrancisco Jerez struct { 82065163bcd2df12494ca523538736282fc847fa6bFrancisco Jerez GLboolean clear_blocked; 83065163bcd2df12494ca523538736282fc847fa6bFrancisco Jerez int clear_seq; 84065163bcd2df12494ca523538736282fc847fa6bFrancisco Jerez } hierz; 85bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez}; 86bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 87bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#define to_nouveau_context(ctx) ((struct nouveau_context *)(ctx)) 88bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 89bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#define context_dev(ctx) \ 90bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez (to_nouveau_context(ctx)->screen->device) 91bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#define context_chipset(ctx) \ 92bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez (context_dev(ctx)->chipset) 93bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#define context_chan(ctx) \ 9456dcd011b5ec33190f268cf546a4c68f81f5ebd0Francisco Jerez (to_nouveau_context(ctx)->hw.chan) 952e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs#define context_client(ctx) \ 962e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs (to_nouveau_context(ctx)->hw.client) 972e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs#define context_push(ctx) \ 982e47d01c9e5325906cf3bb979279599991c6328eBen Skeggs (to_nouveau_context(ctx)->hw.pushbuf) 99bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#define context_eng3d(ctx) \ 10056dcd011b5ec33190f268cf546a4c68f81f5ebd0Francisco Jerez (to_nouveau_context(ctx)->hw.eng3d) 101bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#define context_drv(ctx) \ 102bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez (to_nouveau_context(ctx)->screen->driver) 103bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#define context_dirty(ctx, s) \ 104bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez BITSET_SET(to_nouveau_context(ctx)->dirty, NOUVEAU_STATE_##s) 105bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#define context_dirty_i(ctx, s, i) \ 106bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez BITSET_SET(to_nouveau_context(ctx)->dirty, NOUVEAU_STATE_##s##0 + i) 107878eef8c40046f77cf1527fef06f1ea95bd1629aFrancisco Jerez#define context_emit(ctx, s) \ 108878eef8c40046f77cf1527fef06f1ea95bd1629aFrancisco Jerez context_drv(ctx)->emit[NOUVEAU_STATE_##s](ctx, NOUVEAU_STATE_##s) 109bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 110bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco JerezGLboolean 111738cb502371097fa6fb25f397a3cbcd6a5db020cDave Airlienouveau_context_create(gl_api api, 112d3491e775fb07f891463b2185d74bbad62f3ed24Kristian Høgsberg const struct gl_config *visual, __DRIcontext *dri_ctx, 113e532b6288f01b63d8d8ba8c8dc08292967e65490Ian Romanick unsigned major_version, unsigned minor_version, 114e532b6288f01b63d8d8ba8c8dc08292967e65490Ian Romanick uint32_t flags, unsigned *error, void *share_ctx); 115bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 116bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco JerezGLboolean 117f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergnouveau_context_init(struct gl_context *ctx, struct nouveau_screen *screen, 118f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg const struct gl_config *visual, struct gl_context *share_ctx); 119bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 120bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerezvoid 121f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergnouveau_context_deinit(struct gl_context *ctx); 12256dcd011b5ec33190f268cf546a4c68f81f5ebd0Francisco Jerez 12356dcd011b5ec33190f268cf546a4c68f81f5ebd0Francisco Jerezvoid 124bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jereznouveau_context_destroy(__DRIcontext *dri_ctx); 125bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 1264a7e9b5df453055ed6eedce1ea5c1d4a2f810fa7Francisco Jerezvoid 1274a7e9b5df453055ed6eedce1ea5c1d4a2f810fa7Francisco Jereznouveau_update_renderbuffers(__DRIcontext *dri_ctx, __DRIdrawable *draw); 1284a7e9b5df453055ed6eedce1ea5c1d4a2f810fa7Francisco Jerez 129bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco JerezGLboolean 1304a7e9b5df453055ed6eedce1ea5c1d4a2f810fa7Francisco Jereznouveau_context_make_current(__DRIcontext *dri_ctx, __DRIdrawable *ddraw, 131bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez __DRIdrawable *rdraw); 132bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 133bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco JerezGLboolean 134bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jereznouveau_context_unbind(__DRIcontext *dri_ctx); 135bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 136bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerezvoid 137f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergnouveau_fallback(struct gl_context *ctx, enum nouveau_fallback mode); 138bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 139bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerezvoid 140f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergnouveau_validate_framebuffer(struct gl_context *ctx); 141bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 142bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez#endif 143bfb5dc68fcc9f5dee71f66d9499b8bdcde9627eaFrancisco Jerez 144