*/
#include <stdbool.h>
+#include <stdio.h>
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_bufferobj.h"
#include "nouveau_fbo.h"
#include "nv_object.xml.h"
+#include "main/api_exec.h"
#include "main/dd.h"
#include "main/framebuffer.h"
#include "main/fbobject.h"
#include "main/light.h"
#include "main/state.h"
#include "main/version.h"
+#include "main/vtxfmt.h"
#include "drivers/common/meta.h"
#include "drivers/common/driverfuncs.h"
#include "swrast/swrast.h"
GLboolean
nouveau_context_create(gl_api api,
const struct gl_config *visual, __DRIcontext *dri_ctx,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
+ const struct __DriverContextConfig *ctx_config,
unsigned *error,
void *share_ctx)
{
struct nouveau_context *nctx;
struct gl_context *ctx;
- switch (api) {
- case API_OPENGL_COMPAT:
- /* Do after-the-fact version checking (below).
- */
- break;
- case API_OPENGLES:
- /* NV10 and NV20 can support OpenGL ES 1.0 only. Older chips
- * cannot do even that.
- */
- if ((screen->device->chipset & 0xf0) == 0x00) {
- *error = __DRI_CTX_ERROR_BAD_API;
- return GL_FALSE;
- } else if (minor_version != 0) {
- *error = __DRI_CTX_ERROR_BAD_VERSION;
- return GL_FALSE;
- }
- break;
- case API_OPENGLES2:
- case API_OPENGL_CORE:
- *error = __DRI_CTX_ERROR_BAD_API;
- return GL_FALSE;
+ if (ctx_config->flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
+ *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+ return false;
}
- /* API and flag filtering is handled in dri2CreateContextAttribs.
- */
- (void) flags;
+ if (ctx_config->attribute_mask) {
+ *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+ return false;
+ }
- ctx = screen->driver->context_create(screen, visual, share_ctx);
+ ctx = screen->driver->context_create(screen, api, visual, share_ctx);
if (!ctx) {
*error = __DRI_CTX_ERROR_NO_MEMORY;
return GL_FALSE;
}
+ driContextSetFlags(ctx, ctx_config->flags);
+
nctx = to_nouveau_context(ctx);
nctx->dri_context = dri_ctx;
dri_ctx->driverPrivate = ctx;
_mesa_compute_version(ctx);
- if (ctx->Version < major_version * 10 + minor_version) {
+ if (ctx->Version < (ctx_config->major_version * 10 +
+ ctx_config->minor_version)) {
nouveau_context_destroy(dri_ctx);
*error = __DRI_CTX_ERROR_BAD_VERSION;
return GL_FALSE;
}
+ /* Exec table initialization requires the version to be computed */
+ _mesa_initialize_dispatch_tables(ctx);
+ _mesa_initialize_vbo_vtxfmt(ctx);
+
if (nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_VRAM, 0, 4096,
NULL, &nctx->fence)) {
nouveau_context_destroy(dri_ctx);
}
GLboolean
-nouveau_context_init(struct gl_context *ctx, struct nouveau_screen *screen,
+nouveau_context_init(struct gl_context *ctx, gl_api api,
+ struct nouveau_screen *screen,
const struct gl_config *visual, struct gl_context *share_ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
/* Initialize the function pointers. */
_mesa_init_driver_functions(&functions);
+ _tnl_init_driver_draw_function(&functions);
nouveau_driver_functions_init(&functions);
nouveau_bufferobj_functions_init(&functions);
nouveau_texture_functions_init(&functions);
nouveau_fbo_functions_init(&functions);
/* Initialize the mesa context. */
- _mesa_initialize_context(ctx, API_OPENGL_COMPAT, visual,
- share_ctx, &functions);
+ if (!_mesa_initialize_context(ctx, api, visual, share_ctx, &functions))
+ return GL_FALSE;
nouveau_state_init(ctx);
nouveau_scratch_init(ctx);
_mesa_meta_init(ctx);
_swrast_CreateContext(ctx);
- _vbo_CreateContext(ctx);
+ _vbo_CreateContext(ctx, true);
_tnl_CreateContext(ctx);
nouveau_span_functions_init(ctx);
_mesa_allow_light_in_model(ctx, GL_FALSE);
/* Enable any supported extensions. */
ctx->Extensions.EXT_blend_color = true;
ctx->Extensions.EXT_blend_minmax = true;
- ctx->Extensions.EXT_fog_coord = true;
- ctx->Extensions.EXT_framebuffer_blit = true;
- ctx->Extensions.EXT_framebuffer_object = true;
- ctx->Extensions.EXT_packed_depth_stencil = true;
- ctx->Extensions.EXT_secondary_color = true;
ctx->Extensions.EXT_texture_filter_anisotropic = true;
- ctx->Extensions.NV_blend_square = true;
ctx->Extensions.NV_texture_env_combine4 = true;
+ ctx->Const.MaxDrawBuffers = ctx->Const.MaxColorAttachments = 1;
+
+ /* This effectively disables 3D textures */
+ ctx->Const.Max3DTextureLevels = 1;
return GL_TRUE;
}
if (TNL_CONTEXT(ctx))
_tnl_DestroyContext(ctx);
- if (vbo_context(ctx))
- _vbo_DestroyContext(ctx);
+ _vbo_DestroyContext(ctx);
if (SWRAST_CONTEXT(ctx))
_swrast_DestroyContext(ctx);
attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
if (fb->Visual.doubleBufferMode)
attachments[i++] = __DRI_BUFFER_BACK_LEFT;
- if (fb->Visual.haveDepthBuffer && fb->Visual.haveStencilBuffer)
+ if (fb->Visual.depthBits > 0 && fb->Visual.stencilBits > 0)
attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
- else if (fb->Visual.haveDepthBuffer)
+ else if (fb->Visual.depthBits > 0)
attachments[i++] = __DRI_BUFFER_DEPTH;
- else if (fb->Visual.haveStencilBuffer)
+ else if (fb->Visual.stencilBits > 0)
attachments[i++] = __DRI_BUFFER_STENCIL;
- buffers = (*screen->dri2.loader->getBuffers)(draw, &draw->w, &draw->h,
- attachments, i, &count,
- draw->loaderPrivate);
+ buffers = screen->dri2.loader->getBuffers(draw, &draw->w, &draw->h,
+ attachments, i, &count,
+ draw->loaderPrivate);
if (buffers == NULL)
return;