classic/nouveau: Remove driver

This will now only be available in the Amber branch

Reviewed-by: Emma Anholt <emma@anholt.net>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10153>
This commit is contained in:
Dylan Baker 2021-04-09 09:51:38 -07:00 committed by Marge Bot
parent 184a690fca
commit f464871932
71 changed files with 7 additions and 18904 deletions

View File

@ -825,7 +825,7 @@ fedora-release:
-Wno-error=uninitialized
CPP_ARGS: >
-Wno-error=array-bounds
DRI_DRIVERS: "nouveau,i915,i965"
DRI_DRIVERS: "i915,i965"
DRI_LOADERS: >
-D glx=dri
-D gbm=enabled
@ -1118,7 +1118,7 @@ debian-i386:
CROSS: i386
VULKAN_DRIVERS: intel,amd,swrast,virtio-experimental
GALLIUM_DRIVERS: "iris,nouveau,r300,r600,radeonsi,swrast,virgl,zink,crocus"
DRI_DRIVERS: "i915,i965,nouveau"
DRI_DRIVERS: "i915,i965"
EXTRA_OPTION: >
-D vulkan-layers=device-select,overlay

View File

@ -178,11 +178,9 @@ if dri_drivers.contains('auto')
if system_has_kms_drm
# TODO: PPC, Sparc
if ['x86', 'x86_64'].contains(host_machine.cpu_family())
dri_drivers = ['i915', 'i965', 'nouveau']
elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
dri_drivers = ['i915', 'i965']
elif ['arm', 'aarch64', 'mips', 'mips64'].contains(host_machine.cpu_family())
dri_drivers = []
elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
dri_drivers = ['nouveau']
else
error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
host_machine.cpu_family()))
@ -198,7 +196,6 @@ endif
with_dri_i915 = dri_drivers.contains('i915')
with_dri_i965 = dri_drivers.contains('i965')
with_dri_nouveau = dri_drivers.contains('nouveau')
with_dri = dri_drivers.length() != 0
@ -1597,7 +1594,7 @@ _libdrm_checks = [
['intel', with_dri_i915 or with_gallium_i915],
['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi],
['radeon', (with_gallium_radeonsi or with_gallium_r300 or with_gallium_r600)],
['nouveau', (with_gallium_nouveau or with_dri_nouveau)],
['nouveau', with_gallium_nouveau],
]
# Loop over the enables versions and get the highest libdrm requirement for all

View File

@ -55,7 +55,7 @@ option(
'dri-drivers',
type : 'array',
value : ['auto'],
choices : ['auto', 'i915', 'i965', 'nouveau'],
choices : ['auto', 'i915', 'i965'],
description : 'List of dri drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
)
option(

View File

@ -51,7 +51,7 @@ endif
libloader = static_library(
'loader',
['loader_dri_helper.c', 'loader.c', 'pci_id_driver_map.c'],
['loader_dri_helper.c', 'loader.c'],
c_args : loader_c_args,
gnu_symbol_visibility : 'hidden',
include_directories : [inc_include, inc_src, inc_util],

View File

@ -1,59 +0,0 @@
/*
* Copyright 2014 Ilia Mirkin
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <stdbool.h>
bool is_nouveau_vieux(int fd);
#ifdef HAVE_LIBDRM
#include <stdlib.h>
#include <xf86drm.h>
#include <nouveau_drm.h>
static int
nouveau_chipset(int fd)
{
struct drm_nouveau_getparam gp = { NOUVEAU_GETPARAM_CHIPSET_ID, 0 };
int ret;
ret = drmCommandWriteRead(fd, DRM_NOUVEAU_GETPARAM, &gp, sizeof(gp));
if (ret)
return -1;
return gp.value;
}
bool
is_nouveau_vieux(int fd)
{
int chipset = nouveau_chipset(fd);
return (chipset > 0 && chipset < 0x30) ||
(chipset < 0x40 && getenv("NOUVEAU_VIEUX") != NULL);
}
#else
bool is_nouveau_vieux(int fd) { return false; }
#endif

View File

@ -56,7 +56,6 @@ static const int vmwgfx_chip_ids[] = {
#undef CHIPSET
};
bool is_nouveau_vieux(int fd);
bool is_kernel_i915(int fd);
static const struct {
@ -74,7 +73,6 @@ static const struct {
{ 0x1002, "r300", r300_chip_ids, ARRAY_SIZE(r300_chip_ids) },
{ 0x1002, "r600", r600_chip_ids, ARRAY_SIZE(r600_chip_ids) },
{ 0x1002, "radeonsi", NULL, -1 },
{ 0x10de, "nouveau_vieux", NULL, -1, is_nouveau_vieux },
{ 0x10de, "nouveau", NULL, -1, },
{ 0x1af4, "virtio_gpu", virtio_gpu_chip_ids, ARRAY_SIZE(virtio_gpu_chip_ids) },
{ 0x15ad, "vmwgfx", vmwgfx_chip_ids, ARRAY_SIZE(vmwgfx_chip_ids) },

View File

@ -33,11 +33,6 @@ if with_dri_i965
_dri_drivers += libi965
_dri_link += 'i965_dri.so'
endif
if with_dri_nouveau
subdir('nouveau')
_dri_drivers += libnouveau_vieux
_dri_link += 'nouveau_vieux_dri.so'
endif
if _dri_drivers != []
libmesa_dri_drivers = shared_library(

View File

@ -1,8 +0,0 @@
((prog-mode
(indent-tabs-mode . t)
(tab-width . 8)
(c-basic-offset . 8)
(c-file-style . "stroustrup")
(fill-column . 78)
)
)

View File

@ -1,2 +0,0 @@
[*.{c,h}]
indent_style = tab

View File

@ -1,88 +0,0 @@
# Copyright © 2017 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
files_nouveau_vieux = files(
'nouveau_array.c',
'nouveau_array.h',
'nouveau_bufferobj.c',
'nouveau_bufferobj.h',
'nouveau_context.c',
'nouveau_context.h',
'nouveau_driver.c',
'nouveau_driver.h',
'nouveau_fbo.c',
'nouveau_fbo.h',
'nouveau_gldefs.h',
'nouveau_local.h',
'nouveau_render.h',
'nouveau_scratch.c',
'nouveau_scratch.h',
'nouveau_screen.c',
'nouveau_screen.h',
'nouveau_span.c',
'nouveau_state.c',
'nouveau_state.h',
'nouveau_surface.c',
'nouveau_surface.h',
'nouveau_texture.c',
'nouveau_texture.h',
'nouveau_util.h',
'nv01_2d.xml.h',
'nv04_3d.xml.h',
'nv04_context.c',
'nv04_context.h',
'nv04_driver.h',
'nv04_render.c',
'nv04_state_fb.c',
'nv04_state_frag.c',
'nv04_state_raster.c',
'nv04_state_tex.c',
'nv04_surface.c',
'nv10_3d.xml.h',
'nv10_context.c',
'nv10_driver.h',
'nv10_render.c',
'nv10_state_fb.c',
'nv10_state_frag.c',
'nv10_state_polygon.c',
'nv10_state_raster.c',
'nv10_state_tex.c',
'nv10_state_tnl.c',
'nv20_3d.xml.h',
'nv20_context.c',
'nv20_driver.h',
'nv20_render.c',
'nv20_state_fb.c',
'nv20_state_frag.c',
'nv20_state_polygon.c',
'nv20_state_raster.c',
'nv20_state_tex.c',
'nv20_state_tnl.c',
'nv_m2mf.xml.h',
'nv_object.xml.h',
)
libnouveau_vieux = static_library(
'nouveau_vieux',
files_nouveau_vieux,
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_dri_common, inc_util],
gnu_symbol_visibility : 'hidden',
dependencies : [dep_libdrm, dep_libdrm_nouveau, idep_mesautil],
)

View File

@ -1,154 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "main/bufferobj.h"
#include "nouveau_driver.h"
#include "nouveau_array.h"
#include "nouveau_bufferobj.h"
#include "nouveau_context.h"
#define EXTRACT(in_t, out_t) extract_func_##in_t##_to_##out_t
#define EXTRACT_FUNC(in_t, out_t, k) \
static out_t EXTRACT(in_t, out_t) \
(struct nouveau_array *a, int i, int j) { \
in_t x = ((in_t *)(a->buf + i * a->stride))[j]; \
\
return (out_t)x / (k); \
}
EXTRACT_FUNC(GLchar, unsigned, 1);
EXTRACT_FUNC(GLchar, float, SCHAR_MAX);
EXTRACT_FUNC(GLubyte, unsigned, 1);
EXTRACT_FUNC(GLubyte, float, UCHAR_MAX);
EXTRACT_FUNC(GLshort, unsigned, 1);
EXTRACT_FUNC(GLshort, float, SHRT_MAX);
EXTRACT_FUNC(GLushort, unsigned, 1);
EXTRACT_FUNC(GLushort, float, USHRT_MAX);
EXTRACT_FUNC(GLint, unsigned, 1);
EXTRACT_FUNC(GLint, float, INT_MAX);
EXTRACT_FUNC(GLuint, unsigned, 1);
EXTRACT_FUNC(GLuint, float, UINT_MAX);
EXTRACT_FUNC(GLfloat, unsigned, 1.0 / UINT_MAX);
EXTRACT_FUNC(GLfloat, float, 1);
#undef EXTRACT_FUNC
static void
get_array_extract(struct nouveau_array *a, extract_u_t *extract_u,
extract_f_t *extract_f)
{
switch (a->type) {
case GL_BYTE:
*extract_u = EXTRACT(GLchar, unsigned);
*extract_f = EXTRACT(GLchar, float);
break;
case GL_UNSIGNED_BYTE:
*extract_u = EXTRACT(GLubyte, unsigned);
*extract_f = EXTRACT(GLubyte, float);
break;
case GL_SHORT:
*extract_u = EXTRACT(GLshort, unsigned);
*extract_f = EXTRACT(GLshort, float);
break;
case GL_UNSIGNED_SHORT:
*extract_u = EXTRACT(GLushort, unsigned);
*extract_f = EXTRACT(GLushort, float);
break;
case GL_INT:
*extract_u = EXTRACT(GLint, unsigned);
*extract_f = EXTRACT(GLint, float);
break;
case GL_UNSIGNED_INT:
*extract_u = EXTRACT(GLuint, unsigned);
*extract_f = EXTRACT(GLuint, float);
break;
case GL_FLOAT:
*extract_u = EXTRACT(GLfloat, unsigned);
*extract_f = EXTRACT(GLfloat, float);
break;
default:
assert(0);
}
}
#undef EXTRACT
void
nouveau_init_array(struct nouveau_array *a, int attr, int stride,
int fields, int type, struct gl_buffer_object *obj,
const void *ptr, GLboolean map, struct gl_context *ctx)
{
struct nouveau_client *client = context_client(ctx);
a->attr = attr;
a->stride = stride;
a->fields = fields;
a->type = type;
a->buf = NULL;
if (nouveau_bufferobj_hw(obj)) {
struct nouveau_bufferobj *nbo =
to_nouveau_bufferobj(obj);
nouveau_bo_ref(nbo->bo, &a->bo);
a->offset = (intptr_t)ptr;
if (map) {
nouveau_bo_map(a->bo, NOUVEAU_BO_RD, client);
a->buf = a->bo->map + a->offset;
}
} else {
nouveau_bo_ref(NULL, &a->bo);
a->offset = 0;
if (map) {
if (obj) {
a->buf = ADD_POINTERS(
nouveau_bufferobj_sys(obj), ptr);
} else {
a->buf = ptr;
}
}
}
if (a->buf)
get_array_extract(a, &a->extract_u, &a->extract_f);
}
void
nouveau_deinit_array(struct nouveau_array *a)
{
a->buf = NULL;
a->fields = 0;
}
void
nouveau_cleanup_array(struct nouveau_array *a)
{
nouveau_deinit_array(a);
nouveau_bo_ref(NULL, &a->bo);
}

View File

@ -1,58 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_ARRAY_H__
#define __NOUVEAU_ARRAY_H__
struct nouveau_array;
typedef unsigned (*extract_u_t)(struct nouveau_array *, int, int);
typedef float (*extract_f_t)(struct nouveau_array *, int, int);
struct nouveau_array {
int attr;
int stride, fields, type;
struct nouveau_bo *bo;
unsigned offset;
const void *buf;
extract_u_t extract_u;
extract_f_t extract_f;
};
void
nouveau_init_array(struct nouveau_array *a, int attr, int stride,
int fields, int type, struct gl_buffer_object *obj,
const void *ptr, GLboolean map, struct gl_context *ctx);
void
nouveau_deinit_array(struct nouveau_array *a);
void
nouveau_cleanup_array(struct nouveau_array *a);
#endif

View File

@ -1,183 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_bufferobj.h"
#include "nouveau_context.h"
#include "main/bufferobj.h"
#include "util/u_memory.h"
static inline char *
get_bufferobj_map(struct gl_context *ctx, struct gl_buffer_object *obj,
unsigned flags)
{
struct nouveau_bufferobj *nbo = to_nouveau_bufferobj(obj);
void *map = NULL;
if (nbo->sys) {
map = nbo->sys;
} else if (nbo->bo) {
nouveau_bo_map(nbo->bo, flags, context_client(ctx));
map = nbo->bo->map;
}
return map;
}
static struct gl_buffer_object *
nouveau_bufferobj_new(struct gl_context *ctx, GLuint buffer)
{
struct nouveau_bufferobj *nbo;
nbo = CALLOC_STRUCT(nouveau_bufferobj);
if (!nbo)
return NULL;
_mesa_initialize_buffer_object(ctx, &nbo->base, buffer);
return &nbo->base;
}
static void
nouveau_bufferobj_del(struct gl_context *ctx, struct gl_buffer_object *obj)
{
struct nouveau_bufferobj *nbo = to_nouveau_bufferobj(obj);
nouveau_bo_ref(NULL, &nbo->bo);
free(nbo->sys);
free(nbo);
}
static GLboolean
nouveau_bufferobj_data(struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
const GLvoid *data, GLenum usage, GLbitfield storageFlags,
struct gl_buffer_object *obj)
{
struct nouveau_bufferobj *nbo = to_nouveau_bufferobj(obj);
int ret;
obj->Size = size;
obj->Usage = usage;
obj->StorageFlags = storageFlags;
/* Free previous storage */
nouveau_bo_ref(NULL, &nbo->bo);
free(nbo->sys);
nbo->sys = NULL;
if (target == GL_ELEMENT_ARRAY_BUFFER_ARB ||
(size < 512 && usage == GL_DYNAMIC_DRAW_ARB) ||
context_chipset(ctx) < 0x10) {
/* Heuristic: keep it in system ram */
nbo->sys = malloc(size);
} else {
/* Get a hardware BO */
ret = nouveau_bo_new(context_dev(ctx),
NOUVEAU_BO_GART | NOUVEAU_BO_MAP,
ctx->Const.MinMapBufferAlignment,
size, NULL, &nbo->bo);
assert(!ret);
}
if (data)
memcpy(get_bufferobj_map(ctx, obj, NOUVEAU_BO_WR), data, size);
return GL_TRUE;
}
static void
nouveau_bufferobj_subdata(struct gl_context *ctx, GLintptrARB offset,
GLsizeiptrARB size, const GLvoid *data,
struct gl_buffer_object *obj)
{
memcpy(get_bufferobj_map(ctx, obj, NOUVEAU_BO_WR) + offset, data, size);
}
static void
nouveau_bufferobj_get_subdata(struct gl_context *ctx, GLintptrARB offset,
GLsizeiptrARB size, GLvoid *data,
struct gl_buffer_object *obj)
{
memcpy(data, get_bufferobj_map(ctx, obj, NOUVEAU_BO_RD) + offset, size);
}
static void *
nouveau_bufferobj_map_range(struct gl_context *ctx, GLintptr offset,
GLsizeiptr length, GLbitfield access,
struct gl_buffer_object *obj,
gl_map_buffer_index index)
{
unsigned flags = 0;
char *map;
assert(!obj->Mappings[index].Pointer);
if (!(access & GL_MAP_UNSYNCHRONIZED_BIT)) {
if (access & GL_MAP_READ_BIT)
flags |= NOUVEAU_BO_RD;
if (access & GL_MAP_WRITE_BIT)
flags |= NOUVEAU_BO_WR;
}
map = get_bufferobj_map(ctx, obj, flags);
if (!map)
return NULL;
obj->Mappings[index].Pointer = map + offset;
obj->Mappings[index].Offset = offset;
obj->Mappings[index].Length = length;
obj->Mappings[index].AccessFlags = access;
return obj->Mappings[index].Pointer;
}
static GLboolean
nouveau_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj,
gl_map_buffer_index index)
{
assert(obj->Mappings[index].Pointer);
obj->Mappings[index].Pointer = NULL;
obj->Mappings[index].Offset = 0;
obj->Mappings[index].Length = 0;
obj->Mappings[index].AccessFlags = 0;
return GL_TRUE;
}
void
nouveau_bufferobj_functions_init(struct dd_function_table *functions)
{
functions->NewBufferObject = nouveau_bufferobj_new;
functions->DeleteBuffer = nouveau_bufferobj_del;
functions->BufferData = nouveau_bufferobj_data;
functions->BufferSubData = nouveau_bufferobj_subdata;
functions->GetBufferSubData = nouveau_bufferobj_get_subdata;
functions->MapBufferRange = nouveau_bufferobj_map_range;
functions->UnmapBuffer = nouveau_bufferobj_unmap;
}

View File

@ -1,46 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_BUFFEROBJ_H__
#define __NOUVEAU_BUFFEROBJ_H__
struct nouveau_bufferobj {
struct gl_buffer_object base;
struct nouveau_bo *bo;
void *sys;
};
#define to_nouveau_bufferobj(x) ((struct nouveau_bufferobj *)(x))
#define nouveau_bufferobj_hw(x) \
(x ? to_nouveau_bufferobj(x)->bo : NULL)
#define nouveau_bufferobj_sys(x) \
(x ? to_nouveau_bufferobj(x)->sys : NULL)
void
nouveau_bufferobj_functions_init(struct dd_function_table *functions);
#endif

View File

@ -1,428 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#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"
#include "swrast/s_context.h"
#include "vbo/vbo.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
GLboolean
nouveau_context_create(gl_api api,
const struct gl_config *visual, __DRIcontext *dri_ctx,
const struct __DriverContextConfig *ctx_config,
unsigned *error,
void *share_ctx)
{
__DRIscreen *dri_screen = dri_ctx->driScreenPriv;
struct nouveau_screen *screen = dri_screen->driverPrivate;
struct nouveau_context *nctx;
struct gl_context *ctx;
if (ctx_config->flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return false;
}
if (ctx_config->attribute_mask) {
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return false;
}
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 < (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);
*error = __DRI_CTX_ERROR_NO_MEMORY;
return GL_FALSE;
}
*error = __DRI_CTX_ERROR_SUCCESS;
return GL_TRUE;
}
GLboolean
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);
struct dd_function_table functions;
int ret;
nctx->screen = screen;
nctx->fallback = HWTNL;
/* 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. */
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, true);
_tnl_CreateContext(ctx);
nouveau_span_functions_init(ctx);
_mesa_allow_light_in_model(ctx, GL_FALSE);
/* Allocate a hardware channel. */
ret = nouveau_object_new(&context_dev(ctx)->object, 0xbeef0000,
NOUVEAU_FIFO_CHANNEL_CLASS,
&(struct nv04_fifo){
.vram = 0xbeef0201,
.gart = 0xbeef0202
}, sizeof(struct nv04_fifo), &nctx->hw.chan);
if (ret) {
nouveau_error("Error initializing the FIFO.\n");
return GL_FALSE;
}
/* Allocate a client (thread data) */
ret = nouveau_client_new(context_dev(ctx), &nctx->hw.client);
if (ret) {
nouveau_error("Error creating thread data\n");
return GL_FALSE;
}
/* Allocate a push buffer */
ret = nouveau_pushbuf_new(nctx->hw.client, nctx->hw.chan, 4,
512 * 1024, true, &nctx->hw.pushbuf);
if (ret) {
nouveau_error("Error allocating DMA push buffer\n");
return GL_FALSE;
}
/* Allocate buffer context */
ret = nouveau_bufctx_new(nctx->hw.client, 16, &nctx->hw.bufctx);
if (ret) {
nouveau_error("Error allocating buffer context\n");
return GL_FALSE;
}
nctx->hw.pushbuf->user_priv = nctx->hw.bufctx;
/* Allocate NULL object */
ret = nouveau_object_new(nctx->hw.chan, 0x00000000, NV01_NULL_CLASS,
NULL, 0, &nctx->hw.null);
if (ret) {
nouveau_error("Error allocating NULL object\n");
return GL_FALSE;
}
/* Enable any supported extensions. */
ctx->Extensions.EXT_blend_color = true;
ctx->Extensions.EXT_blend_minmax = true;
ctx->Extensions.EXT_texture_filter_anisotropic = 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;
}
void
nouveau_context_deinit(struct gl_context *ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
if (TNL_CONTEXT(ctx))
_tnl_DestroyContext(ctx);
_vbo_DestroyContext(ctx);
if (SWRAST_CONTEXT(ctx))
_swrast_DestroyContext(ctx);
if (ctx->Meta)
_mesa_meta_free(ctx);
nouveau_bufctx_del(&nctx->hw.bufctx);
nouveau_pushbuf_del(&nctx->hw.pushbuf);
nouveau_client_del(&nctx->hw.client);
nouveau_object_del(&nctx->hw.chan);
nouveau_scratch_destroy(ctx);
_mesa_free_context_data(ctx, true);
}
void
nouveau_context_destroy(__DRIcontext *dri_ctx)
{
struct nouveau_context *nctx = dri_ctx->driverPrivate;
struct gl_context *ctx = &nctx->base;
nouveau_bo_ref(NULL, &nctx->fence);
context_drv(ctx)->context_destroy(ctx);
}
void
nouveau_update_renderbuffers(__DRIcontext *dri_ctx, __DRIdrawable *draw)
{
struct gl_context *ctx = dri_ctx->driverPrivate;
struct nouveau_context *nctx = to_nouveau_context(ctx);
__DRIscreen *screen = dri_ctx->driScreenPriv;
struct gl_framebuffer *fb = draw->driverPrivate;
struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb);
unsigned int attachments[__DRI_BUFFER_COUNT];
__DRIbuffer *buffers = NULL;
int i = 0, count, ret;
if (draw->lastStamp == draw->dri2.stamp)
return;
draw->lastStamp = draw->dri2.stamp;
if (nfb->need_front)
attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
if (fb->Visual.doubleBufferMode)
attachments[i++] = __DRI_BUFFER_BACK_LEFT;
if (fb->Visual.depthBits > 0 && fb->Visual.stencilBits > 0)
attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
else if (fb->Visual.depthBits > 0)
attachments[i++] = __DRI_BUFFER_DEPTH;
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);
if (buffers == NULL)
return;
for (i = 0; i < count; i++) {
struct gl_renderbuffer *rb;
struct nouveau_surface *s;
uint32_t old_name;
int index;
switch (buffers[i].attachment) {
case __DRI_BUFFER_FRONT_LEFT:
case __DRI_BUFFER_FAKE_FRONT_LEFT:
index = BUFFER_FRONT_LEFT;
break;
case __DRI_BUFFER_BACK_LEFT:
index = BUFFER_BACK_LEFT;
break;
case __DRI_BUFFER_DEPTH:
case __DRI_BUFFER_DEPTH_STENCIL:
index = BUFFER_DEPTH;
break;
case __DRI_BUFFER_STENCIL:
index = BUFFER_STENCIL;
break;
default:
assert(0);
}
rb = fb->Attachment[index].Renderbuffer;
s = &to_nouveau_renderbuffer(rb)->surface;
s->width = draw->w;
s->height = draw->h;
s->pitch = buffers[i].pitch;
s->cpp = buffers[i].cpp;
if (index == BUFFER_DEPTH && s->bo) {
ret = nouveau_bo_name_get(s->bo, &old_name);
/*
* Disable fast Z clears in the next frame, the
* depth buffer contents are undefined.
*/
if (!ret && old_name != buffers[i].name)
nctx->hierz.clear_seq = 0;
}
nouveau_bo_ref(NULL, &s->bo);
ret = nouveau_bo_name_ref(context_dev(ctx),
buffers[i].name, &s->bo);
assert(!ret);
}
_mesa_resize_framebuffer(ctx, fb, draw->w, draw->h);
}
static void
update_framebuffer(__DRIcontext *dri_ctx, __DRIdrawable *draw,
int *stamp)
{
struct gl_context *ctx = dri_ctx->driverPrivate;
struct gl_framebuffer *fb = draw->driverPrivate;
*stamp = draw->dri2.stamp;
nouveau_update_renderbuffers(dri_ctx, draw);
_mesa_resize_framebuffer(ctx, fb, draw->w, draw->h);
/* Clean up references to the old framebuffer objects. */
context_dirty(ctx, FRAMEBUFFER);
nouveau_bufctx_reset(to_nouveau_context(ctx)->hw.bufctx, BUFCTX_FB);
PUSH_KICK(context_push(ctx));
}
GLboolean
nouveau_context_make_current(__DRIcontext *dri_ctx, __DRIdrawable *dri_draw,
__DRIdrawable *dri_read)
{
if (dri_ctx) {
struct nouveau_context *nctx = dri_ctx->driverPrivate;
struct gl_context *ctx = &nctx->base;
/* Ask the X server for new renderbuffers. */
if (dri_draw->driverPrivate != ctx->WinSysDrawBuffer)
update_framebuffer(dri_ctx, dri_draw,
&dri_ctx->dri2.draw_stamp);
if (dri_draw != dri_read &&
dri_read->driverPrivate != ctx->WinSysReadBuffer)
update_framebuffer(dri_ctx, dri_read,
&dri_ctx->dri2.read_stamp);
/* Pass it down to mesa. */
_mesa_make_current(ctx, dri_draw->driverPrivate,
dri_read->driverPrivate);
_mesa_update_state(ctx);
} else {
_mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
}
GLboolean
nouveau_context_unbind(__DRIcontext *dri_ctx)
{
/* Unset current context and dispatch table */
_mesa_make_current(NULL, NULL, NULL);
return GL_TRUE;
}
void
nouveau_fallback(struct gl_context *ctx, enum nouveau_fallback mode)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
nctx->fallback = MAX2(HWTNL, mode);
if (mode < SWRAST) {
nouveau_state_emit(ctx);
#if 0
nouveau_bo_state_emit(ctx);
#endif
} else {
PUSH_KICK(context_push(ctx));
}
}
static void
validate_framebuffer(__DRIcontext *dri_ctx, __DRIdrawable *draw,
int *stamp)
{
struct gl_framebuffer *fb = draw->driverPrivate;
struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb);
GLboolean need_front =
(fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT ||
fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT);
if (nfb->need_front != need_front) {
nfb->need_front = need_front;
dri2InvalidateDrawable(draw);
}
if (draw->dri2.stamp != *stamp)
update_framebuffer(dri_ctx, draw, stamp);
}
void
nouveau_validate_framebuffer(struct gl_context *ctx)
{
__DRIcontext *dri_ctx = to_nouveau_context(ctx)->dri_context;
__DRIdrawable *dri_draw = dri_ctx->driDrawablePriv;
__DRIdrawable *dri_read = dri_ctx->driReadablePriv;
if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
validate_framebuffer(dri_ctx, dri_draw,
&dri_ctx->dri2.draw_stamp);
if (_mesa_is_winsys_fbo(ctx->ReadBuffer))
validate_framebuffer(dri_ctx, dri_read,
&dri_ctx->dri2.read_stamp);
if (ctx->NewState & _NEW_BUFFERS)
_mesa_update_state(ctx);
}

View File

@ -1,144 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_CONTEXT_H__
#define __NOUVEAU_CONTEXT_H__
#include "nouveau_screen.h"
#include "nouveau_state.h"
#include "nouveau_scratch.h"
#include "nouveau_render.h"
#include "util/bitset.h"
enum nouveau_fallback {
HWTNL = 0,
SWTNL,
SWRAST,
};
#define BUFCTX_FB 0
#define BUFCTX_VTX 1
#define BUFCTX_TEX(i) (2 + (i))
struct nouveau_hw_state {
struct nouveau_object *chan;
struct nouveau_client *client;
struct nouveau_pushbuf *pushbuf;
struct nouveau_bufctx *bufctx;
struct nouveau_object *null;
struct nouveau_object *ntfy;
struct nouveau_object *eng3d;
struct nouveau_object *eng3dm;
struct nouveau_object *surf3d;
struct nouveau_object *m2mf;
struct nouveau_object *surf2d;
struct nouveau_object *rop;
struct nouveau_object *patt;
struct nouveau_object *rect;
struct nouveau_object *swzsurf;
struct nouveau_object *sifm;
};
struct nouveau_context {
struct gl_context base;
__DRIcontext *dri_context;
struct nouveau_screen *screen;
BITSET_DECLARE(dirty, MAX_NOUVEAU_STATE);
enum nouveau_fallback fallback;
struct nouveau_bo *fence;
struct nouveau_hw_state hw;
struct nouveau_render_state render;
struct nouveau_scratch_state scratch;
struct {
GLboolean clear_blocked;
int clear_seq;
} hierz;
};
#define to_nouveau_context(ctx) ((struct nouveau_context *)(ctx))
#define context_dev(ctx) \
(to_nouveau_context(ctx)->screen->device)
#define context_chipset(ctx) \
(context_dev(ctx)->chipset)
#define context_chan(ctx) \
(to_nouveau_context(ctx)->hw.chan)
#define context_client(ctx) \
(to_nouveau_context(ctx)->hw.client)
#define context_push(ctx) \
(to_nouveau_context(ctx)->hw.pushbuf)
#define context_eng3d(ctx) \
(to_nouveau_context(ctx)->hw.eng3d)
#define context_drv(ctx) \
(to_nouveau_context(ctx)->screen->driver)
#define context_dirty(ctx, s) \
BITSET_SET(to_nouveau_context(ctx)->dirty, NOUVEAU_STATE_##s)
#define context_dirty_i(ctx, s, i) \
BITSET_SET(to_nouveau_context(ctx)->dirty, NOUVEAU_STATE_##s##0 + i)
#define context_emit(ctx, s) \
context_drv(ctx)->emit[NOUVEAU_STATE_##s](ctx, NOUVEAU_STATE_##s)
GLboolean
nouveau_context_create(gl_api api,
const struct gl_config *visual, __DRIcontext *dri_ctx,
const struct __DriverContextConfig *ctx_config,
unsigned *error, void *share_ctx);
GLboolean
nouveau_context_init(struct gl_context *ctx, gl_api api,
struct nouveau_screen *screen,
const struct gl_config *visual, struct gl_context *share_ctx);
void
nouveau_context_deinit(struct gl_context *ctx);
void
nouveau_context_destroy(__DRIcontext *dri_ctx);
void
nouveau_update_renderbuffers(__DRIcontext *dri_ctx, __DRIdrawable *draw);
GLboolean
nouveau_context_make_current(__DRIcontext *dri_ctx, __DRIdrawable *ddraw,
__DRIdrawable *rdraw);
GLboolean
nouveau_context_unbind(__DRIcontext *dri_ctx);
void
nouveau_fallback(struct gl_context *ctx, enum nouveau_fallback mode);
void
nouveau_validate_framebuffer(struct gl_context *ctx);
#endif

View File

@ -1,182 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <stdio.h>
#include "main/mtypes.h"
#include "main/fbobject.h"
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_fbo.h"
#include "nouveau_util.h"
#include "drivers/common/meta.h"
const char * const nouveau_vendor_string = "Nouveau";
const char *
nouveau_get_renderer_string(unsigned chipset)
{
char hardware_name[32];
static char buffer[128];
snprintf(hardware_name, sizeof(hardware_name), "nv%02X", chipset);
driGetRendererString(buffer, hardware_name, 0);
return buffer;
}
static const GLubyte *
nouveau_get_string(struct gl_context *ctx, GLenum name)
{
switch (name) {
case GL_VENDOR:
return (GLubyte *)nouveau_vendor_string;
case GL_RENDERER:
return (GLubyte *)nouveau_get_renderer_string(context_chipset(ctx));
default:
return NULL;
}
}
static void
nouveau_flush(struct gl_context *ctx, unsigned gallium_flush_flags)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
PUSH_KICK(push);
if (_mesa_is_winsys_fbo(ctx->DrawBuffer) &&
ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
__DRIscreen *screen = nctx->screen->dri_screen;
const __DRIdri2LoaderExtension *dri2 = screen->dri2.loader;
__DRIdrawable *drawable = nctx->dri_context->driDrawablePriv;
if (drawable && drawable->loaderPrivate)
dri2->flushFrontBuffer(drawable, drawable->loaderPrivate);
}
}
static void
nouveau_finish(struct gl_context *ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_pushbuf_refn refn =
{ nctx->fence, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR };
nouveau_flush(ctx, 0);
if (!nouveau_pushbuf_space(push, 16, 0, 0) &&
!nouveau_pushbuf_refn(push, &refn, 1)) {
PUSH_DATA(push, 0);
PUSH_KICK(push);
}
nouveau_bo_wait(nctx->fence, NOUVEAU_BO_RDWR, context_client(ctx));
}
void
nouveau_clear(struct gl_context *ctx, GLbitfield buffers)
{
struct gl_framebuffer *fb = ctx->DrawBuffer;
int x, y, w, h;
int i, buf;
nouveau_validate_framebuffer(ctx);
get_scissors(fb, &x, &y, &w, &h);
for (i = 0; i < BUFFER_COUNT; i++) {
struct nouveau_surface *s;
unsigned mask, value;
buf = buffers & (1 << i);
if (!buf)
continue;
s = &to_nouveau_renderbuffer(
fb->Attachment[i].Renderbuffer)->surface;
if (buf & BUFFER_BITS_COLOR) {
const float *color = ctx->Color.ClearColor.f;
if (fb->Attachment[i].Renderbuffer->_BaseFormat ==
GL_LUMINANCE_ALPHA)
value = pack_la_clamp_f(
s->format, color[0], color[3]);
else
value = pack_rgba_clamp_f(s->format, color);
const uint8_t colormask[4] = {
GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0) ? 0xff : 0,
GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1) ? 0xff : 0,
GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2) ? 0xff : 0,
GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3) ? 0xff : 0,
};
mask = pack_rgba_i(s->format, colormask);
if (mask)
context_drv(ctx)->surface_fill(
ctx, s, mask, value, x, y, w, h);
buffers &= ~buf;
} else if (buf & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) {
mask = pack_zs_i(s->format,
(buffers & BUFFER_BIT_DEPTH &&
ctx->Depth.Mask) ? ~0 : 0,
(buffers & BUFFER_BIT_STENCIL ?
ctx->Stencil.WriteMask[0] : 0));
value = pack_zs_f(s->format,
ctx->Depth.Clear,
ctx->Stencil.Clear);
if (mask)
context_drv(ctx)->surface_fill(
ctx, s, mask, value, x, y, w, h);
buffers &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
}
}
if (buffers)
_mesa_meta_Clear(ctx, buffers);
}
void
nouveau_driver_functions_init(struct dd_function_table *functions)
{
functions->GetString = nouveau_get_string;
functions->Flush = nouveau_flush;
functions->Finish = nouveau_finish;
functions->Clear = nouveau_clear;
functions->DrawPixels = _mesa_meta_DrawPixels;
functions->CopyPixels = _mesa_meta_CopyPixels;
functions->Bitmap = _mesa_meta_Bitmap;
functions->BlitFramebuffer = _mesa_meta_and_swrast_BlitFramebuffer;
}

View File

@ -1,89 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_DRIVER_H__
#define __NOUVEAU_DRIVER_H__
#include "main/mtypes.h"
#include "main/macros.h"
#include "main/formats.h"
#include "main/state.h"
#include "utils.h"
#include "dri_util.h"
#undef NDEBUG
#include <assert.h>
#include <nouveau.h>
#include "nouveau_screen.h"
#include "nouveau_state.h"
#include "nouveau_surface.h"
#include "nouveau_local.h"
#define DRIVER_AUTHOR "Nouveau"
struct nouveau_driver {
struct gl_context *(*context_create)(struct nouveau_screen *screen,
gl_api api,
const struct gl_config *visual,
struct gl_context *share_ctx);
void (*context_destroy)(struct gl_context *ctx);
void (*surface_copy)(struct gl_context *ctx,
struct nouveau_surface *dst,
struct nouveau_surface *src,
int dx, int dy, int sx, int sy, int w, int h);
void (*surface_fill)(struct gl_context *ctx,
struct nouveau_surface *dst,
unsigned mask, unsigned value,
int dx, int dy, int w, int h);
nouveau_state_func *emit;
int num_emit;
};
#define nouveau_error(format, ...) \
fprintf(stderr, "%s: " format, __func__, ## __VA_ARGS__)
extern const char * const nouveau_vendor_string;
const char *
nouveau_get_renderer_string(unsigned chipset);
void
nouveau_clear(struct gl_context *ctx, GLbitfield buffers);
void
nouveau_span_functions_init(struct gl_context *ctx);
void
nouveau_driver_functions_init(struct dd_function_table *functions);
void
nouveau_texture_functions_init(struct dd_function_table *functions);
#endif

View File

@ -1,339 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_fbo.h"
#include "nouveau_context.h"
#include "nouveau_texture.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/fbobject.h"
#include "util/u_memory.h"
static GLboolean
set_renderbuffer_format(struct gl_renderbuffer *rb, GLenum internalFormat)
{
struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
rb->InternalFormat = internalFormat;
switch (internalFormat) {
case GL_RGB:
case GL_RGB8:
rb->_BaseFormat = GL_RGB;
rb->Format = MESA_FORMAT_B8G8R8X8_UNORM;
s->cpp = 4;
break;
case GL_RGBA:
case GL_RGBA8:
rb->_BaseFormat = GL_RGBA;
rb->Format = MESA_FORMAT_B8G8R8A8_UNORM;
s->cpp = 4;
break;
case GL_RGB5:
rb->_BaseFormat = GL_RGB;
rb->Format = MESA_FORMAT_B5G6R5_UNORM;
s->cpp = 2;
break;
case GL_DEPTH_COMPONENT16:
rb->_BaseFormat = GL_DEPTH_COMPONENT;
rb->Format = MESA_FORMAT_Z_UNORM16;
s->cpp = 2;
break;
case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT24:
case GL_STENCIL_INDEX8_EXT:
case GL_DEPTH24_STENCIL8_EXT:
rb->_BaseFormat = GL_DEPTH_STENCIL;
rb->Format = MESA_FORMAT_S8_UINT_Z24_UNORM;
s->cpp = 4;
break;
default:
return GL_FALSE;
}
s->format = rb->Format;
return GL_TRUE;
}
static GLboolean
nouveau_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat,
GLuint width, GLuint height)
{
struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
if (!set_renderbuffer_format(rb, internalFormat))
return GL_FALSE;
rb->Width = width;
rb->Height = height;
nouveau_surface_alloc(ctx, s, TILED, NOUVEAU_BO_VRAM | NOUVEAU_BO_MAP,
rb->Format, width, height);
context_dirty(ctx, FRAMEBUFFER);
return GL_TRUE;
}
static void
nouveau_renderbuffer_del(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
nouveau_surface_ref(NULL, s);
_mesa_delete_renderbuffer(ctx, rb);
}
static struct gl_renderbuffer *
nouveau_renderbuffer_new(struct gl_context *ctx, GLuint name)
{
struct gl_renderbuffer *rb;
rb = (struct gl_renderbuffer *)
CALLOC_STRUCT(nouveau_renderbuffer);
if (!rb)
return NULL;
_mesa_init_renderbuffer(rb, name);
rb->AllocStorage = nouveau_renderbuffer_storage;
rb->Delete = nouveau_renderbuffer_del;
return rb;
}
static void
nouveau_renderbuffer_map(struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLuint x, GLuint y, GLuint w, GLuint h,
GLbitfield mode,
GLubyte **out_map,
GLint *out_stride,
bool flip_y)
{
struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
GLubyte *map;
int stride;
int flags = 0;
/* driver does not support GL_FRAMEBUFFER_FLIP_Y_MESA */
assert((rb->Name == 0) == flip_y);
if (mode & GL_MAP_READ_BIT)
flags |= NOUVEAU_BO_RD;
if (mode & GL_MAP_WRITE_BIT)
flags |= NOUVEAU_BO_WR;
nouveau_bo_map(s->bo, flags, context_client(ctx));
map = s->bo->map;
stride = s->pitch;
if (rb->Name == 0) {
map += stride * (rb->Height - 1);
stride = -stride;
}
map += x * s->cpp;
map += (int)y * stride;
*out_map = map;
*out_stride = stride;
}
static void
nouveau_renderbuffer_unmap(struct gl_context *ctx,
struct gl_renderbuffer *rb)
{
}
static GLboolean
nouveau_renderbuffer_dri_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat,
GLuint width, GLuint height)
{
if (!set_renderbuffer_format(rb, internalFormat))
return GL_FALSE;
rb->Width = width;
rb->Height = height;
return GL_TRUE;
}
struct gl_renderbuffer *
nouveau_renderbuffer_dri_new(GLenum format, __DRIdrawable *drawable)
{
struct gl_renderbuffer *rb;
rb = nouveau_renderbuffer_new(NULL, 0);
if (!rb)
return NULL;
rb->AllocStorage = nouveau_renderbuffer_dri_storage;
if (!set_renderbuffer_format(rb, format)) {
nouveau_renderbuffer_del(NULL, rb);
return NULL;
}
return rb;
}
static struct gl_framebuffer *
nouveau_framebuffer_new(struct gl_context *ctx, GLuint name)
{
struct nouveau_framebuffer *nfb;
nfb = CALLOC_STRUCT(nouveau_framebuffer);
if (!nfb)
return NULL;
_mesa_initialize_user_framebuffer(&nfb->base, name);
return &nfb->base;
}
struct gl_framebuffer *
nouveau_framebuffer_dri_new(const struct gl_config *visual)
{
struct nouveau_framebuffer *nfb;
nfb = CALLOC_STRUCT(nouveau_framebuffer);
if (!nfb)
return NULL;
_mesa_initialize_window_framebuffer(&nfb->base, visual);
nfb->need_front = !visual->doubleBufferMode;
return &nfb->base;
}
static void
nouveau_bind_framebuffer(struct gl_context *ctx, GLenum target,
struct gl_framebuffer *dfb,
struct gl_framebuffer *rfb)
{
context_dirty(ctx, FRAMEBUFFER);
}
static void
nouveau_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum attachment, struct gl_renderbuffer *rb)
{
_mesa_FramebufferRenderbuffer_sw(ctx, fb, attachment, rb);
context_dirty(ctx, FRAMEBUFFER);
}
static void
nouveau_render_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
struct gl_renderbuffer *rb = att->Renderbuffer;
struct gl_texture_image *ti = rb->TexImage;
/* Update the renderbuffer fields from the texture. */
nouveau_surface_ref(&to_nouveau_teximage(ti)->surface,
&to_nouveau_renderbuffer(rb)->surface);
context_dirty(ctx, FRAMEBUFFER);
}
static void
nouveau_finish_render_texture(struct gl_context *ctx,
struct gl_renderbuffer *rb)
{
if (rb && rb->TexImage)
texture_dirty(rb->TexImage->TexObject);
}
static int
validate_format_bpp(mesa_format format)
{
switch (format) {
case MESA_FORMAT_B8G8R8X8_UNORM:
case MESA_FORMAT_B8G8R8A8_UNORM:
case MESA_FORMAT_S8_UINT_Z24_UNORM:
return 32;
case MESA_FORMAT_B5G6R5_UNORM:
case MESA_FORMAT_Z_UNORM16:
return 16;
default:
return 0;
}
}
static void
nouveau_check_framebuffer_complete(struct gl_context *ctx,
struct gl_framebuffer *fb)
{
struct gl_renderbuffer_attachment *color =
&fb->Attachment[BUFFER_COLOR0];
struct gl_renderbuffer_attachment *depth =
&fb->Attachment[BUFFER_DEPTH];
int color_bpp = 0, zeta_bpp;
if (color->Type == GL_TEXTURE) {
color_bpp = validate_format_bpp(
color->Renderbuffer->TexImage->TexFormat);
if (!color_bpp)
goto err;
}
if (depth->Type == GL_TEXTURE) {
zeta_bpp = validate_format_bpp(
depth->Renderbuffer->TexImage->TexFormat);
if (!zeta_bpp)
goto err;
/* NV04/NV05 requires same bpp-ness for color/zeta */
if (context_chipset(ctx) < 0x10 &&
color_bpp && color_bpp != zeta_bpp)
goto err;
}
return;
err:
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
return;
}
void
nouveau_fbo_functions_init(struct dd_function_table *functions)
{
functions->NewFramebuffer = nouveau_framebuffer_new;
functions->NewRenderbuffer = nouveau_renderbuffer_new;
functions->MapRenderbuffer = nouveau_renderbuffer_map;
functions->UnmapRenderbuffer = nouveau_renderbuffer_unmap;
functions->BindFramebuffer = nouveau_bind_framebuffer;
functions->FramebufferRenderbuffer = nouveau_framebuffer_renderbuffer;
functions->RenderTexture = nouveau_render_texture;
functions->FinishRenderTexture = nouveau_finish_render_texture;
functions->ValidateFramebuffer = nouveau_check_framebuffer_complete;
}

View File

@ -1,56 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_FBO_H__
#define __NOUVEAU_FBO_H__
struct nouveau_framebuffer {
struct gl_framebuffer base;
GLboolean need_front;
struct {
struct nouveau_bo *bo;
uint32_t clear_value;
} hierz;
};
#define to_nouveau_framebuffer(x) ((struct nouveau_framebuffer *)(x))
struct nouveau_renderbuffer {
struct gl_renderbuffer base;
struct nouveau_surface surface;
};
#define to_nouveau_renderbuffer(x) ((struct nouveau_renderbuffer *)(x))
struct gl_framebuffer *
nouveau_framebuffer_dri_new(const struct gl_config *visual);
struct gl_renderbuffer *
nouveau_renderbuffer_dri_new(GLenum format, __DRIdrawable *drawable);
void
nouveau_fbo_functions_init(struct dd_function_table *functions);
#endif

View File

@ -1,259 +0,0 @@
/*
* Copyright (C) 2007-2010 The Nouveau Project.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_GLDEFS_H__
#define __NOUVEAU_GLDEFS_H__
static inline unsigned
nvgl_blend_func(unsigned func)
{
switch (func) {
case GL_ZERO:
return 0x0000;
case GL_ONE:
return 0x0001;
case GL_SRC_COLOR:
return 0x0300;
case GL_ONE_MINUS_SRC_COLOR:
return 0x0301;
case GL_SRC_ALPHA:
return 0x0302;
case GL_ONE_MINUS_SRC_ALPHA:
return 0x0303;
case GL_DST_ALPHA:
return 0x0304;
case GL_ONE_MINUS_DST_ALPHA:
return 0x0305;
case GL_DST_COLOR:
return 0x0306;
case GL_ONE_MINUS_DST_COLOR:
return 0x0307;
case GL_SRC_ALPHA_SATURATE:
return 0x0308;
case GL_CONSTANT_COLOR:
return 0x8001;
case GL_ONE_MINUS_CONSTANT_COLOR:
return 0x8002;
case GL_CONSTANT_ALPHA:
return 0x8003;
case GL_ONE_MINUS_CONSTANT_ALPHA:
return 0x8004;
default:
assert(0);
}
}
static inline unsigned
nvgl_blend_eqn(unsigned eqn)
{
switch (eqn) {
case GL_FUNC_ADD:
return 0x8006;
case GL_MIN:
return 0x8007;
case GL_MAX:
return 0x8008;
case GL_FUNC_SUBTRACT:
return 0x800a;
case GL_FUNC_REVERSE_SUBTRACT:
return 0x800b;
default:
assert(0);
}
}
static inline unsigned
nvgl_comparison_op(unsigned op)
{
switch (op) {
case GL_NEVER:
return 0x0200;
case GL_LESS:
return 0x0201;
case GL_EQUAL:
return 0x0202;
case GL_LEQUAL:
return 0x0203;
case GL_GREATER:
return 0x0204;
case GL_NOTEQUAL:
return 0x0205;
case GL_GEQUAL:
return 0x0206;
case GL_ALWAYS:
return 0x0207;
default:
assert(0);
}
}
static inline unsigned
nvgl_polygon_mode(unsigned mode)
{
switch (mode) {
case GL_POINT:
return 0x1b00;
case GL_LINE:
return 0x1b01;
case GL_FILL:
return 0x1b02;
default:
assert(0);
}
}
static inline unsigned
nvgl_stencil_op(unsigned op)
{
switch (op) {
case GL_ZERO:
return 0x0000;
case GL_INVERT:
return 0x150a;
case GL_KEEP:
return 0x1e00;
case GL_REPLACE:
return 0x1e01;
case GL_INCR:
return 0x1e02;
case GL_DECR:
return 0x1e03;
case GL_INCR_WRAP_EXT:
return 0x8507;
case GL_DECR_WRAP_EXT:
return 0x8508;
default:
assert(0);
}
}
static inline unsigned
nvgl_primitive(unsigned prim)
{
switch (prim) {
case GL_POINTS:
return 0x0001;
case GL_LINES:
return 0x0002;
case GL_LINE_LOOP:
return 0x0003;
case GL_LINE_STRIP:
return 0x0004;
case GL_TRIANGLES:
return 0x0005;
case GL_TRIANGLE_STRIP:
return 0x0006;
case GL_TRIANGLE_FAN:
return 0x0007;
case GL_QUADS:
return 0x0008;
case GL_QUAD_STRIP:
return 0x0009;
case GL_POLYGON:
return 0x000a;
default:
assert(0);
}
}
static inline unsigned
nvgl_wrap_mode(unsigned wrap)
{
switch (wrap) {
case GL_REPEAT:
return 0x1;
case GL_MIRRORED_REPEAT:
return 0x2;
case GL_CLAMP:
case GL_CLAMP_TO_EDGE:
return 0x3;
case GL_CLAMP_TO_BORDER:
return 0x4;
default:
assert(0);
}
}
static inline unsigned
nvgl_wrap_mode_nv20(unsigned wrap)
{
switch (wrap) {
case GL_REPEAT:
return 0x1;
case GL_MIRRORED_REPEAT:
return 0x2;
case GL_CLAMP:
return 0x5;
case GL_CLAMP_TO_EDGE:
return 0x3;
case GL_CLAMP_TO_BORDER:
return 0x4;
default:
unreachable("Bad GL texture wrap mode");
}
}
static inline unsigned
nvgl_filter_mode(unsigned filter)
{
switch (filter) {
case GL_NEAREST:
return 0x1;
case GL_LINEAR:
return 0x2;
case GL_NEAREST_MIPMAP_NEAREST:
return 0x3;
case GL_LINEAR_MIPMAP_NEAREST:
return 0x4;
case GL_NEAREST_MIPMAP_LINEAR:
return 0x5;
case GL_LINEAR_MIPMAP_LINEAR:
return 0x6;
default:
assert(0);
}
}
static inline unsigned
nvgl_texgen_mode(unsigned mode)
{
switch (mode) {
case GL_EYE_LINEAR:
return 0x2400;
case GL_OBJECT_LINEAR:
return 0x2401;
case GL_SPHERE_MAP:
return 0x2402;
case GL_NORMAL_MAP:
return 0x8511;
case GL_REFLECTION_MAP:
return 0x8512;
default:
assert(0);
}
}
#endif

View File

@ -1,191 +0,0 @@
/*
* Copyright 2007 Nouveau Project
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __NOUVEAU_LOCAL_H__
#define __NOUVEAU_LOCAL_H__
static inline uint32_t
PUSH_AVAIL(struct nouveau_pushbuf *push)
{
return push->end - push->cur;
}
static inline int
PUSH_SPACE(struct nouveau_pushbuf *push, uint32_t size)
{
if (PUSH_AVAIL(push) < size)
return nouveau_pushbuf_space(push, size, 0, 0) == 0;
return 1;
}
static inline void
PUSH_DATA(struct nouveau_pushbuf *push, uint32_t data)
{
*push->cur++ = data;
}
static inline void
PUSH_DATAf(struct nouveau_pushbuf *push, float v)
{
union { float f; uint32_t i; } d = { .f = v };
PUSH_DATA(push, d.i);
}
static inline void
PUSH_DATAb(struct nouveau_pushbuf *push, GLboolean x)
{
PUSH_DATA(push, x ? 1 : 0);
}
static inline void
PUSH_DATAm(struct nouveau_pushbuf *push, float m[16])
{
int i, j;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
PUSH_DATAf(push, m[4*j + i]);
}
static inline void
PUSH_DATAp(struct nouveau_pushbuf *push, const void *data, uint32_t size)
{
memcpy(push->cur, data, size * 4);
push->cur += size;
}
static inline void
PUSH_RELOC(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t offset,
uint32_t flags, uint32_t vor, uint32_t tor)
{
nouveau_pushbuf_reloc(push, bo, offset, flags, vor, tor);
}
static inline void
PUSH_KICK(struct nouveau_pushbuf *push)
{
nouveau_pushbuf_kick(push, push->channel);
}
static struct nouveau_bufctx *
BUFCTX(struct nouveau_pushbuf *push)
{
return push->user_priv;
}
static inline void
PUSH_RESET(struct nouveau_pushbuf *push, int bin)
{
nouveau_bufctx_reset(BUFCTX(push), bin);
}
static inline void
PUSH_MTHDl(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
struct nouveau_bo *bo, uint32_t offset, uint32_t access)
{
nouveau_bufctx_mthd(BUFCTX(push), bin, (1 << 18) | (subc << 13) | mthd,
bo, offset, access | NOUVEAU_BO_LOW, 0, 0);
PUSH_DATA(push, bo->offset + offset);
}
static inline void
PUSH_MTHDs(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
struct nouveau_bo *bo, uint32_t data, uint32_t access,
uint32_t vor, uint32_t tor)
{
nouveau_bufctx_mthd(BUFCTX(push), bin, (1 << 18) | (subc << 13) | mthd,
bo, data, access | NOUVEAU_BO_OR, vor, tor);
if (bo->flags & NOUVEAU_BO_VRAM)
PUSH_DATA(push, data | vor);
else
PUSH_DATA(push, data | tor);
}
static inline void
PUSH_MTHD(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
struct nouveau_bo *bo, uint32_t data, uint32_t access,
uint32_t vor, uint32_t tor)
{
nouveau_bufctx_mthd(BUFCTX(push), bin, (1 << 18) | (subc << 13) | mthd,
bo, data, access | NOUVEAU_BO_OR, vor, tor);
if (access & NOUVEAU_BO_LOW)
data += bo->offset;
if (access & NOUVEAU_BO_OR) {
if (bo->flags & NOUVEAU_BO_VRAM)
data |= vor;
else
data |= tor;
}
PUSH_DATA(push, data);
}
static inline void
BEGIN_NV04(struct nouveau_pushbuf *push, int subc, int mthd, int size)
{
PUSH_SPACE(push, size + 1);
PUSH_DATA (push, 0x00000000 | (size << 18) | (subc << 13) | mthd);
}
static inline void
BEGIN_NI04(struct nouveau_pushbuf *push, int subc, int mthd, int size)
{
PUSH_SPACE(push, size + 1);
PUSH_DATA (push, 0x40000000 | (size << 18) | (subc << 13) | mthd);
}
/* subchannel assignment */
#define SUBC_M2MF(mthd) 0, (mthd)
#define NV03_M2MF(mthd) SUBC_M2MF(NV04_M2MF_##mthd)
#define SUBC_NVSW(mthd) 1, (mthd)
#define SUBC_SF2D(mthd) 2, (mthd)
#define NV04_SF2D(mthd) SUBC_SF2D(NV04_CONTEXT_SURFACES_2D_##mthd)
#define NV10_SF2D(mthd) SUBC_SF2D(NV10_CONTEXT_SURFACES_2D_##mthd)
#define SUBC_PATT(mthd) 3, (mthd)
#define NV01_PATT(mthd) SUBC_PATT(NV04_IMAGE_PATTERN_##mthd)
#define NV01_ROP(mthd) SUBC_PATT(NV03_CONTEXT_ROP_##mthd)
#define SUBC_GDI(mthd) 4, (mthd)
#define NV04_GDI(mthd) SUBC_GDI(NV04_GDI_RECTANGLE_TEXT_##mthd)
#define SUBC_SIFM(mthd) 5, (mthd)
#define NV03_SIFM(mthd) SUBC_SIFM(NV03_SCALED_IMAGE_FROM_MEMORY_##mthd)
#define NV05_SIFM(mthd) SUBC_SIFM(NV05_SCALED_IMAGE_FROM_MEMORY_##mthd)
#define SUBC_SURF(mthd) 6, (mthd)
#define NV04_SSWZ(mthd) SUBC_SURF(NV04_SWIZZLED_SURFACE_##mthd)
#define NV04_SF3D(mthd) SUBC_SURF(NV04_CONTEXT_SURFACES_3D_##mthd)
#define SUBC_3D(mthd) 7, (mthd)
#define NV04_TTRI(mthd) SUBC_3D(NV04_TEXTURED_TRIANGLE_##mthd)
#define NV04_MTRI(mthd) SUBC_3D(NV04_MULTITEX_TRIANGLE_##mthd)
#define NV10_3D(mthd) SUBC_3D(NV10_3D_##mthd)
#define NV11_3D(mthd) SUBC_3D(NV11_3D_##mthd)
#define NV17_3D(mthd) SUBC_3D(NV17_3D_##mthd)
#define NV20_3D(mthd) SUBC_3D(NV20_3D_##mthd)
#define NV25_3D(mthd) SUBC_3D(NV25_3D_##mthd)
#define NV01_SUBC(subc, mthd) SUBC_##subc((NV01_SUBCHAN_##mthd))
#define NV11_SUBC(subc, mthd) SUBC_##subc((NV11_SUBCHAN_##mthd))
#define NV04_GRAPH(subc, mthd) SUBC_##subc((NV04_GRAPH_##mthd))
#endif

View File

@ -1,80 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_RENDER_H__
#define __NOUVEAU_RENDER_H__
#include "vbo/vbo.h"
#include "nouveau_array.h"
typedef void (*dispatch_t)(struct gl_context *, unsigned int, int, unsigned int);
typedef void (*emit_t)(struct gl_context *, struct nouveau_array *, const void *);
struct nouveau_attr_info {
int vbo_index;
int imm_method;
int imm_fields;
emit_t emit;
};
struct nouveau_swtnl_state {
struct nouveau_bo *vbo;
unsigned offset;
void *buf;
unsigned vertex_count;
GLenum primitive;
};
struct nouveau_render_state {
enum {
VBO,
IMM
} mode;
struct nouveau_array ib;
struct nouveau_array attrs[VERT_ATTRIB_MAX];
/* Maps a HW VBO index or IMM emission order to an index in
* the attrs array above (or -1 if unused). */
int map[VERT_ATTRIB_MAX];
int attr_count;
int vertex_size;
struct nouveau_swtnl_state swtnl;
};
#define to_render_state(ctx) (&to_nouveau_context(ctx)->render)
#define FOR_EACH_ATTR(render, i, attr) \
for (i = 0; attr = (render)->map[i], i < NUM_VERTEX_ATTRS; i++)
#define FOR_EACH_BOUND_ATTR(render, i, attr) \
for (i = 0; attr = (render)->map[i], i < render->attr_count; i++) \
if (attr >= 0)
#endif

View File

@ -1,209 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/*
* Vertex submission helper definitions shared among the software and
* hardware TnL paths.
*/
#include "nouveau_gldefs.h"
#include "main/light.h"
#include "vbo/vbo.h"
#include "tnl/tnl.h"
#define OUT_INDICES_L(r, i, d, n) \
BATCH_OUT_L(i + d, n); \
(void)r
#define OUT_INDICES_I16(r, i, d, n) \
BATCH_OUT_I16(r->ib.extract_u(&r->ib, 0, i) + d, \
r->ib.extract_u(&r->ib, 0, i + 1) + d)
#define OUT_INDICES_I32(r, i, d, n) \
BATCH_OUT_I32(r->ib.extract_u(&r->ib, 0, i) + d)
/*
* Emit <n> vertices using BATCH_OUT_<out>, MAX_OUT_<out> at a time,
* grouping them in packets of length MAX_PACKET.
*
* out: hardware index data type.
* ctx: GL context.
* start: element within the index buffer to begin with.
* delta: integer correction that will be added to each index found in
* the index buffer.
*/
#define EMIT_VBO(out, ctx, start, delta, n) do { \
struct nouveau_render_state *render = to_render_state(ctx); \
int _npush = n; \
\
while (_npush) { \
int _npack = MIN2(_npush, MAX_PACKET * MAX_OUT_##out); \
_npush -= _npack; \
\
BATCH_PACKET_##out((_npack + MAX_OUT_##out - 1) \
/ MAX_OUT_##out); \
while (_npack) { \
int _nout = MIN2(_npack, MAX_OUT_##out);\
_npack -= _nout; \
\
OUT_INDICES_##out(render, start, delta, \
_nout); \
start += _nout; \
} \
} \
} while (0)
/*
* Emit the <n>-th element of the array <a>, using IMM_OUT.
*/
#define EMIT_IMM(ctx, a, n) do { \
struct nouveau_attr_info *info = \
&TAG(vertex_attrs)[(a)->attr]; \
int m; \
\
if (!info->emit) { \
IMM_PACKET(info->imm_method, info->imm_fields); \
\
for (m = 0; m < (a)->fields; m++) \
IMM_OUT((a)->extract_f(a, n, m)); \
\
for (m = (a)->fields; m < info->imm_fields; m++) \
IMM_OUT(((float []){0, 0, 0, 1})[m]); \
\
} else { \
info->emit(ctx, a, (a)->buf + n * (a)->stride); \
} \
} while (0)
static void
dispatch_l(struct gl_context *ctx, unsigned int start, int delta,
unsigned int n)
{
struct nouveau_pushbuf *push = context_push(ctx);
RENDER_LOCALS(ctx);
EMIT_VBO(L, ctx, start, delta, n);
}
static void
dispatch_i32(struct gl_context *ctx, unsigned int start, int delta,
unsigned int n)
{
struct nouveau_pushbuf *push = context_push(ctx);
RENDER_LOCALS(ctx);
EMIT_VBO(I32, ctx, start, delta, n);
}
static void
dispatch_i16(struct gl_context *ctx, unsigned int start, int delta,
unsigned int n)
{
struct nouveau_pushbuf *push = context_push(ctx);
RENDER_LOCALS(ctx);
EMIT_VBO(I32, ctx, start, delta, n & 1);
EMIT_VBO(I16, ctx, start, delta, n & ~1);
}
/*
* Select an appropriate dispatch function for the given index buffer.
*/
static dispatch_t
get_array_dispatch(struct nouveau_array *a)
{
if (!a->fields)
return dispatch_l;
else if (a->type == GL_UNSIGNED_INT)
return dispatch_i32;
else
return dispatch_i16;
}
/*
* Returns how many vertices you can draw using <n> pushbuf dwords.
*/
static inline unsigned
get_max_vertices(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
int n)
{
struct nouveau_render_state *render = to_render_state(ctx);
if (render->mode == IMM) {
return MAX2(0, n - 4) / (render->vertex_size / 4 +
render->attr_count);
} else {
unsigned max_out;
if (ib) {
switch (ib->index_size_shift) {
case 2:
max_out = MAX_OUT_I32;
break;
case 1:
max_out = MAX_OUT_I16;
break;
case 0:
max_out = MAX_OUT_I16;
break;
default:
assert(0);
max_out = 0;
break;
}
} else {
max_out = MAX_OUT_L;
}
return MAX2(0, n - 7) * max_out * MAX_PACKET / (1 + MAX_PACKET);
}
}
static void
TAG(emit_material)(struct gl_context *ctx, struct nouveau_array *a,
const void *v)
{
int attr = a->attr - VERT_ATTRIB_MAT(0);
int state = ((int []) {
NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
NOUVEAU_STATE_MATERIAL_FRONT_DIFFUSE,
NOUVEAU_STATE_MATERIAL_BACK_DIFFUSE,
NOUVEAU_STATE_MATERIAL_FRONT_SPECULAR,
NOUVEAU_STATE_MATERIAL_BACK_SPECULAR,
NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
NOUVEAU_STATE_MATERIAL_FRONT_SHININESS,
NOUVEAU_STATE_MATERIAL_BACK_SHININESS
}) [attr];
COPY_4V(ctx->Light.Material.Attrib[attr], (float *)v);
_mesa_update_material(ctx, 1 << attr);
context_drv(ctx)->emit[state](ctx, state);
}

View File

@ -1,97 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
/*
* Returns a pointer to a chunk of 'size' bytes long GART memory. 'bo'
* and 'offset' will point to the returned memory.
*/
void *
nouveau_get_scratch(struct gl_context *ctx, unsigned size,
struct nouveau_bo **bo, unsigned *offset)
{
struct nouveau_client *client = context_client(ctx);
struct nouveau_scratch_state *scratch =
&to_nouveau_context(ctx)->scratch;
void *buf;
if (scratch->buf && size <= NOUVEAU_SCRATCH_SIZE - scratch->offset) {
nouveau_bo_ref(scratch->bo[scratch->index], bo);
buf = scratch->buf + scratch->offset;
*offset = scratch->offset;
scratch->offset += size;
} else if (size <= NOUVEAU_SCRATCH_SIZE) {
scratch->index = (scratch->index + 1) % NOUVEAU_SCRATCH_COUNT;
nouveau_bo_ref(scratch->bo[scratch->index], bo);
nouveau_bo_map(*bo, NOUVEAU_BO_WR, client);
buf = scratch->buf = (*bo)->map;
*offset = 0;
scratch->offset = size;
} else {
nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_GART |
NOUVEAU_BO_MAP, 0, size, NULL, bo);
nouveau_bo_map(*bo, NOUVEAU_BO_WR, client);
buf = (*bo)->map;
*offset = 0;
}
return buf;
}
void
nouveau_scratch_init(struct gl_context *ctx)
{
struct nouveau_scratch_state *scratch =
&to_nouveau_context(ctx)->scratch;
int ret, i;
for (i = 0; i < NOUVEAU_SCRATCH_COUNT; i++) {
ret = nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_GART |
NOUVEAU_BO_MAP, 0, NOUVEAU_SCRATCH_SIZE,
NULL, &scratch->bo[i]);
assert(!ret);
}
}
void
nouveau_scratch_destroy(struct gl_context *ctx)
{
struct nouveau_scratch_state *scratch =
&to_nouveau_context(ctx)->scratch;
int i;
for (i = 0; i < NOUVEAU_SCRATCH_COUNT; i++)
nouveau_bo_ref(NULL, &scratch->bo[i]);
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_SCRATCH_H__
#define __NOUVEAU_SCRATCH_H__
#define NOUVEAU_SCRATCH_COUNT 2
#define NOUVEAU_SCRATCH_SIZE 3*1024*1024
struct nouveau_scratch_state {
struct nouveau_bo *bo[NOUVEAU_SCRATCH_COUNT];
int index;
int offset;
void *buf;
};
void *
nouveau_get_scratch(struct gl_context *ctx, unsigned size,
struct nouveau_bo **bo, unsigned *offset);
void
nouveau_scratch_init(struct gl_context *ctx);
void
nouveau_scratch_destroy(struct gl_context *ctx);
#endif

View File

@ -1,361 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <stdio.h>
#include <xf86drm.h>
#include <nouveau_drm.h>
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_fbo.h"
#include "nouveau_texture.h"
#include "nv04_driver.h"
#include "nv10_driver.h"
#include "nv20_driver.h"
#include "main/framebuffer.h"
#include "main/fbobject.h"
#include "main/renderbuffer.h"
#include "util/u_memory.h"
#include "swrast/s_renderbuffer.h"
#include <nvif/class.h>
#include <nvif/cl0080.h>
static const __DRIextension *nouveau_screen_extensions[];
static void
nouveau_destroy_screen(__DRIscreen *dri_screen);
static const __DRIconfig **
nouveau_get_configs(uint32_t chipset)
{
__DRIconfig **configs = NULL;
int i;
const uint8_t depth_bits[] = { 0, 16, 24, 24 };
const uint8_t stencil_bits[] = { 0, 0, 0, 8 };
const uint8_t msaa_samples[] = { 0 };
static const mesa_format formats[3] = {
MESA_FORMAT_B5G6R5_UNORM,
MESA_FORMAT_B8G8R8A8_UNORM,
MESA_FORMAT_B8G8R8X8_UNORM,
};
const GLenum back_buffer_modes[] = {
__DRI_ATTRIB_SWAP_NONE, __DRI_ATTRIB_SWAP_UNDEFINED
};
for (i = 0; i < ARRAY_SIZE(formats); i++) {
__DRIconfig **config;
config = driCreateConfigs(formats[i],
depth_bits, stencil_bits,
ARRAY_SIZE(depth_bits),
back_buffer_modes,
ARRAY_SIZE(back_buffer_modes),
msaa_samples,
ARRAY_SIZE(msaa_samples),
GL_TRUE, chipset < 0x10);
assert(config);
configs = driConcatConfigs(configs, config);
}
return (const __DRIconfig **)configs;
}
static const __DRIconfig **
nouveau_init_screen2(__DRIscreen *dri_screen)
{
const __DRIconfig **configs;
struct nouveau_screen *screen;
int ret;
/* Allocate the screen. */
screen = CALLOC_STRUCT(nouveau_screen);
if (!screen)
return NULL;
dri_screen->driverPrivate = screen;
/* Open the DRM device. */
ret = nouveau_drm_new(dri_screen->fd, &screen->drm);
if (ret) {
nouveau_error("Error opening the DRM device.\n");
goto fail;
}
ret = nouveau_device_new(&screen->drm->client, NV_DEVICE,
&(struct nv_device_v0) {
.device = ~0ULL,
}, sizeof(struct nv_device_v0),
&screen->device);
if (ret) {
nouveau_error("Error creating device object.\n");
goto fail;
}
/* Choose the card specific function pointers. */
switch (screen->device->chipset & 0xf0) {
case 0x00:
screen->driver = &nv04_driver;
dri_screen->max_gl_compat_version = 12;
break;
case 0x10:
screen->driver = &nv10_driver;
dri_screen->max_gl_compat_version = 12;
dri_screen->max_gl_es1_version = 10;
break;
case 0x20:
case 0x30:
screen->driver = &nv20_driver;
dri_screen->max_gl_compat_version = 13;
dri_screen->max_gl_es1_version = 10;
break;
default:
nouveau_error("Unknown chipset: %02X\n",
screen->device->chipset);
goto fail;
}
dri_screen->extensions = nouveau_screen_extensions;
screen->dri_screen = dri_screen;
configs = nouveau_get_configs(screen->device->chipset);
if (!configs)
goto fail;
return configs;
fail:
nouveau_destroy_screen(dri_screen);
return NULL;
}
static int
nouveau_query_renderer_integer(__DRIscreen *psp, int param,
unsigned int *value)
{
const struct nouveau_screen *const screen =
(struct nouveau_screen *) psp->driverPrivate;
switch (param) {
case __DRI2_RENDERER_VENDOR_ID:
value[0] = 0x10de;
return 0;
case __DRI2_RENDERER_DEVICE_ID: {
uint64_t device_id;
if (nouveau_getparam(screen->device,
NOUVEAU_GETPARAM_PCI_DEVICE,
&device_id)) {
nouveau_error("Error retrieving the device PCIID.\n");
device_id = -1;
}
value[0] = (unsigned int) device_id;
return 0;
}
case __DRI2_RENDERER_ACCELERATED:
value[0] = 1;
return 0;
case __DRI2_RENDERER_VIDEO_MEMORY:
/* XXX: return vram_size or vram_limit ? */
value[0] = screen->device->vram_size >> 20;
return 0;
case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
value[0] = 0;
return 0;
default:
return driQueryRendererIntegerCommon(psp, param, value);
}
}
static int
nouveau_query_renderer_string(__DRIscreen *psp, int param, const char **value)
{
const struct nouveau_screen *const screen =
(struct nouveau_screen *) psp->driverPrivate;
switch (param) {
case __DRI2_RENDERER_VENDOR_ID:
value[0] = nouveau_vendor_string;
return 0;
case __DRI2_RENDERER_DEVICE_ID:
value[0] = nouveau_get_renderer_string(screen->device->chipset);
return 0;
default:
return -1;
}
}
static const __DRI2rendererQueryExtension nouveau_renderer_query_extension = {
.base = { __DRI2_RENDERER_QUERY, 1 },
.queryInteger = nouveau_query_renderer_integer,
.queryString = nouveau_query_renderer_string
};
static void
nouveau_destroy_screen(__DRIscreen *dri_screen)
{
struct nouveau_screen *screen = dri_screen->driverPrivate;
if (!screen)
return;
nouveau_device_del(&screen->device);
nouveau_drm_del(&screen->drm);
free(screen);
dri_screen->driverPrivate = NULL;
}
static GLboolean
nouveau_create_buffer(__DRIscreen *dri_screen,
__DRIdrawable *drawable,
const struct gl_config *visual,
GLboolean is_pixmap)
{
struct gl_renderbuffer *rb;
struct gl_framebuffer *fb;
GLenum color_format;
if (is_pixmap)
return GL_FALSE; /* not implemented */
if (visual->redBits == 5)
color_format = GL_RGB5;
else if (visual->alphaBits == 0)
color_format = GL_RGB8;
else
color_format = GL_RGBA8;
fb = nouveau_framebuffer_dri_new(visual);
if (!fb)
return GL_FALSE;
/* Front buffer. */
rb = nouveau_renderbuffer_dri_new(color_format, drawable);
_mesa_attach_and_own_rb(fb, BUFFER_FRONT_LEFT, rb);
/* Back buffer */
if (visual->doubleBufferMode) {
rb = nouveau_renderbuffer_dri_new(color_format, drawable);
_mesa_attach_and_own_rb(fb, BUFFER_BACK_LEFT, rb);
}
/* Depth/stencil buffer. */
if (visual->depthBits == 24 && visual->stencilBits == 8) {
rb = nouveau_renderbuffer_dri_new(GL_DEPTH24_STENCIL8_EXT, drawable);
_mesa_attach_and_own_rb(fb, BUFFER_DEPTH, rb);
_mesa_attach_and_reference_rb(fb, BUFFER_STENCIL, rb);
} else if (visual->depthBits == 24) {
rb = nouveau_renderbuffer_dri_new(GL_DEPTH_COMPONENT24, drawable);
_mesa_attach_and_own_rb(fb, BUFFER_DEPTH, rb);
} else if (visual->depthBits == 16) {
rb = nouveau_renderbuffer_dri_new(GL_DEPTH_COMPONENT16, drawable);
_mesa_attach_and_own_rb(fb, BUFFER_DEPTH, rb);
}
/* Software renderbuffers. */
_swrast_add_soft_renderbuffers(fb, GL_FALSE, GL_FALSE, GL_FALSE,
visual->accumRedBits > 0,
GL_FALSE);
drawable->driverPrivate = fb;
return GL_TRUE;
}
static void
nouveau_destroy_buffer(__DRIdrawable *drawable)
{
_mesa_reference_framebuffer(
(struct gl_framebuffer **)&drawable->driverPrivate, NULL);
}
static void
nouveau_drawable_flush(__DRIdrawable *draw)
{
}
static const struct __DRI2flushExtensionRec nouveau_flush_extension = {
.base = { __DRI2_FLUSH, 3 },
.flush = nouveau_drawable_flush,
.invalidate = dri2InvalidateDrawable,
};
static const struct __DRItexBufferExtensionRec nouveau_texbuffer_extension = {
.base = { __DRI_TEX_BUFFER, 3 },
.setTexBuffer = NULL,
.setTexBuffer2 = nouveau_set_texbuffer,
.releaseTexBuffer = NULL,
};
static const __DRIextension *nouveau_screen_extensions[] = {
&nouveau_flush_extension.base,
&nouveau_texbuffer_extension.base,
&nouveau_renderer_query_extension.base,
&dri2ConfigQueryExtension.base,
&dri2NoErrorExtension.base,
NULL
};
const struct __DriverAPIRec nouveau_driver_api = {
.InitScreen = nouveau_init_screen2,
.DestroyScreen = nouveau_destroy_screen,
.CreateBuffer = nouveau_create_buffer,
.DestroyBuffer = nouveau_destroy_buffer,
.CreateContext = nouveau_context_create,
.DestroyContext = nouveau_context_destroy,
.MakeCurrent = nouveau_context_make_current,
.UnbindContext = nouveau_context_unbind,
};
static const struct __DRIDriverVtableExtensionRec nouveau_vtable = {
.base = { __DRI_DRIVER_VTABLE, 1 },
.vtable = &nouveau_driver_api,
};
/* This is the table of extensions that the loader will dlsym() for. */
static const __DRIextension *nouveau_driver_extensions[] = {
&driCoreExtension.base,
&driDRI2Extension.base,
&nouveau_vtable.base,
NULL
};
PUBLIC const __DRIextension **__driDriverGetExtensions_nouveau_vieux(void)
{
globalDriverAPI = &nouveau_driver_api;
return nouveau_driver_extensions;
}

View File

@ -1,41 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_SCREEN_H__
#define __NOUVEAU_SCREEN_H__
const __DRIextension **__driDriverGetExtensions_nouveau_vieux(void);
struct nouveau_context;
struct nouveau_screen {
__DRIscreen *dri_screen;
struct nouveau_drm *drm;
struct nouveau_device *device;
const struct nouveau_driver *driver;
};
#endif

View File

@ -1,99 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_fbo.h"
#include "nouveau_context.h"
#include "swrast/swrast.h"
#include "swrast/s_context.h"
static void
renderbuffer_map_unmap(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLboolean map)
{
struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
if (map)
nouveau_bo_map(s->bo, NOUVEAU_BO_RDWR, context_client(ctx));
}
static void
framebuffer_map_unmap(struct gl_context *ctx, struct gl_framebuffer *fb, GLboolean map)
{
int i;
for (i = 0; i < fb->_NumColorDrawBuffers; i++)
renderbuffer_map_unmap(ctx, fb->_ColorDrawBuffers[i], map);
renderbuffer_map_unmap(ctx, fb->_ColorReadBuffer, map);
if (fb->Attachment[BUFFER_DEPTH].Renderbuffer)
renderbuffer_map_unmap(ctx, fb->Attachment[BUFFER_DEPTH].Renderbuffer, map);
}
static void
span_map_unmap(struct gl_context *ctx, GLboolean map)
{
int i;
framebuffer_map_unmap(ctx, ctx->DrawBuffer, map);
if (ctx->ReadBuffer != ctx->DrawBuffer)
framebuffer_map_unmap(ctx, ctx->ReadBuffer, map);
for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
if (map)
_swrast_map_texture(ctx, ctx->Texture.Unit[i]._Current);
else
_swrast_unmap_texture(ctx, ctx->Texture.Unit[i]._Current);
}
static void
nouveau_span_start(struct gl_context *ctx)
{
nouveau_fallback(ctx, SWRAST);
span_map_unmap(ctx, GL_TRUE);
}
static void
nouveau_span_finish(struct gl_context *ctx)
{
span_map_unmap(ctx, GL_FALSE);
nouveau_fallback(ctx, HWTNL);
}
void
nouveau_span_functions_init(struct gl_context *ctx)
{
struct swrast_device_driver *swdd =
_swrast_GetDeviceDriverReference(ctx);
swdd->SpanRenderStart = nouveau_span_start;
swdd->SpanRenderFinish = nouveau_span_finish;
}

View File

@ -1,548 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_texture.h"
#include "nouveau_util.h"
#include "swrast/swrast.h"
#include "tnl/tnl.h"
#include "util/bitscan.h"
#include "main/framebuffer.h"
static void
nouveau_alpha_func(struct gl_context *ctx, GLenum func, GLfloat ref)
{
context_dirty(ctx, ALPHA_FUNC);
}
static void
nouveau_blend_color(struct gl_context *ctx, const GLfloat color[4])
{
context_dirty(ctx, BLEND_COLOR);
}
static void
nouveau_blend_equation_separate(struct gl_context *ctx, GLenum modeRGB, GLenum modeA)
{
context_dirty(ctx, BLEND_EQUATION);
}
static void
nouveau_blend_func_separate(struct gl_context *ctx, GLenum sfactorRGB,
GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA)
{
context_dirty(ctx, BLEND_FUNC);
}
static void
nouveau_clip_plane(struct gl_context *ctx, GLenum plane, const GLfloat *equation)
{
context_dirty_i(ctx, CLIP_PLANE, plane - GL_CLIP_PLANE0);
}
static void
nouveau_color_mask(struct gl_context *ctx, GLboolean rmask, GLboolean gmask,
GLboolean bmask, GLboolean amask)
{
context_dirty(ctx, COLOR_MASK);
}
static void
nouveau_color_material(struct gl_context *ctx, GLenum face, GLenum mode)
{
context_dirty(ctx, COLOR_MATERIAL);
context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
context_dirty(ctx, MATERIAL_BACK_AMBIENT);
context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
context_dirty(ctx, MATERIAL_BACK_SPECULAR);
}
static void
nouveau_cull_face(struct gl_context *ctx, GLenum mode)
{
context_dirty(ctx, CULL_FACE);
}
static void
nouveau_front_face(struct gl_context *ctx, GLenum mode)
{
context_dirty(ctx, FRONT_FACE);
}
static void
nouveau_depth_func(struct gl_context *ctx, GLenum func)
{
context_dirty(ctx, DEPTH);
}
static void
nouveau_depth_mask(struct gl_context *ctx, GLboolean flag)
{
context_dirty(ctx, DEPTH);
}
static void
nouveau_read_buffer(struct gl_context *ctx, GLenum buffer)
{
nouveau_validate_framebuffer(ctx);
}
static void
nouveau_draw_buffer(struct gl_context *ctx)
{
nouveau_validate_framebuffer(ctx);
context_dirty(ctx, FRAMEBUFFER);
}
static void
nouveau_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
{
GLbitfield mask;
switch (cap) {
case GL_ALPHA_TEST:
context_dirty(ctx, ALPHA_FUNC);
break;
case GL_BLEND:
context_dirty(ctx, BLEND_EQUATION);
break;
case GL_COLOR_LOGIC_OP:
context_dirty(ctx, LOGIC_OPCODE);
break;
case GL_COLOR_MATERIAL:
context_dirty(ctx, COLOR_MATERIAL);
context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
context_dirty(ctx, MATERIAL_BACK_AMBIENT);
context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
context_dirty(ctx, MATERIAL_BACK_SPECULAR);
break;
case GL_COLOR_SUM_EXT:
context_dirty(ctx, FRAG);
context_dirty(ctx, LIGHT_MODEL);
break;
case GL_CULL_FACE:
context_dirty(ctx, CULL_FACE);
break;
case GL_DEPTH_TEST:
context_dirty(ctx, DEPTH);
break;
case GL_DITHER:
context_dirty(ctx, DITHER);
break;
case GL_FOG:
context_dirty(ctx, FOG);
context_dirty(ctx, FRAG);
context_dirty(ctx, MODELVIEW);
break;
case GL_LIGHT0:
case GL_LIGHT1:
case GL_LIGHT2:
case GL_LIGHT3:
case GL_LIGHT4:
case GL_LIGHT5:
case GL_LIGHT6:
case GL_LIGHT7:
context_dirty(ctx, MODELVIEW);
context_dirty(ctx, LIGHT_ENABLE);
context_dirty_i(ctx, LIGHT_SOURCE, cap - GL_LIGHT0);
context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
context_dirty(ctx, MATERIAL_BACK_AMBIENT);
context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
context_dirty(ctx, MATERIAL_BACK_SPECULAR);
context_dirty(ctx, MATERIAL_FRONT_SHININESS);
context_dirty(ctx, MATERIAL_BACK_SHININESS);
break;
case GL_LIGHTING:
context_dirty(ctx, FRAG);
context_dirty(ctx, MODELVIEW);
context_dirty(ctx, LIGHT_MODEL);
context_dirty(ctx, LIGHT_ENABLE);
mask = ctx->Light._EnabledLights;
while (mask) {
const int i = u_bit_scan(&mask);
context_dirty_i(ctx, LIGHT_SOURCE, i);
}
context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
context_dirty(ctx, MATERIAL_BACK_AMBIENT);
context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
context_dirty(ctx, MATERIAL_BACK_SPECULAR);
context_dirty(ctx, MATERIAL_FRONT_SHININESS);
context_dirty(ctx, MATERIAL_BACK_SHININESS);
break;
case GL_LINE_SMOOTH:
context_dirty(ctx, LINE_MODE);
break;
case GL_NORMALIZE:
context_dirty(ctx, LIGHT_ENABLE);
break;
case GL_POINT_SMOOTH:
context_dirty(ctx, POINT_MODE);
break;
case GL_POLYGON_OFFSET_POINT:
case GL_POLYGON_OFFSET_LINE:
case GL_POLYGON_OFFSET_FILL:
context_dirty(ctx, POLYGON_OFFSET);
break;
case GL_POLYGON_SMOOTH:
context_dirty(ctx, POLYGON_MODE);
break;
case GL_SCISSOR_TEST:
context_dirty(ctx, SCISSOR);
break;
case GL_STENCIL_TEST:
context_dirty(ctx, STENCIL_FUNC);
break;
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
case GL_TEXTURE_RECTANGLE:
context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit);
context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
break;
case GL_TEXTURE_GEN_S:
case GL_TEXTURE_GEN_T:
case GL_TEXTURE_GEN_R:
case GL_TEXTURE_GEN_Q:
context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
context_dirty(ctx, MODELVIEW);
break;
}
}
static void
nouveau_fog(struct gl_context *ctx, GLenum pname, const GLfloat *params)
{
context_dirty(ctx, FOG);
}
static void
nouveau_light(struct gl_context *ctx, GLenum light, GLenum pname, const GLfloat *params)
{
switch (pname) {
case GL_AMBIENT:
context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
context_dirty(ctx, MATERIAL_BACK_AMBIENT);
break;
case GL_DIFFUSE:
context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
break;
case GL_SPECULAR:
context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
context_dirty(ctx, MATERIAL_BACK_SPECULAR);
break;
case GL_SPOT_CUTOFF:
case GL_POSITION:
context_dirty(ctx, MODELVIEW);
context_dirty(ctx, LIGHT_ENABLE);
context_dirty_i(ctx, LIGHT_SOURCE, light - GL_LIGHT0);
break;
default:
context_dirty_i(ctx, LIGHT_SOURCE, light - GL_LIGHT0);
break;
}
}
static void
nouveau_light_model(struct gl_context *ctx, GLenum pname, const GLfloat *params)
{
context_dirty(ctx, LIGHT_MODEL);
context_dirty(ctx, MODELVIEW);
}
static void
nouveau_line_stipple(struct gl_context *ctx, GLint factor, GLushort pattern )
{
context_dirty(ctx, LINE_STIPPLE);
}
static void
nouveau_line_width(struct gl_context *ctx, GLfloat width)
{
context_dirty(ctx, LINE_MODE);
}
static void
nouveau_logic_opcode(struct gl_context *ctx, UNUSED enum gl_logicop_mode opcode)
{
context_dirty(ctx, LOGIC_OPCODE);
}
static void
nouveau_point_parameter(struct gl_context *ctx, GLenum pname, const GLfloat *params)
{
context_dirty(ctx, POINT_PARAMETER);
}
static void
nouveau_point_size(struct gl_context *ctx, GLfloat size)
{
context_dirty(ctx, POINT_MODE);
}
static void
nouveau_polygon_mode(struct gl_context *ctx, GLenum face, GLenum mode)
{
context_dirty(ctx, POLYGON_MODE);
}
static void
nouveau_polygon_offset(struct gl_context *ctx, GLfloat factor, GLfloat units, GLfloat clamp)
{
context_dirty(ctx, POLYGON_OFFSET);
}
static void
nouveau_polygon_stipple(struct gl_context *ctx, const GLubyte *mask)
{
context_dirty(ctx, POLYGON_STIPPLE);
}
static void
nouveau_render_mode(struct gl_context *ctx, GLenum mode)
{
context_dirty(ctx, RENDER_MODE);
}
static void
nouveau_shade_model(struct gl_context *ctx, GLenum mode)
{
context_dirty(ctx, SHADE_MODEL);
}
static void
nouveau_stencil_func_separate(struct gl_context *ctx, GLenum face, GLenum func,
GLint ref, GLuint mask)
{
context_dirty(ctx, STENCIL_FUNC);
}
static void
nouveau_stencil_mask_separate(struct gl_context *ctx, GLenum face, GLuint mask)
{
context_dirty(ctx, STENCIL_MASK);
}
static void
nouveau_stencil_op_separate(struct gl_context *ctx, GLenum face, GLenum fail,
GLenum zfail, GLenum zpass)
{
context_dirty(ctx, STENCIL_OP);
}
static void
nouveau_tex_gen(struct gl_context *ctx, GLenum coord, GLenum pname,
const GLfloat *params)
{
switch (pname) {
case GL_TEXTURE_GEN_MODE:
context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
context_dirty(ctx, MODELVIEW);
break;
default:
context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
break;
}
}
static void
nouveau_tex_env(struct gl_context *ctx, GLenum target, GLenum pname,
const GLfloat *param)
{
switch (target) {
case GL_TEXTURE_FILTER_CONTROL_EXT:
context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
break;
default:
context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit);
break;
}
}
static void
nouveau_tex_parameter(struct gl_context *ctx,
struct gl_texture_object *t, GLenum pname)
{
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
case GL_TEXTURE_WRAP_R:
case GL_TEXTURE_MIN_LOD:
case GL_TEXTURE_MAX_LOD:
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
case GL_TEXTURE_LOD_BIAS:
context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
break;
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_ALL_ATTRIB_BITS: /* meaning is all pnames, internal */
nouveau_texture_reallocate(ctx, t);
context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
break;
}
}
void
nouveau_emit_nothing(struct gl_context *ctx, int emit)
{
}
int
nouveau_next_dirty_state(struct gl_context *ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
int i = BITSET_FFS(nctx->dirty) - 1;
if (i < 0 || i >= context_drv(ctx)->num_emit)
return -1;
return i;
}
void
nouveau_state_emit(struct gl_context *ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
const struct nouveau_driver *drv = context_drv(ctx);
int i;
while ((i = nouveau_next_dirty_state(ctx)) >= 0) {
BITSET_CLEAR(nctx->dirty, i);
drv->emit[i](ctx, i);
}
BITSET_ZERO(nctx->dirty);
}
static void
nouveau_update_state(struct gl_context *ctx)
{
GLbitfield new_state = ctx->NewState;
int i;
if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
_mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW))
context_dirty(ctx, PROJECTION);
if (new_state & _NEW_MODELVIEW)
context_dirty(ctx, MODELVIEW);
if (new_state & _NEW_TEXTURE_MATRIX) {
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
context_dirty_i(ctx, TEX_MAT, i);
}
if (new_state & _NEW_SCISSOR)
context_dirty(ctx, SCISSOR);
if (new_state & _NEW_VIEWPORT)
context_dirty(ctx, VIEWPORT);
if (new_state & _NEW_CURRENT_ATTRIB &&
new_state & _NEW_LIGHT) {
context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
context_dirty(ctx, MATERIAL_BACK_AMBIENT);
context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
context_dirty(ctx, MATERIAL_BACK_SPECULAR);
context_dirty(ctx, MATERIAL_FRONT_SHININESS);
context_dirty(ctx, MATERIAL_BACK_SHININESS);
}
if (new_state & _NEW_TEXTURE) {
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
if (ctx->Texture.Unit[i].Sampler)
context_dirty_i(ctx, TEX_OBJ, i);
}
}
_swrast_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
nouveau_state_emit(ctx);
}
void
nouveau_state_init(struct gl_context *ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
ctx->Driver.AlphaFunc = nouveau_alpha_func;
ctx->Driver.BlendColor = nouveau_blend_color;
ctx->Driver.BlendEquationSeparate = nouveau_blend_equation_separate;
ctx->Driver.BlendFuncSeparate = nouveau_blend_func_separate;
ctx->Driver.ClipPlane = nouveau_clip_plane;
ctx->Driver.ColorMask = nouveau_color_mask;
ctx->Driver.ColorMaterial = nouveau_color_material;
ctx->Driver.CullFace = nouveau_cull_face;
ctx->Driver.FrontFace = nouveau_front_face;
ctx->Driver.DepthFunc = nouveau_depth_func;
ctx->Driver.DepthMask = nouveau_depth_mask;
ctx->Driver.ReadBuffer = nouveau_read_buffer;
ctx->Driver.DrawBuffer = nouveau_draw_buffer;
ctx->Driver.Enable = nouveau_enable;
ctx->Driver.Fogfv = nouveau_fog;
ctx->Driver.Lightfv = nouveau_light;
ctx->Driver.LightModelfv = nouveau_light_model;
ctx->Driver.LineStipple = nouveau_line_stipple;
ctx->Driver.LineWidth = nouveau_line_width;
ctx->Driver.LogicOpcode = nouveau_logic_opcode;
ctx->Driver.PointParameterfv = nouveau_point_parameter;
ctx->Driver.PointSize = nouveau_point_size;
ctx->Driver.PolygonMode = nouveau_polygon_mode;
ctx->Driver.PolygonOffset = nouveau_polygon_offset;
ctx->Driver.PolygonStipple = nouveau_polygon_stipple;
ctx->Driver.RenderMode = nouveau_render_mode;
ctx->Driver.ShadeModel = nouveau_shade_model;
ctx->Driver.StencilFuncSeparate = nouveau_stencil_func_separate;
ctx->Driver.StencilMaskSeparate = nouveau_stencil_mask_separate;
ctx->Driver.StencilOpSeparate = nouveau_stencil_op_separate;
ctx->Driver.TexGen = nouveau_tex_gen;
ctx->Driver.TexEnv = nouveau_tex_env;
ctx->Driver.TexParameter = nouveau_tex_parameter;
ctx->Driver.UpdateState = nouveau_update_state;
BITSET_ONES(nctx->dirty);
}

View File

@ -1,122 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_STATE_H__
#define __NOUVEAU_STATE_H__
enum {
NOUVEAU_STATE_ALPHA_FUNC,
NOUVEAU_STATE_BLEND_COLOR,
NOUVEAU_STATE_BLEND_EQUATION,
NOUVEAU_STATE_BLEND_FUNC,
NOUVEAU_STATE_CLIP_PLANE0,
NOUVEAU_STATE_CLIP_PLANE1,
NOUVEAU_STATE_CLIP_PLANE2,
NOUVEAU_STATE_CLIP_PLANE3,
NOUVEAU_STATE_CLIP_PLANE4,
NOUVEAU_STATE_CLIP_PLANE5,
NOUVEAU_STATE_COLOR_MASK,
NOUVEAU_STATE_COLOR_MATERIAL,
NOUVEAU_STATE_CULL_FACE,
NOUVEAU_STATE_FRONT_FACE,
NOUVEAU_STATE_DEPTH,
NOUVEAU_STATE_DITHER,
NOUVEAU_STATE_FRAG,
NOUVEAU_STATE_FRAMEBUFFER,
NOUVEAU_STATE_FOG,
NOUVEAU_STATE_LIGHT_ENABLE,
NOUVEAU_STATE_LIGHT_MODEL,
NOUVEAU_STATE_LIGHT_SOURCE0,
NOUVEAU_STATE_LIGHT_SOURCE1,
NOUVEAU_STATE_LIGHT_SOURCE2,
NOUVEAU_STATE_LIGHT_SOURCE3,
NOUVEAU_STATE_LIGHT_SOURCE4,
NOUVEAU_STATE_LIGHT_SOURCE5,
NOUVEAU_STATE_LIGHT_SOURCE6,
NOUVEAU_STATE_LIGHT_SOURCE7,
NOUVEAU_STATE_LINE_STIPPLE,
NOUVEAU_STATE_LINE_MODE,
NOUVEAU_STATE_LOGIC_OPCODE,
NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
NOUVEAU_STATE_MATERIAL_FRONT_DIFFUSE,
NOUVEAU_STATE_MATERIAL_BACK_DIFFUSE,
NOUVEAU_STATE_MATERIAL_FRONT_SPECULAR,
NOUVEAU_STATE_MATERIAL_BACK_SPECULAR,
NOUVEAU_STATE_MATERIAL_FRONT_SHININESS,
NOUVEAU_STATE_MATERIAL_BACK_SHININESS,
NOUVEAU_STATE_MODELVIEW,
NOUVEAU_STATE_POINT_MODE,
NOUVEAU_STATE_POINT_PARAMETER,
NOUVEAU_STATE_POLYGON_MODE,
NOUVEAU_STATE_POLYGON_OFFSET,
NOUVEAU_STATE_POLYGON_STIPPLE,
NOUVEAU_STATE_PROJECTION,
NOUVEAU_STATE_RENDER_MODE,
NOUVEAU_STATE_SCISSOR,
NOUVEAU_STATE_SHADE_MODEL,
NOUVEAU_STATE_STENCIL_FUNC,
NOUVEAU_STATE_STENCIL_MASK,
NOUVEAU_STATE_STENCIL_OP,
NOUVEAU_STATE_TEX_ENV0,
NOUVEAU_STATE_TEX_ENV1,
NOUVEAU_STATE_TEX_ENV2,
NOUVEAU_STATE_TEX_ENV3,
NOUVEAU_STATE_TEX_GEN0,
NOUVEAU_STATE_TEX_GEN1,
NOUVEAU_STATE_TEX_GEN2,
NOUVEAU_STATE_TEX_GEN3,
NOUVEAU_STATE_TEX_MAT0,
NOUVEAU_STATE_TEX_MAT1,
NOUVEAU_STATE_TEX_MAT2,
NOUVEAU_STATE_TEX_MAT3,
NOUVEAU_STATE_TEX_OBJ0,
NOUVEAU_STATE_TEX_OBJ1,
NOUVEAU_STATE_TEX_OBJ2,
NOUVEAU_STATE_TEX_OBJ3,
NOUVEAU_STATE_VIEWPORT,
NUM_NOUVEAU_STATE,
/* Room for card-specific states. */
MAX_NOUVEAU_STATE = NUM_NOUVEAU_STATE + 16,
};
typedef void (*nouveau_state_func)(struct gl_context *ctx, int emit);
void
nouveau_state_init(struct gl_context *ctx);
void
nouveau_emit_nothing(struct gl_context *ctx, int emit);
int
nouveau_next_dirty_state(struct gl_context *ctx);
void
nouveau_state_emit(struct gl_context *ctx);
#endif

View File

@ -1,92 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_util.h"
#include "main/formats.h"
void
nouveau_surface_alloc(struct gl_context *ctx, struct nouveau_surface *s,
enum nouveau_surface_layout layout,
unsigned flags, unsigned format,
unsigned width, unsigned height)
{
union nouveau_bo_config config = {};
int ret, cpp = _mesa_get_format_bytes(format);
nouveau_bo_ref(NULL, &s->bo);
*s = (struct nouveau_surface) {
.layout = layout,
.format = format,
.width = width,
.height = height,
.cpp = cpp,
.pitch = _mesa_format_row_stride(format, width),
};
if (layout == TILED) {
s->pitch = align(s->pitch, 256);
config.nv04.surf_pitch = s->pitch;
if (cpp == 4)
config.nv04.surf_flags = NV04_BO_32BPP;
else if (cpp == 2)
config.nv04.surf_flags = NV04_BO_16BPP;
if (_mesa_get_format_bits(format, GL_DEPTH_BITS))
config.nv04.surf_flags |= NV04_BO_ZETA;
} else {
s->pitch = align(s->pitch, 64);
}
ret = nouveau_bo_new(context_dev(ctx), flags, 0,
get_format_blocksy(format, height) * s->pitch,
&config, &s->bo);
assert(!ret);
}
void
nouveau_surface_ref(struct nouveau_surface *src,
struct nouveau_surface *dst)
{
if (src) {
dst->offset = src->offset;
dst->layout = src->layout;
dst->format = src->format;
dst->width = src->width;
dst->height = src->height;
dst->cpp = src->cpp;
dst->pitch = src->pitch;
nouveau_bo_ref(src->bo, &dst->bo);
} else {
nouveau_bo_ref(NULL, &dst->bo);
}
}

View File

@ -1,58 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_SURFACE_H__
#define __NOUVEAU_SURFACE_H__
enum nouveau_surface_layout {
LINEAR = 0,
TILED,
SWIZZLED,
};
struct nouveau_surface {
struct nouveau_bo *bo;
unsigned offset;
enum nouveau_surface_layout layout;
mesa_format format;
unsigned cpp, pitch;
unsigned width, height;
};
void
nouveau_surface_alloc(struct gl_context *ctx, struct nouveau_surface *s,
enum nouveau_surface_layout layout,
unsigned flags, unsigned format,
unsigned width, unsigned height);
void
nouveau_surface_ref(struct nouveau_surface *src,
struct nouveau_surface *dst);
#endif

View File

@ -1,349 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#include "tnl/t_vertex.h"
#define SWTNL_VBO_SIZE 65536
static enum tnl_attr_format
swtnl_get_format(int type, int fields) {
switch (type) {
case GL_FLOAT:
switch (fields){
case 1:
return EMIT_1F;
case 2:
return EMIT_2F;
case 3:
return EMIT_3F;
case 4:
return EMIT_4F;
default:
assert(0);
}
case GL_UNSIGNED_BYTE:
switch (fields) {
case 4:
return EMIT_4UB_4F_RGBA;
default:
assert(0);
}
default:
assert(0);
}
}
static struct swtnl_attr_info {
int type;
int fields;
} swtnl_attrs[VERT_ATTRIB_MAX] = {
[VERT_ATTRIB_POS] = {
.type = GL_FLOAT,
.fields = 4,
},
[VERT_ATTRIB_NORMAL] = {
.type = GL_FLOAT,
.fields = -1,
},
[VERT_ATTRIB_COLOR0] = {
.type = GL_UNSIGNED_BYTE,
.fields = 4,
},
[VERT_ATTRIB_COLOR1] = {
.type = GL_UNSIGNED_BYTE,
.fields = 4,
},
[VERT_ATTRIB_FOG] = {
.type = GL_FLOAT,
.fields = 1,
},
[VERT_ATTRIB_TEX0] = {
.type = GL_FLOAT,
.fields = -1,
},
[VERT_ATTRIB_TEX1] = {
.type = GL_FLOAT,
.fields = -1,
},
[VERT_ATTRIB_TEX2] = {
.type = GL_FLOAT,
.fields = -1,
},
[VERT_ATTRIB_TEX3] = {
.type = GL_FLOAT,
.fields = -1,
},
};
static void
swtnl_choose_attrs(struct gl_context *ctx)
{
struct nouveau_render_state *render = to_render_state(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct tnl_clipspace *vtx = &tnl->clipspace;
static struct tnl_attr_map map[NUM_VERTEX_ATTRS];
int fields, attr, i, n = 0;
render->mode = VBO;
render->attr_count = NUM_VERTEX_ATTRS;
/* We always want non Ndc coords format */
tnl->vb.AttribPtr[VERT_ATTRIB_POS] = tnl->vb.ClipPtr;
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
struct nouveau_attr_info *ha = &TAG(vertex_attrs)[i];
struct swtnl_attr_info *sa = &swtnl_attrs[i];
struct nouveau_array *a = &render->attrs[i];
if (!sa->fields)
continue; /* Unsupported attribute. */
if (tnl->render_inputs_bitset & BITFIELD64_BIT(i)) {
if (sa->fields > 0)
fields = sa->fields;
else
fields = tnl->vb.AttribPtr[i]->size;
map[n++] = (struct tnl_attr_map) {
.attrib = i,
.format = swtnl_get_format(sa->type, fields),
};
render->map[ha->vbo_index] = i;
a->attr = i;
a->fields = fields;
a->type = sa->type;
}
}
_tnl_install_attrs(ctx, map, n, NULL, 0);
FOR_EACH_BOUND_ATTR(render, i, attr)
render->attrs[attr].stride = vtx->vertex_size;
TAG(render_set_format)(ctx);
}
static void
swtnl_alloc_vertices(struct gl_context *ctx)
{
struct nouveau_swtnl_state *swtnl = &to_render_state(ctx)->swtnl;
nouveau_bo_ref(NULL, &swtnl->vbo);
swtnl->buf = nouveau_get_scratch(ctx, SWTNL_VBO_SIZE, &swtnl->vbo,
&swtnl->offset);
swtnl->vertex_count = 0;
}
static void
swtnl_bind_vertices(struct gl_context *ctx)
{
struct nouveau_render_state *render = to_render_state(ctx);
struct nouveau_swtnl_state *swtnl = &render->swtnl;
struct tnl_clipspace *vtx = &TNL_CONTEXT(ctx)->clipspace;
int i;
for (i = 0; i < vtx->attr_count; i++) {
struct tnl_clipspace_attr *ta = &vtx->attr[i];
struct nouveau_array *a = &render->attrs[ta->attrib];
nouveau_bo_ref(swtnl->vbo, &a->bo);
a->offset = swtnl->offset + ta->vertoffset;
}
TAG(render_bind_vertices)(ctx);
}
static void
swtnl_unbind_vertices(struct gl_context *ctx)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i, attr;
TAG(render_release_vertices)(ctx);
FOR_EACH_BOUND_ATTR(render, i, attr) {
nouveau_bo_ref(NULL, &render->attrs[attr].bo);
render->map[i] = -1;
}
render->attr_count = 0;
}
static void
swtnl_flush_vertices(struct gl_context *ctx)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_swtnl_state *swtnl = &to_render_state(ctx)->swtnl;
unsigned npush, start = 0, count = swtnl->vertex_count;
RENDER_LOCALS(ctx);
swtnl_bind_vertices(ctx);
while (count) {
npush = get_max_vertices(ctx, NULL, PUSH_AVAIL(push));
npush = MIN2(npush / 12 * 12, count);
count -= npush;
if (!npush) {
PUSH_KICK(push);
continue;
}
BATCH_BEGIN(nvgl_primitive(swtnl->primitive));
EMIT_VBO(L, ctx, start, 0, npush);
BATCH_END();
PUSH_KICK(push);
}
swtnl_alloc_vertices(ctx);
}
/* TnL renderer entry points */
static void
swtnl_start(struct gl_context *ctx)
{
swtnl_choose_attrs(ctx);
}
static void
swtnl_finish(struct gl_context *ctx)
{
swtnl_flush_vertices(ctx);
swtnl_unbind_vertices(ctx);
}
static void
swtnl_primitive(struct gl_context *ctx, GLenum mode)
{
}
static void
swtnl_reset_stipple(struct gl_context *ctx)
{
}
/* Primitive rendering */
#define BEGIN_PRIMITIVE(p, n) \
struct nouveau_swtnl_state *swtnl = &to_render_state(ctx)->swtnl; \
int vertex_len = TNL_CONTEXT(ctx)->clipspace.vertex_size; \
\
if (swtnl->vertex_count + (n) > SWTNL_VBO_SIZE/vertex_len \
|| (swtnl->vertex_count && swtnl->primitive != p)) \
swtnl_flush_vertices(ctx); \
\
swtnl->primitive = p;
#define OUT_VERTEX(i) do { \
memcpy(swtnl->buf + swtnl->vertex_count * vertex_len, \
_tnl_get_vertex(ctx, (i)), vertex_len); \
swtnl->vertex_count++; \
} while (0)
static void
swtnl_points(struct gl_context *ctx, GLuint first, GLuint last)
{
int i, count;
while (first < last) {
BEGIN_PRIMITIVE(GL_POINTS, last - first);
count = MIN2(SWTNL_VBO_SIZE / vertex_len, last - first);
for (i = 0; i < count; i++)
OUT_VERTEX(first + i);
first += count;
}
}
static void
swtnl_line(struct gl_context *ctx, GLuint v1, GLuint v2)
{
BEGIN_PRIMITIVE(GL_LINES, 2);
OUT_VERTEX(v1);
OUT_VERTEX(v2);
}
static void
swtnl_triangle(struct gl_context *ctx, GLuint v1, GLuint v2, GLuint v3)
{
BEGIN_PRIMITIVE(GL_TRIANGLES, 3);
OUT_VERTEX(v1);
OUT_VERTEX(v2);
OUT_VERTEX(v3);
}
static void
swtnl_quad(struct gl_context *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint v4)
{
BEGIN_PRIMITIVE(GL_QUADS, 4);
OUT_VERTEX(v1);
OUT_VERTEX(v2);
OUT_VERTEX(v3);
OUT_VERTEX(v4);
}
/* TnL initialization. */
void
TAG(swtnl_init)(struct gl_context *ctx)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
tnl->Driver.RunPipeline = _tnl_run_pipeline;
tnl->Driver.Render.Interp = _tnl_interp;
tnl->Driver.Render.CopyPV = _tnl_copy_pv;
tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine;
tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
tnl->Driver.Render.Start = swtnl_start;
tnl->Driver.Render.Finish = swtnl_finish;
tnl->Driver.Render.PrimitiveNotify = swtnl_primitive;
tnl->Driver.Render.ResetLineStipple = swtnl_reset_stipple;
tnl->Driver.Render.Points = swtnl_points;
tnl->Driver.Render.Line = swtnl_line;
tnl->Driver.Render.Triangle = swtnl_triangle;
tnl->Driver.Render.Quad = swtnl_quad;
_tnl_init_vertices(ctx, tnl->vb.Size,
NUM_VERTEX_ATTRS * 4 * sizeof(GLfloat));
_tnl_need_projected_coords(ctx, GL_FALSE);
_tnl_allow_vertex_fog(ctx, GL_FALSE);
swtnl_alloc_vertices(ctx);
}
void
TAG(swtnl_destroy)(struct gl_context *ctx)
{
nouveau_bo_ref(NULL, &to_render_state(ctx)->swtnl.vbo);
}

View File

@ -1,700 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_texture.h"
#include "nouveau_fbo.h"
#include "nouveau_util.h"
#include "main/pbo.h"
#include "main/texobj.h"
#include "main/texstore.h"
#include "main/texformat.h"
#include "main/texcompress.h"
#include "main/texgetimage.h"
#include "main/mipmap.h"
#include "main/teximage.h"
#include "util/u_memory.h"
#include "drivers/common/meta.h"
#include "swrast/s_texfetch.h"
#include "util/macros.h"
static struct gl_texture_object *
nouveau_texture_new(struct gl_context *ctx, GLuint name, GLenum target)
{
struct nouveau_texture *nt = CALLOC_STRUCT(nouveau_texture);
_mesa_initialize_texture_object(ctx, &nt->base, name, target);
return &nt->base;
}
static void
nouveau_texture_free(struct gl_context *ctx, struct gl_texture_object *t)
{
struct nouveau_texture *nt = to_nouveau_texture(t);
int i;
for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
nouveau_surface_ref(NULL, &nt->surfaces[i]);
_mesa_delete_texture_object(ctx, t);
}
static struct gl_texture_image *
nouveau_teximage_new(struct gl_context *ctx)
{
struct nouveau_teximage *nti = CALLOC_STRUCT(nouveau_teximage);
return &nti->base.Base;
}
static void
nouveau_teximage_free(struct gl_context *ctx, struct gl_texture_image *ti)
{
struct nouveau_teximage *nti = to_nouveau_teximage(ti);
nouveau_surface_ref(NULL, &nti->surface);
}
static void
nouveau_map_texture_image(struct gl_context *ctx,
struct gl_texture_image *ti,
GLuint slice,
GLuint x, GLuint y, GLuint w, GLuint h,
GLbitfield mode,
GLubyte **map,
GLint *stride)
{
struct nouveau_teximage *nti = to_nouveau_teximage(ti);
struct nouveau_surface *s = &nti->surface;
struct nouveau_surface *st = &nti->transfer.surface;
struct nouveau_client *client = context_client(ctx);
/* Nouveau has no support for 3D or cubemap textures. */
assert(slice == 0);
if (s->bo) {
if (!(mode & GL_MAP_READ_BIT) &&
nouveau_pushbuf_refd(context_push(ctx), s->bo)) {
unsigned size;
/*
* Heuristic: use a bounce buffer to pipeline
* teximage transfers.
*/
st->layout = LINEAR;
st->format = s->format;
st->cpp = s->cpp;
st->width = w;
st->height = h;
st->pitch = s->pitch;
nti->transfer.x = x;
nti->transfer.y = y;
size = get_format_blocksy(st->format, h) * st->pitch;
*map = nouveau_get_scratch(ctx, size,
&st->bo, &st->offset);
*stride = st->pitch;
} else {
int ret, flags = 0;
if (mode & GL_MAP_READ_BIT)
flags |= NOUVEAU_BO_RD;
if (mode & GL_MAP_WRITE_BIT)
flags |= NOUVEAU_BO_WR;
if (!s->bo->map) {
ret = nouveau_bo_map(s->bo, flags, client);
assert(!ret);
}
*map = s->bo->map +
get_format_blocksy(s->format, y) * s->pitch +
get_format_blocksx(s->format, x) * s->cpp;
*stride = s->pitch;
}
} else {
*map = nti->base.Buffer +
get_format_blocksy(s->format, y) * s->pitch +
get_format_blocksx(s->format, x) * s->cpp;
*stride = s->pitch;
}
}
static void
nouveau_unmap_texture_image(struct gl_context *ctx, struct gl_texture_image *ti,
GLuint slice)
{
struct nouveau_teximage *nti = to_nouveau_teximage(ti);
struct nouveau_surface *s = &nti->surface;
struct nouveau_surface *st = &nti->transfer.surface;
if (st->bo) {
context_drv(ctx)->surface_copy(ctx, s, st, nti->transfer.x,
nti->transfer.y, 0, 0,
st->width, st->height);
nouveau_surface_ref(NULL, st);
}
}
static mesa_format
nouveau_choose_tex_format(struct gl_context *ctx, GLenum target,
GLint internalFormat,
GLenum srcFormat, GLenum srcType)
{
switch (internalFormat) {
case 4:
case GL_RGBA:
case GL_RGBA2:
case GL_RGBA4:
case GL_RGBA8:
case GL_RGBA12:
case GL_RGBA16:
case GL_RGB10_A2:
case GL_COMPRESSED_RGBA:
return MESA_FORMAT_B8G8R8A8_UNORM;
case GL_RGB5_A1:
return MESA_FORMAT_B5G5R5A1_UNORM;
case GL_RGB:
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
case GL_COMPRESSED_RGB:
return MESA_FORMAT_B8G8R8X8_UNORM;
case 3:
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
return MESA_FORMAT_B5G6R5_UNORM;
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE4_ALPHA4:
case GL_LUMINANCE6_ALPHA2:
case GL_LUMINANCE12_ALPHA4:
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
case GL_LUMINANCE8_ALPHA8:
case GL_COMPRESSED_LUMINANCE_ALPHA:
return MESA_FORMAT_B8G8R8A8_UNORM;
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE4:
case GL_LUMINANCE12:
case GL_LUMINANCE16:
case GL_LUMINANCE8:
case GL_COMPRESSED_LUMINANCE:
return MESA_FORMAT_L_UNORM8;
case GL_ALPHA:
case GL_ALPHA4:
case GL_ALPHA12:
case GL_ALPHA16:
case GL_ALPHA8:
case GL_COMPRESSED_ALPHA:
return MESA_FORMAT_A_UNORM8;
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY12:
case GL_INTENSITY16:
case GL_INTENSITY8:
case GL_COMPRESSED_INTENSITY:
return MESA_FORMAT_I_UNORM8;
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
return MESA_FORMAT_RGB_DXT1;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return MESA_FORMAT_RGBA_DXT1;
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
return MESA_FORMAT_RGBA_DXT3;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
return MESA_FORMAT_RGBA_DXT5;
default:
unreachable("Unknown format");
}
}
static GLboolean
teximage_fits(struct gl_texture_object *t, int level)
{
struct nouveau_surface *s = &to_nouveau_texture(t)->surfaces[level];
struct gl_texture_image *ti = t->Image[0][level];
if (!ti || !to_nouveau_teximage(ti)->surface.bo)
return GL_FALSE;
if (level == t->Attrib.BaseLevel && (s->offset & 0x7f))
return GL_FALSE;
return t->Target == GL_TEXTURE_RECTANGLE ||
(s->bo && s->format == ti->TexFormat &&
s->width == ti->Width && s->height == ti->Height);
}
static GLboolean
validate_teximage(struct gl_context *ctx, struct gl_texture_object *t,
int level, int x, int y, int z,
int width, int height, int depth)
{
struct gl_texture_image *ti = t->Image[0][level];
if (teximage_fits(t, level)) {
struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces;
struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
if (t->Target == GL_TEXTURE_RECTANGLE)
nouveau_surface_ref(s, &ss[level]);
else
context_drv(ctx)->surface_copy(ctx, &ss[level], s,
x, y, x, y,
width, height);
return GL_TRUE;
}
return GL_FALSE;
}
static int
get_last_level(struct gl_texture_object *t)
{
struct gl_texture_image *base = t->Image[0][t->Attrib.BaseLevel];
if (t->Sampler.Attrib.MinFilter == GL_NEAREST ||
t->Sampler.Attrib.MinFilter == GL_LINEAR || !base)
return t->Attrib.BaseLevel;
else
return MIN2(t->Attrib.BaseLevel + base->MaxNumLevels - 1, t->Attrib.MaxLevel);
}
static void
relayout_texture(struct gl_context *ctx, struct gl_texture_object *t)
{
struct gl_texture_image *base = t->Image[0][t->Attrib.BaseLevel];
if (base && t->Target != GL_TEXTURE_RECTANGLE) {
struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces;
struct nouveau_surface *s = &to_nouveau_teximage(base)->surface;
int i, ret, last = get_last_level(t);
enum nouveau_surface_layout layout =
(_mesa_is_format_compressed(s->format) ? LINEAR : SWIZZLED);
unsigned size, pitch, offset = 0,
width = s->width,
height = s->height;
/* Deallocate the old storage. */
for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
nouveau_bo_ref(NULL, &ss[i].bo);
/* Relayout the mipmap tree. */
for (i = t->Attrib.BaseLevel; i <= last; i++) {
pitch = _mesa_format_row_stride(s->format, width);
size = get_format_blocksy(s->format, height) * pitch;
/* Images larger than 16B have to be aligned. */
if (size > 16)
offset = align(offset, 64);
ss[i] = (struct nouveau_surface) {
.offset = offset,
.layout = layout,
.format = s->format,
.width = width,
.height = height,
.cpp = s->cpp,
.pitch = pitch,
};
offset += size;
width = minify(width, 1);
height = minify(height, 1);
}
if (t->Attrib.BaseLevel <= last) {
/* Get new storage. */
size = align(offset, 64);
assert(size);
ret = nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_MAP |
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM,
0, size, NULL, &ss[last].bo);
assert(!ret);
for (i = t->Attrib.BaseLevel; i < last; i++)
nouveau_bo_ref(ss[last].bo, &ss[i].bo);
}
}
}
GLboolean
nouveau_texture_validate(struct gl_context *ctx, struct gl_texture_object *t)
{
struct nouveau_texture *nt = to_nouveau_texture(t);
int i, last = get_last_level(t);
if (!teximage_fits(t, t->Attrib.BaseLevel) ||
!teximage_fits(t, last))
return GL_FALSE;
if (nt->dirty) {
nt->dirty = GL_FALSE;
/* Copy the teximages to the actual miptree. */
for (i = t->Attrib.BaseLevel; i <= last; i++) {
struct nouveau_surface *s = &nt->surfaces[i];
validate_teximage(ctx, t, i, 0, 0, 0,
s->width, s->height, 1);
}
PUSH_KICK(context_push(ctx));
}
return GL_TRUE;
}
void
nouveau_texture_reallocate(struct gl_context *ctx, struct gl_texture_object *t)
{
if (!teximage_fits(t, t->Attrib.BaseLevel) ||
!teximage_fits(t, get_last_level(t))) {
texture_dirty(t);
relayout_texture(ctx, t);
nouveau_texture_validate(ctx, t);
}
}
static unsigned
get_teximage_placement(struct gl_texture_image *ti)
{
if (ti->TexFormat == MESA_FORMAT_A_UNORM8 ||
ti->TexFormat == MESA_FORMAT_L_UNORM8 ||
ti->TexFormat == MESA_FORMAT_I_UNORM8)
/* 1 cpp formats will have to be swizzled by the CPU,
* so leave them in system RAM for now. */
return NOUVEAU_BO_MAP;
else
return NOUVEAU_BO_GART | NOUVEAU_BO_MAP;
}
static void
nouveau_compressed_copy(struct gl_context *ctx, GLint dims,
struct gl_texture_image *ti,
GLsizei width, GLsizei height, GLsizei depth,
const GLvoid *src, GLvoid *dst, int row_stride)
{
struct compressed_pixelstore store;
int i;
_mesa_compute_compressed_pixelstore(dims, ti->TexFormat,
width, height, depth,
&ctx->Unpack, &store);
src += store.SkipBytes;
assert(store.CopySlices == 1);
/* copy rows of blocks */
for (i = 0; i < store.CopyRowsPerSlice; i++) {
memcpy(dst, src, store.CopyBytesPerRow);
dst += row_stride;
src += store.TotalBytesPerRow;
}
}
static void
nouveau_teximage(struct gl_context *ctx, GLint dims,
struct gl_texture_image *ti,
GLsizei imageSize,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *packing,
GLboolean compressed)
{
struct gl_texture_object *t = ti->TexObject;
const GLuint level = ti->Level;
struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
struct nouveau_teximage *nti = to_nouveau_teximage(ti);
int ret;
GLuint depth = compressed ? 1 : ti->Depth;
/* Allocate a new bo for the image. */
nouveau_surface_alloc(ctx, s, LINEAR, get_teximage_placement(ti),
ti->TexFormat, ti->Width, ti->Height);
nti->base.RowStride = s->pitch / s->cpp;
if (compressed)
pixels = _mesa_validate_pbo_compressed_teximage(ctx,
dims, imageSize,
pixels, packing, "glCompressedTexImage");
else
pixels = _mesa_validate_pbo_teximage(ctx,
dims, ti->Width, ti->Height, depth, format, type,
pixels, packing, "glTexImage");
if (pixels) {
GLubyte *map;
int row_stride;
/* Store the pixel data. */
nouveau_map_texture_image(ctx, ti, 0,
0, 0, ti->Width, ti->Height,
GL_MAP_WRITE_BIT,
&map, &row_stride);
if (compressed) {
nouveau_compressed_copy(ctx, dims, ti,
ti->Width, ti->Height, depth,
pixels, map, row_stride);
} else {
ret = _mesa_texstore(ctx, dims, ti->_BaseFormat,
ti->TexFormat,
row_stride,
&map,
ti->Width, ti->Height, depth,
format, type, pixels, packing);
assert(ret);
}
nouveau_unmap_texture_image(ctx, ti, 0);
_mesa_unmap_teximage_pbo(ctx, packing);
if (!validate_teximage(ctx, t, level, 0, 0, 0,
ti->Width, ti->Height, depth))
/* It doesn't fit, mark it as dirty. */
texture_dirty(t);
}
if (level == t->Attrib.BaseLevel) {
if (!teximage_fits(t, level))
relayout_texture(ctx, t);
nouveau_texture_validate(ctx, t);
}
context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit);
}
static void
nouveau_teximage_123d(struct gl_context *ctx, GLuint dims,
struct gl_texture_image *ti,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *packing)
{
nouveau_teximage(ctx, dims, ti, 0, format, type, pixels,
packing, GL_FALSE);
}
static void
nouveau_compressed_teximage(struct gl_context *ctx, GLuint dims,
struct gl_texture_image *ti,
GLsizei imageSize, const GLvoid *data)
{
nouveau_teximage(ctx, 2, ti, imageSize, 0, 0, data,
&ctx->Unpack, GL_TRUE);
}
static GLboolean
nouveau_teximage_alloc(struct gl_context *ctx, struct gl_texture_image *ti)
{
nouveau_teximage(ctx, 3, ti, 0, 0, 0, NULL,
&ctx->DefaultPacking,
_mesa_is_format_compressed(ti->TexFormat));
return GL_TRUE;
}
static void
nouveau_texsubimage(struct gl_context *ctx, GLint dims,
struct gl_texture_image *ti,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
GLsizei imageSize,
GLenum format, GLenum type, const void *pixels,
const struct gl_pixelstore_attrib *packing,
GLboolean compressed)
{
int ret;
if (compressed)
pixels = _mesa_validate_pbo_compressed_teximage(ctx,
dims, imageSize,
pixels, packing, "glCompressedTexSubImage");
else
pixels = _mesa_validate_pbo_teximage(ctx,
dims, width, height, depth, format, type,
pixels, packing, "glTexSubImage");
if (pixels) {
GLubyte *map;
int row_stride;
nouveau_map_texture_image(ctx, ti, 0,
xoffset, yoffset, width, height,
GL_MAP_WRITE_BIT, &map, &row_stride);
if (compressed) {
nouveau_compressed_copy(ctx, dims, ti,
width, height, depth,
pixels, map, row_stride);
} else {
ret = _mesa_texstore(ctx, dims, ti->_BaseFormat,
ti->TexFormat,
row_stride, &map,
width, height, depth,
format, type, pixels, packing);
assert(ret);
}
nouveau_unmap_texture_image(ctx, ti, 0);
_mesa_unmap_teximage_pbo(ctx, packing);
}
if (!to_nouveau_texture(ti->TexObject)->dirty)
validate_teximage(ctx, ti->TexObject, ti->Level,
xoffset, yoffset, zoffset,
width, height, depth);
}
static void
nouveau_texsubimage_123d(struct gl_context *ctx, GLuint dims,
struct gl_texture_image *ti,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
GLenum format, GLenum type, const void *pixels,
const struct gl_pixelstore_attrib *packing)
{
nouveau_texsubimage(ctx, dims, ti, xoffset, yoffset, zoffset,
width, height, depth, 0, format, type, pixels,
packing, GL_FALSE);
}
static void
nouveau_compressed_texsubimage(struct gl_context *ctx, GLuint dims,
struct gl_texture_image *ti,
GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLint height, GLint depth,
GLenum format,
GLint imageSize, const void *data)
{
nouveau_texsubimage(ctx, dims, ti, xoffset, yoffset, zoffset,
width, height, depth, imageSize, format, 0, data,
&ctx->Unpack, GL_TRUE);
}
static void
nouveau_bind_texture(struct gl_context *ctx, GLuint texUnit,
GLenum target, struct gl_texture_object *t)
{
context_dirty_i(ctx, TEX_OBJ, texUnit);
context_dirty_i(ctx, TEX_ENV, texUnit);
}
static mesa_format
get_texbuffer_format(struct gl_renderbuffer *rb, GLint format)
{
struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
if (s->cpp < 4)
return s->format;
else if (format == __DRI_TEXTURE_FORMAT_RGBA)
return MESA_FORMAT_B8G8R8A8_UNORM;
else
return MESA_FORMAT_B8G8R8X8_UNORM;
}
void
nouveau_set_texbuffer(__DRIcontext *dri_ctx,
GLint target, GLint format,
__DRIdrawable *draw)
{
struct nouveau_context *nctx = dri_ctx->driverPrivate;
struct gl_context *ctx = &nctx->base;
struct gl_framebuffer *fb = draw->driverPrivate;
struct gl_renderbuffer *rb =
fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
struct gl_texture_object *t = _mesa_get_current_tex_object(ctx, target);
struct gl_texture_image *ti;
struct nouveau_teximage *nti;
struct nouveau_surface *s;
_mesa_lock_texture(ctx, t);
ti = _mesa_get_tex_image(ctx, t, target, 0);
nti = to_nouveau_teximage(ti);
s = &to_nouveau_teximage(ti)->surface;
/* Update the texture surface with the given drawable. */
nouveau_update_renderbuffers(dri_ctx, draw);
nouveau_surface_ref(&to_nouveau_renderbuffer(rb)->surface, s);
s->format = get_texbuffer_format(rb, format);
/* Update the image fields. */
_mesa_init_teximage_fields(ctx, ti, s->width, s->height,
1, 0, s->cpp, s->format);
nti->base.RowStride = s->pitch / s->cpp;
/* Try to validate it. */
if (!validate_teximage(ctx, t, 0, 0, 0, 0, s->width, s->height, 1))
nouveau_texture_reallocate(ctx, t);
context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit);
_mesa_unlock_texture(ctx, t);
}
void
nouveau_texture_functions_init(struct dd_function_table *functions)
{
functions->NewTextureObject = nouveau_texture_new;
functions->DeleteTexture = nouveau_texture_free;
functions->NewTextureImage = nouveau_teximage_new;
functions->FreeTextureImageBuffer = nouveau_teximage_free;
functions->AllocTextureImageBuffer = nouveau_teximage_alloc;
functions->ChooseTextureFormat = nouveau_choose_tex_format;
functions->TexImage = nouveau_teximage_123d;
functions->TexSubImage = nouveau_texsubimage_123d;
functions->CompressedTexImage = nouveau_compressed_teximage;
functions->CompressedTexSubImage = nouveau_compressed_texsubimage;
functions->BindTexture = nouveau_bind_texture;
functions->MapTextureImage = nouveau_map_texture_image;
functions->UnmapTextureImage = nouveau_unmap_texture_image;
}

View File

@ -1,63 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_TEXTURE_H__
#define __NOUVEAU_TEXTURE_H__
#include "swrast/s_context.h"
struct nouveau_teximage {
struct swrast_texture_image base;
struct nouveau_surface surface;
struct {
struct nouveau_surface surface;
int x, y;
} transfer;
};
#define to_nouveau_teximage(x) ((struct nouveau_teximage *)(x))
struct nouveau_texture {
struct gl_texture_object base;
struct nouveau_surface surfaces[MAX_TEXTURE_LEVELS];
GLboolean dirty;
};
#define to_nouveau_texture(x) ((struct nouveau_texture *)(x))
#define texture_dirty(t) \
to_nouveau_texture(t)->dirty = GL_TRUE
void
nouveau_set_texbuffer(__DRIcontext *dri_ctx,
GLint target, GLint format,
__DRIdrawable *draw);
GLboolean
nouveau_texture_validate(struct gl_context *ctx, struct gl_texture_object *t);
void
nouveau_texture_reallocate(struct gl_context *ctx, struct gl_texture_object *t);
#endif

View File

@ -1,233 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NOUVEAU_UTIL_H__
#define __NOUVEAU_UTIL_H__
#include "main/formats.h"
#include "main/colormac.h"
static inline unsigned
pack_rgba_i(mesa_format f, const uint8_t c[])
{
switch (f) {
case MESA_FORMAT_B8G8R8A8_UNORM:
return PACK_COLOR_8888(c[ACOMP], c[RCOMP], c[GCOMP], c[BCOMP]);
case MESA_FORMAT_A8R8G8B8_UNORM:
return PACK_COLOR_8888(c[BCOMP], c[GCOMP], c[RCOMP], c[ACOMP]);
case MESA_FORMAT_B8G8R8X8_UNORM:
return PACK_COLOR_8888(0, c[RCOMP], c[GCOMP], c[BCOMP]);
case MESA_FORMAT_X8R8G8B8_UNORM:
return PACK_COLOR_8888(c[BCOMP], c[GCOMP], c[RCOMP], 0);
case MESA_FORMAT_A8B8G8R8_UNORM:
return PACK_COLOR_8888(c[RCOMP], c[GCOMP], c[BCOMP], c[ACOMP]);
case MESA_FORMAT_R8G8B8A8_UNORM:
return PACK_COLOR_8888(c[ACOMP], c[BCOMP], c[GCOMP], c[RCOMP]);
case MESA_FORMAT_B5G6R5_UNORM:
return PACK_COLOR_565(c[RCOMP], c[GCOMP], c[BCOMP]);
default:
assert(0);
}
}
static inline unsigned
pack_zs_i(mesa_format f, uint32_t z, uint8_t s)
{
switch (f) {
case MESA_FORMAT_S8_UINT_Z24_UNORM:
return (z & 0xffffff00) | (s & 0xff);
case MESA_FORMAT_X8_UINT_Z24_UNORM:
return (z & 0xffffff00);
case MESA_FORMAT_Z_UNORM16:
return (z & 0xffff0000) >> 16;
default:
assert(0);
}
}
static inline unsigned
pack_rgba_f(mesa_format f, const float c[])
{
return pack_rgba_i(f, (uint8_t []) {
FLOAT_TO_UBYTE(c[RCOMP]),
FLOAT_TO_UBYTE(c[GCOMP]),
FLOAT_TO_UBYTE(c[BCOMP]),
FLOAT_TO_UBYTE(c[ACOMP]) });
}
static inline unsigned
pack_rgba_clamp_f(mesa_format f, const float c[])
{
GLubyte bytes[4];
_mesa_unclamped_float_rgba_to_ubyte(bytes, c);
return pack_rgba_i(f, bytes);
}
static inline unsigned
pack_zs_f(mesa_format f, float z, uint8_t s)
{
return pack_zs_i(f, FLOAT_TO_UINT(z), s);
}
static inline unsigned
pack_la_clamp_f(mesa_format f, float l, float a)
{
GLubyte lb, ab;
UNCLAMPED_FLOAT_TO_UBYTE(lb, l);
UNCLAMPED_FLOAT_TO_UBYTE(ab, a);
return pack_rgba_i(f, (uint8_t []) { lb, lb, lb, ab });
}
/* Integer base-2 logarithm, rounded towards zero. */
static inline unsigned
log2i(unsigned i)
{
unsigned r = 0;
if (i & 0xffff0000) {
i >>= 16;
r += 16;
}
if (i & 0x0000ff00) {
i >>= 8;
r += 8;
}
if (i & 0x000000f0) {
i >>= 4;
r += 4;
}
if (i & 0x0000000c) {
i >>= 2;
r += 2;
}
if (i & 0x00000002) {
r += 1;
}
return r;
}
static inline void
get_scissors(struct gl_framebuffer *fb, int *x, int *y, int *w, int *h)
{
*w = fb->_Xmax - fb->_Xmin;
*h = fb->_Ymax - fb->_Ymin;
*x = fb->_Xmin;
*y = (fb->Name ? fb->_Ymin :
/* Window system FBO: Flip the Y coordinate. */
fb->Height - fb->_Ymax);
}
static inline void
get_viewport_scale(struct gl_context *ctx, float a[16])
{
struct gl_viewport_attrib *vp = &ctx->ViewportArray[0];
struct gl_framebuffer *fb = ctx->DrawBuffer;
a[MAT_SX] = (float)vp->Width / 2;
if (fb->Name)
a[MAT_SY] = (float)vp->Height / 2;
else
/* Window system FBO: Flip the Y coordinate. */
a[MAT_SY] = - (float)vp->Height / 2;
a[MAT_SZ] = fb->_DepthMaxF * (vp->Far - vp->Near) / 2;
}
static inline void
get_viewport_translate(struct gl_context *ctx, float a[4])
{
struct gl_viewport_attrib *vp = &ctx->ViewportArray[0];
struct gl_framebuffer *fb = ctx->DrawBuffer;
a[0] = (float)vp->Width / 2 + vp->X;
if (fb->Name)
a[1] = (float)vp->Height / 2 + vp->Y;
else
/* Window system FBO: Flip the Y coordinate. */
a[1] = fb->Height - (float)vp->Height / 2 - vp->Y;
a[2] = fb->_DepthMaxF * (vp->Far + vp->Near) / 2;
}
static inline GLboolean
is_color_operand(int op)
{
return op == GL_SRC_COLOR || op == GL_ONE_MINUS_SRC_COLOR;
}
static inline GLboolean
is_negative_operand(int op)
{
return op == GL_ONE_MINUS_SRC_COLOR || op == GL_ONE_MINUS_SRC_ALPHA;
}
static inline GLboolean
is_texture_source(int s)
{
return s == GL_TEXTURE || (s >= GL_TEXTURE0 && s <= GL_TEXTURE31);
}
static inline struct gl_texgen *
get_texgen_coord(struct gl_fixedfunc_texture_unit *u, int i)
{
return ((struct gl_texgen *[])
{ &u->GenS, &u->GenT, &u->GenR, &u->GenQ }) [i];
}
static inline float *
get_texgen_coeff(struct gl_fixedfunc_texture_unit *u, GLenum mode, unsigned chan)
{
if (mode == GL_OBJECT_LINEAR)
return u->ObjectPlane[chan];
else if (mode == GL_EYE_LINEAR)
return u->EyePlane[chan];
else
return NULL;
}
static inline unsigned
get_format_blocksx(mesa_format format,
unsigned x)
{
GLuint blockwidth;
GLuint blockheight;
_mesa_get_format_block_size(format, &blockwidth, &blockheight);
return (x + blockwidth - 1) / blockwidth;
}
static inline unsigned
get_format_blocksy(mesa_format format,
unsigned y)
{
GLuint blockwidth;
GLuint blockheight;
_mesa_get_format_block_size(format, &blockwidth, &blockheight);
return (y + blockheight - 1) / blockheight;
}
#endif

View File

@ -1,578 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_bufferobj.h"
#include "nouveau_util.h"
#include "main/bufferobj.h"
#include "main/glformats.h"
#include "main/varray.h"
#include "main/image.h"
/* Arbitrary pushbuf length we can assume we can get with a single
* call to WAIT_RING. */
#define PUSHBUF_DWORDS 65536
/* Functions to turn GL arrays or index buffers into nouveau_array
* structures. */
static int
get_array_stride(struct gl_context *ctx, const struct tnl_vertex_array *a)
{
struct nouveau_render_state *render = to_render_state(ctx);
const struct gl_vertex_buffer_binding *binding = a->BufferBinding;
if (render->mode == VBO && !binding->BufferObj) {
const struct gl_array_attributes *attrib = a->VertexAttrib;
/* Pack client buffers. */
return align(attrib->Format._ElementSize, 4);
} else {
return binding->Stride;
}
}
static void
vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
const struct tnl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
GLboolean imm = (render->mode == IMM);
int i, attr;
if (ib) {
GLenum ib_type;
if (ib->index_size_shift == 2)
ib_type = GL_UNSIGNED_INT;
else if (ib->index_size_shift == 1)
ib_type = GL_UNSIGNED_SHORT;
else
ib_type = GL_UNSIGNED_BYTE;
nouveau_init_array(&render->ib, 0, 0, ib->count, ib_type,
ib->obj, ib->ptr, GL_TRUE, ctx);
}
FOR_EACH_BOUND_ATTR(render, i, attr) {
const struct tnl_vertex_array *array = &arrays[attr];
const struct gl_vertex_buffer_binding *binding =
array->BufferBinding;
const struct gl_array_attributes *attrib = array->VertexAttrib;
const GLubyte *p = _mesa_vertex_attrib_address(attrib, binding);
nouveau_init_array(&render->attrs[attr], attr,
get_array_stride(ctx, array),
attrib->Format.Size, attrib->Format.Type,
imm ? binding->BufferObj : NULL,
p, imm, ctx);
}
}
static void
vbo_deinit_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
const struct tnl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i, attr;
if (ib)
nouveau_cleanup_array(&render->ib);
FOR_EACH_BOUND_ATTR(render, i, attr) {
struct nouveau_array *a = &render->attrs[attr];
if (render->mode == IMM)
nouveau_bo_ref(NULL, &a->bo);
nouveau_deinit_array(a);
render->map[i] = -1;
}
render->attr_count = 0;
}
/* Make some rendering decisions from the GL context. */
static void
vbo_choose_render_mode(struct gl_context *ctx, const struct tnl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i;
render->mode = VBO;
if (ctx->Light.Enabled) {
for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
if (arrays[VERT_ATTRIB_MAT(i)].BufferBinding->Stride) {
render->mode = IMM;
break;
}
}
}
}
static void
vbo_emit_attr(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
int attr)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_render_state *render = to_render_state(ctx);
const struct tnl_vertex_array *array = &arrays[attr];
const struct gl_vertex_buffer_binding *binding = array->BufferBinding;
const struct gl_array_attributes *attrib = array->VertexAttrib;
const GLubyte *p = _mesa_vertex_attrib_address(attrib, binding);
struct nouveau_array *a = &render->attrs[attr];
RENDER_LOCALS(ctx);
if (!binding->Stride) {
if (attr >= VERT_ATTRIB_MAT(0))
/* nouveau_update_state takes care of materials. */
return;
/* Constant attribute. */
nouveau_init_array(a, attr, binding->Stride, attrib->Format.Size,
attrib->Format.Type, binding->BufferObj, p,
GL_TRUE, ctx);
EMIT_IMM(ctx, a, 0);
nouveau_deinit_array(a);
} else {
/* Varying attribute. */
struct nouveau_attr_info *info = &TAG(vertex_attrs)[attr];
if (render->mode == VBO) {
render->map[info->vbo_index] = attr;
render->vertex_size += attrib->Format._ElementSize;
render->attr_count = MAX2(render->attr_count,
info->vbo_index + 1);
} else {
render->map[render->attr_count++] = attr;
render->vertex_size += 4 * info->imm_fields;
}
}
}
#define MAT(a) VERT_ATTRIB_MAT(MAT_ATTRIB_##a)
static void
vbo_choose_attrs(struct gl_context *ctx, const struct tnl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i;
/* Reset the vertex size. */
render->vertex_size = 0;
render->attr_count = 0;
vbo_emit_attr(ctx, arrays, VERT_ATTRIB_COLOR0);
if (ctx->Fog.ColorSumEnabled && !ctx->Light.Enabled)
vbo_emit_attr(ctx, arrays, VERT_ATTRIB_COLOR1);
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
if (ctx->Texture._EnabledCoordUnits & (1 << i))
vbo_emit_attr(ctx, arrays, VERT_ATTRIB_TEX0 + i);
}
if (ctx->Fog.Enabled && ctx->Fog.FogCoordinateSource == GL_FOG_COORD)
vbo_emit_attr(ctx, arrays, VERT_ATTRIB_FOG);
if (ctx->Light.Enabled ||
(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS))
vbo_emit_attr(ctx, arrays, VERT_ATTRIB_NORMAL);
if (ctx->Light.Enabled && render->mode == IMM) {
vbo_emit_attr(ctx, arrays, MAT(FRONT_AMBIENT));
vbo_emit_attr(ctx, arrays, MAT(FRONT_DIFFUSE));
vbo_emit_attr(ctx, arrays, MAT(FRONT_SPECULAR));
vbo_emit_attr(ctx, arrays, MAT(FRONT_SHININESS));
if (ctx->Light.Model.TwoSide) {
vbo_emit_attr(ctx, arrays, MAT(BACK_AMBIENT));
vbo_emit_attr(ctx, arrays, MAT(BACK_DIFFUSE));
vbo_emit_attr(ctx, arrays, MAT(BACK_SPECULAR));
vbo_emit_attr(ctx, arrays, MAT(BACK_SHININESS));
}
}
vbo_emit_attr(ctx, arrays, VERT_ATTRIB_POS);
}
static int
get_max_client_stride(struct gl_context *ctx, const struct tnl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i, attr, s = 0;
FOR_EACH_BOUND_ATTR(render, i, attr) {
const struct tnl_vertex_array *a = &arrays[attr];
if (!a->BufferBinding->BufferObj)
s = MAX2(s, get_array_stride(ctx, a));
}
return s;
}
static void
TAG(vbo_render_prims)(struct gl_context *ctx,
const struct tnl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
GLuint min_index, GLuint max_index,
GLuint num_instances, GLuint base_instance);
static GLboolean
vbo_maybe_split(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index, GLuint max_index,
GLuint num_instances, GLuint base_instance)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_render_state *render = to_render_state(ctx);
struct nouveau_bufctx *bufctx = nctx->hw.bufctx;
unsigned pushbuf_avail = PUSHBUF_DWORDS - 2 * (bufctx->relocs +
render->attr_count),
vert_avail = get_max_vertices(ctx, NULL, pushbuf_avail),
idx_avail = get_max_vertices(ctx, ib, pushbuf_avail);
int stride;
/* Try to keep client buffers smaller than the scratch BOs. */
if (render->mode == VBO &&
(stride = get_max_client_stride(ctx, arrays)))
vert_avail = MIN2(vert_avail,
NOUVEAU_SCRATCH_SIZE / stride);
if (max_index - min_index > vert_avail ||
(ib && ib->count > idx_avail)) {
struct split_limits limits = {
.max_verts = vert_avail,
.max_indices = idx_avail,
.max_vb_size = ~0,
};
_tnl_split_prims(ctx, arrays, prims, nr_prims, ib, min_index,
max_index, num_instances, base_instance,
TAG(vbo_render_prims), &limits);
return GL_TRUE;
}
return GL_FALSE;
}
/* VBO rendering path. */
static GLboolean
check_update_array(struct nouveau_array *a, unsigned offset,
struct nouveau_bo *bo, int *pdelta)
{
int delta = *pdelta;
GLboolean dirty;
if (a->bo == bo) {
if (delta < 0)
delta = ((int)offset - (int)a->offset) / a->stride;
dirty = (delta < 0 ||
offset != (a->offset + delta * a->stride));
} else {
dirty = GL_TRUE;
}
*pdelta = (dirty ? 0 : delta);
return dirty;
}
static void
vbo_bind_vertices(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
int base, unsigned min_index, unsigned max_index, int *pdelta)
{
struct nouveau_render_state *render = to_render_state(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_bo *bo[NUM_VERTEX_ATTRS];
unsigned offset[NUM_VERTEX_ATTRS];
GLboolean dirty = GL_FALSE;
int i, j, attr;
RENDER_LOCALS(ctx);
*pdelta = -1;
FOR_EACH_BOUND_ATTR(render, i, attr) {
const struct tnl_vertex_array *array = &arrays[attr];
const struct gl_vertex_buffer_binding *binding =
array->BufferBinding;
const struct gl_array_attributes *attrib = array->VertexAttrib;
const GLubyte *p = _mesa_vertex_attrib_address(attrib, binding);
struct gl_buffer_object *obj = binding->BufferObj;
struct nouveau_array *a = &render->attrs[attr];
unsigned delta = (base + min_index) * binding->Stride;
bo[i] = NULL;
if (nouveau_bufferobj_hw(obj)) {
/* Array in a buffer obj. */
nouveau_bo_ref(to_nouveau_bufferobj(obj)->bo, &bo[i]);
offset[i] = delta + (intptr_t)p;
} else {
int n = max_index - min_index + 1;
const char *sp;
if (obj) {
sp = (char *)ADD_POINTERS(
nouveau_bufferobj_sys(obj), p) + delta;
} else {
sp = (char *)(p + delta);
}
char *dp = nouveau_get_scratch(ctx, n * a->stride,
&bo[i], &offset[i]);
/* Array in client memory, move it to a
* scratch buffer obj. */
for (j = 0; j < n; j++)
memcpy(dp + j * a->stride,
sp + j * binding->Stride,
a->stride);
}
dirty |= check_update_array(a, offset[i], bo[i], pdelta);
}
*pdelta -= min_index;
if (dirty) {
/* Buffers changed, update the attribute binding. */
FOR_EACH_BOUND_ATTR(render, i, attr) {
struct nouveau_array *a = &render->attrs[attr];
nouveau_bo_ref(NULL, &a->bo);
a->offset = offset[i];
a->bo = bo[i];
}
TAG(render_release_vertices)(ctx);
TAG(render_bind_vertices)(ctx);
} else {
/* Just cleanup. */
FOR_EACH_BOUND_ATTR(render, i, attr)
nouveau_bo_ref(NULL, &bo[i]);
}
BATCH_VALIDATE();
}
static void
vbo_draw_vbo(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib, GLuint min_index,
GLuint max_index)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
dispatch_t dispatch = get_array_dispatch(&to_render_state(ctx)->ib);
int i, delta = 0, basevertex = 0;
RENDER_LOCALS(ctx);
TAG(render_set_format)(ctx);
for (i = 0; i < nr_prims; i++) {
unsigned start = prims[i].start,
count = prims[i].count;
if (i == 0 || basevertex != prims[i].basevertex) {
basevertex = prims[i].basevertex;
vbo_bind_vertices(ctx, arrays, basevertex, min_index,
max_index, &delta);
nouveau_pushbuf_bufctx(push, nctx->hw.bufctx);
if (nouveau_pushbuf_validate(push)) {
nouveau_pushbuf_bufctx(push, NULL);
return;
}
}
if (count > get_max_vertices(ctx, ib, PUSH_AVAIL(push)))
PUSH_SPACE(push, PUSHBUF_DWORDS);
BATCH_BEGIN(nvgl_primitive(prims[i].mode));
dispatch(ctx, start, delta, count);
BATCH_END();
}
nouveau_pushbuf_bufctx(push, NULL);
TAG(render_release_vertices)(ctx);
}
/* Immediate rendering path. */
static unsigned
extract_id(struct nouveau_array *a, int i, int j)
{
return j;
}
static void
vbo_draw_imm(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib, GLuint min_index,
GLuint max_index)
{
struct nouveau_render_state *render = to_render_state(ctx);
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
extract_u_t extract = ib ? render->ib.extract_u : extract_id;
int i, j, k, attr;
RENDER_LOCALS(ctx);
nouveau_pushbuf_bufctx(push, nctx->hw.bufctx);
if (nouveau_pushbuf_validate(push)) {
nouveau_pushbuf_bufctx(push, NULL);
return;
}
for (i = 0; i < nr_prims; i++) {
unsigned start = prims[i].start,
end = start + prims[i].count;
if (prims[i].count > get_max_vertices(ctx, ib,
PUSH_AVAIL(push)))
PUSH_SPACE(push, PUSHBUF_DWORDS);
BATCH_BEGIN(nvgl_primitive(prims[i].mode));
for (; start < end; start++) {
j = prims[i].basevertex +
extract(&render->ib, 0, start);
FOR_EACH_BOUND_ATTR(render, k, attr)
EMIT_IMM(ctx, &render->attrs[attr], j);
}
BATCH_END();
}
nouveau_pushbuf_bufctx(push, NULL);
}
/* draw_prims entry point when we're doing hw-tnl. */
static void
TAG(vbo_render_prims)(struct gl_context *ctx,
const struct tnl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
GLuint min_index, GLuint max_index,
GLuint num_instances, GLuint base_instance)
{
struct nouveau_render_state *render = to_render_state(ctx);
if (!index_bounds_valid)
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index,
nr_prims, 0, false);
vbo_choose_render_mode(ctx, arrays);
vbo_choose_attrs(ctx, arrays);
if (vbo_maybe_split(ctx, arrays, prims, nr_prims, ib, min_index,
max_index, num_instances, base_instance))
return;
vbo_init_arrays(ctx, ib, arrays);
if (render->mode == VBO)
vbo_draw_vbo(ctx, arrays, prims, nr_prims, ib, min_index,
max_index);
else
vbo_draw_imm(ctx, arrays, prims, nr_prims, ib, min_index,
max_index);
vbo_deinit_arrays(ctx, ib, arrays);
}
/* VBO rendering entry points. */
static void
TAG(vbo_check_render_prims)(struct gl_context *ctx,
const struct tnl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
GLuint min_index, GLuint max_index,
GLuint num_instances, GLuint base_instance)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
nouveau_validate_framebuffer(ctx);
if (nctx->fallback == HWTNL)
TAG(vbo_render_prims)(ctx, arrays, prims, nr_prims, ib,
index_bounds_valid, min_index, max_index,
num_instances, base_instance);
if (nctx->fallback == SWTNL)
_tnl_draw_prims(ctx, arrays, prims, nr_prims, ib,
index_bounds_valid, min_index, max_index,
num_instances, base_instance);
}
static void
TAG(vbo_draw)(struct gl_context *ctx,
const struct _mesa_prim *prims, unsigned nr_prims,
const struct _mesa_index_buffer *ib,
bool index_bounds_valid,
bool primitive_restart,
unsigned restart_index,
unsigned min_index, unsigned max_index,
unsigned num_instances, unsigned base_instance)
{
/* Borrow and update the inputs list from the tnl context */
const struct tnl_vertex_array* arrays = _tnl_bind_inputs(ctx);
TAG(vbo_check_render_prims)(ctx, arrays,
prims, nr_prims, ib,
index_bounds_valid, min_index, max_index,
num_instances, base_instance);
}
void
TAG(vbo_init)(struct gl_context *ctx)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i;
for (i = 0; i < VERT_ATTRIB_MAX; i++)
render->map[i] = -1;
/* Overwrite our draw function */
ctx->Driver.Draw = TAG(vbo_draw);
}
void
TAG(vbo_destroy)(struct gl_context *ctx)
{
}

File diff suppressed because it is too large Load Diff

View File

@ -1,738 +0,0 @@
#ifndef NV04_3D_XML
#define NV04_3D_XML
/* Autogenerated file, DO NOT EDIT manually!
This file was generated by the rules-ng-ng headergen tool in this git repository:
http://0x04.net/cgit/index.cgi/rules-ng-ng
git clone git://0x04.net/rules-ng-ng
The rules-ng-ng source files this header was generated from are:
- nv04_3d.xml ( 17839 bytes, from 2010-11-15 02:23:48)
- copyright.xml ( 6452 bytes, from 2010-11-15 15:10:58)
- nv_object.xml ( 11547 bytes, from 2010-11-13 23:32:57)
- nvchipsets.xml ( 3074 bytes, from 2010-11-13 23:32:57)
- nv_defs.xml ( 4437 bytes, from 2010-11-01 00:28:46)
- nv_3ddefs.xml ( 16394 bytes, from 2010-11-01 00:28:46)
Copyright (C) 2006-2010 by the following authors:
- Artur Huillet <arthur.huillet@free.fr> (ahuillet)
- Ben Skeggs (darktama, darktama_)
- B. R. <koala_br@users.sourceforge.net> (koala_br)
- Carlos Martin <carlosmn@users.sf.net> (carlosmn)
- Christoph Bumiller <e0425955@student.tuwien.ac.at> (calim, chrisbmr)
- Dawid Gajownik <gajownik@users.sf.net> (gajownik)
- Dmitry Baryshkov
- Dmitry Eremin-Solenikov <lumag@users.sf.net> (lumag)
- EdB <edb_@users.sf.net> (edb_)
- Erik Waling <erikwailing@users.sf.net> (erikwaling)
- Francisco Jerez <currojerez@riseup.net> (curro)
- imirkin <imirkin@users.sf.net> (imirkin)
- jb17bsome <jb17bsome@bellsouth.net> (jb17bsome)
- Jeremy Kolb <kjeremy@users.sf.net> (kjeremy)
- Laurent Carlier <lordheavym@gmail.com> (lordheavy)
- Luca Barbieri <luca@luca-barbieri.com> (lb, lb1)
- Maarten Maathuis <madman2003@gmail.com> (stillunknown)
- Marcin Kościelnicki <koriakin@0x04.net> (mwk, koriakin)
- Mark Carey <mark.carey@gmail.com> (careym)
- Matthieu Castet <matthieu.castet@parrot.com> (mat-c)
- nvidiaman <nvidiaman@users.sf.net> (nvidiaman)
- Patrice Mandin <patmandin@gmail.com> (pmandin, pmdata)
- Pekka Paalanen <pq@iki.fi> (pq, ppaalanen)
- Peter Popov <ironpeter@users.sf.net> (ironpeter)
- Richard Hughes <hughsient@users.sf.net> (hughsient)
- Rudi Cilibrasi <cilibrar@users.sf.net> (cilibrar)
- Serge Martin
- Simon Raffeiner
- Stephane Loeuillet <leroutier@users.sf.net> (leroutier)
- Stephane Marchesin <stephane.marchesin@gmail.com> (marcheu)
- sturmflut <sturmflut@users.sf.net> (sturmflut)
- Sylvain Munaut <tnt@246tNt.com>
- Victor Stinner <victor.stinner@haypocalc.com> (haypo)
- Wladmir van der Laan <laanwj@gmail.com> (miathan6)
- Younes Manton <younes.m@gmail.com> (ymanton)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define NV04_CONTEXT_SURFACES_3D_DMA_NOTIFY 0x00000180
#define NV04_CONTEXT_SURFACES_3D_DMA_COLOR 0x00000184
#define NV04_CONTEXT_SURFACES_3D_DMA_ZETA 0x00000188
#define NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL 0x000002f8
#define NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL_X__MASK 0x0000ffff
#define NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL_X__SHIFT 0
#define NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL_W__MASK 0xffff0000
#define NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL_W__SHIFT 16
#define NV04_CONTEXT_SURFACES_3D_CLIP_VERTICAL 0x000002fc
#define NV04_CONTEXT_SURFACES_3D_CLIP_VERTICAL_Y__MASK 0x0000ffff
#define NV04_CONTEXT_SURFACES_3D_CLIP_VERTICAL_Y__SHIFT 0
#define NV04_CONTEXT_SURFACES_3D_CLIP_VERTICAL_H__MASK 0xffff0000
#define NV04_CONTEXT_SURFACES_3D_CLIP_VERTICAL_H__SHIFT 16
#define NV04_CONTEXT_SURFACES_3D_FORMAT 0x00000300
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR__MASK 0x000000ff
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR__SHIFT 0
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_X1R5G5B5_Z1R5G5B5 0x00000001
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_X1R5G5B5_X1R5G5B5 0x00000002
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_R5G6B5 0x00000003
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_X8R8G8B8_Z8R8G8B8 0x00000004
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_X8R8G8B8_X8R8G8B8 0x00000005
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_X1A7R8G8B8_Z1A7R8G8B8 0x00000006
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_X1A7R8G8B8_X1A7R8G8B8 0x00000007
#define NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_A8R8G8B8 0x00000008
#define NV04_CONTEXT_SURFACES_3D_FORMAT_TYPE__MASK 0x0000ff00
#define NV04_CONTEXT_SURFACES_3D_FORMAT_TYPE__SHIFT 8
#define NV04_CONTEXT_SURFACES_3D_FORMAT_TYPE_PITCH 0x00000100
#define NV04_CONTEXT_SURFACES_3D_FORMAT_TYPE_SWIZZLE 0x00000200
#define NV04_CONTEXT_SURFACES_3D_FORMAT_BASE_SIZE_U__MASK 0x00ff0000
#define NV04_CONTEXT_SURFACES_3D_FORMAT_BASE_SIZE_U__SHIFT 16
#define NV04_CONTEXT_SURFACES_3D_FORMAT_BASE_SIZE_V__MASK 0xff000000
#define NV04_CONTEXT_SURFACES_3D_FORMAT_BASE_SIZE_V__SHIFT 24
#define NV04_CONTEXT_SURFACES_3D_CLIP_SIZE 0x00000304
#define NV04_CONTEXT_SURFACES_3D_CLIP_SIZE_W__MASK 0x0000ffff
#define NV04_CONTEXT_SURFACES_3D_CLIP_SIZE_W__SHIFT 0
#define NV04_CONTEXT_SURFACES_3D_CLIP_SIZE_H__MASK 0xffff0000
#define NV04_CONTEXT_SURFACES_3D_CLIP_SIZE_H__SHIFT 16
#define NV04_CONTEXT_SURFACES_3D_PITCH 0x00000308
#define NV04_CONTEXT_SURFACES_3D_PITCH_COLOR__MASK 0x0000ffff
#define NV04_CONTEXT_SURFACES_3D_PITCH_COLOR__SHIFT 0
#define NV04_CONTEXT_SURFACES_3D_PITCH_ZETA__MASK 0xffff0000
#define NV04_CONTEXT_SURFACES_3D_PITCH_ZETA__SHIFT 16
#define NV04_CONTEXT_SURFACES_3D_OFFSET_COLOR 0x0000030c
#define NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA 0x00000310
#define NV04_TEXTURED_TRIANGLE_DMA_NOTIFY 0x00000180
#define NV04_TEXTURED_TRIANGLE_DMA_A 0x00000184
#define NV04_TEXTURED_TRIANGLE_DMA_B 0x00000188
#define NV04_TEXTURED_TRIANGLE_SURFACES 0x0000018c
#define NV04_TEXTURED_TRIANGLE_COLORKEY 0x00000300
#define NV04_TEXTURED_TRIANGLE_OFFSET 0x00000304
#define NV04_TEXTURED_TRIANGLE_FORMAT 0x00000308
#define NV04_TEXTURED_TRIANGLE_FORMAT_DMA_A 0x00000001
#define NV04_TEXTURED_TRIANGLE_FORMAT_DMA_B 0x00000002
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_KEY_ENABLE 0x00000004
#define NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_ZOH__MASK 0x00000030
#define NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_ZOH__SHIFT 4
#define NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_ZOH_CENTER 0x00000010
#define NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_ZOH_CORNER 0x00000020
#define NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_FOH__MASK 0x000000c0
#define NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_FOH__SHIFT 6
#define NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_FOH_CENTER 0x00000040
#define NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_FOH_CORNER 0x00000080
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR__MASK 0x00000f00
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR__SHIFT 8
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_Y8 0x00000100
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_A1R5G5B5 0x00000200
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_X1R5G5B5 0x00000300
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_A4R4G4B4 0x00000400
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_R5G6B5 0x00000500
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_A8R8G8B8 0x00000600
#define NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_X8R8G8B8 0x00000700
#define NV04_TEXTURED_TRIANGLE_FORMAT_MIPMAP_LEVELS__MASK 0x0000f000
#define NV04_TEXTURED_TRIANGLE_FORMAT_MIPMAP_LEVELS__SHIFT 12
#define NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_U__MASK 0x000f0000
#define NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_U__SHIFT 16
#define NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_V__MASK 0x00f00000
#define NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_V__SHIFT 20
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU__MASK 0x07000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU__SHIFT 24
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_REPEAT 0x01000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_MIRRORED_REPEAT 0x02000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE 0x03000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_BORDER 0x04000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_WRAPU 0x08000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV__MASK 0x70000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV__SHIFT 28
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_REPEAT 0x10000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_MIRRORED_REPEAT 0x20000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_CLAMP_TO_EDGE 0x30000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_CLAMP_TO_BORDER 0x40000000
#define NV04_TEXTURED_TRIANGLE_FORMAT_WRAPV 0x80000000
#define NV04_TEXTURED_TRIANGLE_FILTER 0x0000030c
#define NV04_TEXTURED_TRIANGLE_FILTER_KERNEL_SIZE_X__MASK 0x000000ff
#define NV04_TEXTURED_TRIANGLE_FILTER_KERNEL_SIZE_X__SHIFT 0
#define NV04_TEXTURED_TRIANGLE_FILTER_KERNEL_SIZE_Y__MASK 0x00007f00
#define NV04_TEXTURED_TRIANGLE_FILTER_KERNEL_SIZE_Y__SHIFT 8
#define NV04_TEXTURED_TRIANGLE_FILTER_MIPMAP_DITHER_ENABLE 0x00008000
#define NV04_TEXTURED_TRIANGLE_FILTER_MIPMAP_LODBIAS__MASK 0x00ff0000
#define NV04_TEXTURED_TRIANGLE_FILTER_MIPMAP_LODBIAS__SHIFT 16
#define NV04_TEXTURED_TRIANGLE_FILTER_MINIFY__MASK 0x07000000
#define NV04_TEXTURED_TRIANGLE_FILTER_MINIFY__SHIFT 24
#define NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST 0x01000000
#define NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR 0x02000000
#define NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST 0x03000000
#define NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST 0x04000000
#define NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR 0x05000000
#define NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR 0x06000000
#define NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MINIFY_ENABLE 0x08000000
#define NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY__MASK 0x70000000
#define NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY__SHIFT 28
#define NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_NEAREST 0x10000000
#define NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_LINEAR 0x20000000
#define NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MAGNIFY_ENABLE 0x80000000
#define NV04_TEXTURED_TRIANGLE_BLEND 0x00000310
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP__MASK 0x0000000f
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP__SHIFT 0
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP_DECAL 0x00000001
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP_MODULATE 0x00000002
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP_DECALALPHA 0x00000003
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP_MODULATEALPHA 0x00000004
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP_DECALMASK 0x00000005
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP_MODULATEMASK 0x00000006
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP_COPY 0x00000007
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP_ADD 0x00000008
#define NV04_TEXTURED_TRIANGLE_BLEND_MASK_BIT__MASK 0x00000030
#define NV04_TEXTURED_TRIANGLE_BLEND_MASK_BIT__SHIFT 4
#define NV04_TEXTURED_TRIANGLE_BLEND_MASK_BIT_LSB 0x00000010
#define NV04_TEXTURED_TRIANGLE_BLEND_MASK_BIT_MSB 0x00000020
#define NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE__MASK 0x000000c0
#define NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE__SHIFT 6
#define NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_FLAT 0x00000040
#define NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_GOURAUD 0x00000080
#define NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_PHONG 0x000000c0
#define NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE 0x00000100
#define NV04_TEXTURED_TRIANGLE_BLEND_SPECULAR_ENABLE 0x00001000
#define NV04_TEXTURED_TRIANGLE_BLEND_FOG_ENABLE 0x00010000
#define NV04_TEXTURED_TRIANGLE_BLEND_BLEND_ENABLE 0x00100000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC__MASK 0x0f000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC__SHIFT 24
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_ZERO 0x01000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_ONE 0x02000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_SRC_COLOR 0x03000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_ONE_MINUS_SRC_COLOR 0x04000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_SRC_ALPHA 0x05000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_ONE_MINUS_SRC_ALPHA 0x06000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_DST_ALPHA 0x07000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_ONE_MINUS_DST_ALPHA 0x08000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_DST_COLOR 0x09000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_ONE_MINUS_DST_COLOR 0x0a000000
#define NV04_TEXTURED_TRIANGLE_BLEND_SRC_SRC_ALPHA_SATURATE 0x0b000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST__MASK 0xf0000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST__SHIFT 28
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_ZERO 0x10000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_ONE 0x20000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_SRC_COLOR 0x30000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_ONE_MINUS_SRC_COLOR 0x40000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_SRC_ALPHA 0x50000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_ONE_MINUS_SRC_ALPHA 0x60000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_DST_ALPHA 0x70000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_ONE_MINUS_DST_ALPHA 0x80000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_DST_COLOR 0x90000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_ONE_MINUS_DST_COLOR 0xa0000000
#define NV04_TEXTURED_TRIANGLE_BLEND_DST_SRC_ALPHA_SATURATE 0xb0000000
#define NV04_TEXTURED_TRIANGLE_CONTROL 0x00000314
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_REF__MASK 0x000000ff
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_REF__SHIFT 0
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC__MASK 0x00000f00
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC__SHIFT 8
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_NEVER 0x00000100
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_LESS 0x00000200
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_EQUAL 0x00000300
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_LEQUAL 0x00000400
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_GREATER 0x00000500
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_NOTEQUAL 0x00000600
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_GEQUAL 0x00000700
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_ALWAYS 0x00000800
#define NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_ENABLE 0x00001000
#define NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN__MASK 0x00002000
#define NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN__SHIFT 13
#define NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN_CENTER 0x00000000
#define NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN_CORNER 0x00002000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_ENABLE 0x00004000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC__MASK 0x000f0000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC__SHIFT 16
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_NEVER 0x00010000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_LESS 0x00020000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_EQUAL 0x00030000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_LEQUAL 0x00040000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_GREATER 0x00050000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_NOTEQUAL 0x00060000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_GEQUAL 0x00070000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_ALWAYS 0x00080000
#define NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE__MASK 0x00300000
#define NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE__SHIFT 20
#define NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_BOTH 0x00000000
#define NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_NONE 0x00100000
#define NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_CW 0x00200000
#define NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_CCW 0x00300000
#define NV04_TEXTURED_TRIANGLE_CONTROL_DITHER_ENABLE 0x00400000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_PERSPECTIVE_ENABLE 0x00800000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_WRITE 0x01000000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT__MASK 0xc0000000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT__SHIFT 30
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT_FIXED 0x40000000
#define NV04_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT_FLOAT 0x80000000
#define NV04_TEXTURED_TRIANGLE_FOGCOLOR 0x00000318
#define NV04_TEXTURED_TRIANGLE_FOGCOLOR_B__MASK 0x000000ff
#define NV04_TEXTURED_TRIANGLE_FOGCOLOR_B__SHIFT 0
#define NV04_TEXTURED_TRIANGLE_FOGCOLOR_G__MASK 0x0000ff00
#define NV04_TEXTURED_TRIANGLE_FOGCOLOR_G__SHIFT 8
#define NV04_TEXTURED_TRIANGLE_FOGCOLOR_R__MASK 0x00ff0000
#define NV04_TEXTURED_TRIANGLE_FOGCOLOR_R__SHIFT 16
#define NV04_TEXTURED_TRIANGLE_FOGCOLOR_A__MASK 0xff000000
#define NV04_TEXTURED_TRIANGLE_FOGCOLOR_A__SHIFT 24
#define NV04_TEXTURED_TRIANGLE_TLVERTEX(i0) (0x00000400 + 0x20*(i0))
#define NV04_TEXTURED_TRIANGLE_TLVERTEX__ESIZE 0x00000020
#define NV04_TEXTURED_TRIANGLE_TLVERTEX__LEN 0x00000010
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(i0) (0x00000400 + 0x20*(i0))
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SY(i0) (0x00000404 + 0x20*(i0))
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SZ(i0) (0x00000408 + 0x20*(i0))
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_RHW(i0) (0x0000040c + 0x20*(i0))
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_COLOR(i0) (0x00000410 + 0x20*(i0))
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_COLOR_B__MASK 0x000000ff
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_COLOR_B__SHIFT 0
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_COLOR_G__MASK 0x0000ff00
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_COLOR_G__SHIFT 8
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_COLOR_R__MASK 0x00ff0000
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_COLOR_R__SHIFT 16
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_COLOR_A__MASK 0xff000000
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_COLOR_A__SHIFT 24
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SPECULAR(i0) (0x00000414 + 0x20*(i0))
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SPECULAR_B__MASK 0x000000ff
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SPECULAR_B__SHIFT 0
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SPECULAR_G__MASK 0x0000ff00
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SPECULAR_G__SHIFT 8
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SPECULAR_R__MASK 0x00ff0000
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SPECULAR_R__SHIFT 16
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SPECULAR_FOG__MASK 0xff000000
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_SPECULAR_FOG__SHIFT 24
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_TU(i0) (0x00000418 + 0x20*(i0))
#define NV04_TEXTURED_TRIANGLE_TLVERTEX_TV(i0) (0x0000041c + 0x20*(i0))
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE(i0) (0x00000600 + 0x4*(i0))
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE__ESIZE 0x00000004
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE__LEN 0x00000040
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I0__MASK 0x0000000f
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I0__SHIFT 0
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I1__MASK 0x000000f0
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I1__SHIFT 4
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I2__MASK 0x00000f00
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I2__SHIFT 8
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I3__MASK 0x0000f000
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I3__SHIFT 12
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I4__MASK 0x000f0000
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I4__SHIFT 16
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I5__MASK 0x00f00000
#define NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE_I5__SHIFT 20
#define NV04_MULTITEX_TRIANGLE_DMA_NOTIFY 0x00000180
#define NV04_MULTITEX_TRIANGLE_DMA_A 0x00000184
#define NV04_MULTITEX_TRIANGLE_DMA_B 0x00000188
#define NV04_MULTITEX_TRIANGLE_SURFACES 0x0000018c
#define NV04_MULTITEX_TRIANGLE_OFFSET(i0) (0x00000308 + 0x4*(i0))
#define NV04_MULTITEX_TRIANGLE_OFFSET__ESIZE 0x00000004
#define NV04_MULTITEX_TRIANGLE_OFFSET__LEN 0x00000002
#define NV04_MULTITEX_TRIANGLE_FORMAT(i0) (0x00000310 + 0x4*(i0))
#define NV04_MULTITEX_TRIANGLE_FORMAT__ESIZE 0x00000004
#define NV04_MULTITEX_TRIANGLE_FORMAT__LEN 0x00000002
#define NV04_MULTITEX_TRIANGLE_FORMAT_DMA_A 0x00000001
#define NV04_MULTITEX_TRIANGLE_FORMAT_DMA_B 0x00000002
#define NV04_MULTITEX_TRIANGLE_FORMAT_ORIGIN_ZOH__MASK 0x00000030
#define NV04_MULTITEX_TRIANGLE_FORMAT_ORIGIN_ZOH__SHIFT 4
#define NV04_MULTITEX_TRIANGLE_FORMAT_ORIGIN_ZOH_CENTER 0x00000010
#define NV04_MULTITEX_TRIANGLE_FORMAT_ORIGIN_ZOH_CORNER 0x00000020
#define NV04_MULTITEX_TRIANGLE_FORMAT_ORIGIN_FOH__MASK 0x000000c0
#define NV04_MULTITEX_TRIANGLE_FORMAT_ORIGIN_FOH__SHIFT 6
#define NV04_MULTITEX_TRIANGLE_FORMAT_ORIGIN_FOH_CENTER 0x00000040
#define NV04_MULTITEX_TRIANGLE_FORMAT_ORIGIN_FOH_CORNER 0x00000080
#define NV04_MULTITEX_TRIANGLE_FORMAT_COLOR__MASK 0x00000f00
#define NV04_MULTITEX_TRIANGLE_FORMAT_COLOR__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_FORMAT_COLOR_Y8 0x00000100
#define NV04_MULTITEX_TRIANGLE_FORMAT_COLOR_A1R5G5B5 0x00000200
#define NV04_MULTITEX_TRIANGLE_FORMAT_COLOR_X1R5G5B5 0x00000300
#define NV04_MULTITEX_TRIANGLE_FORMAT_COLOR_A4R4G4B4 0x00000400
#define NV04_MULTITEX_TRIANGLE_FORMAT_COLOR_R5G6B5 0x00000500
#define NV04_MULTITEX_TRIANGLE_FORMAT_COLOR_A8R8G8B8 0x00000600
#define NV04_MULTITEX_TRIANGLE_FORMAT_COLOR_X8R8G8B8 0x00000700
#define NV04_MULTITEX_TRIANGLE_FORMAT_MIPMAP_LEVELS__MASK 0x0000f000
#define NV04_MULTITEX_TRIANGLE_FORMAT_MIPMAP_LEVELS__SHIFT 12
#define NV04_MULTITEX_TRIANGLE_FORMAT_BASE_SIZE_U__MASK 0x000f0000
#define NV04_MULTITEX_TRIANGLE_FORMAT_BASE_SIZE_U__SHIFT 16
#define NV04_MULTITEX_TRIANGLE_FORMAT_BASE_SIZE_V__MASK 0x00f00000
#define NV04_MULTITEX_TRIANGLE_FORMAT_BASE_SIZE_V__SHIFT 20
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSU__MASK 0x07000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSU__SHIFT 24
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSU_REPEAT 0x01000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSU_MIRRORED_REPEAT 0x02000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE 0x03000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_BORDER 0x04000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_WRAPU 0x08000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSV__MASK 0x70000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSV__SHIFT 28
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSV_REPEAT 0x10000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSV_MIRRORED_REPEAT 0x20000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSV_CLAMP_TO_EDGE 0x30000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSV_CLAMP_TO_BORDER 0x40000000
#define NV04_MULTITEX_TRIANGLE_FORMAT_WRAPV 0x80000000
#define NV04_MULTITEX_TRIANGLE_FILTER(i0) (0x00000318 + 0x4*(i0))
#define NV04_MULTITEX_TRIANGLE_FILTER__ESIZE 0x00000004
#define NV04_MULTITEX_TRIANGLE_FILTER__LEN 0x00000002
#define NV04_MULTITEX_TRIANGLE_FILTER_KERNEL_SIZE_X__MASK 0x000000ff
#define NV04_MULTITEX_TRIANGLE_FILTER_KERNEL_SIZE_X__SHIFT 0
#define NV04_MULTITEX_TRIANGLE_FILTER_KERNEL_SIZE_Y__MASK 0x00007f00
#define NV04_MULTITEX_TRIANGLE_FILTER_KERNEL_SIZE_Y__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_FILTER_MIPMAP_DITHER_ENABLE 0x00008000
#define NV04_MULTITEX_TRIANGLE_FILTER_MIPMAP_LODBIAS__MASK 0x00ff0000
#define NV04_MULTITEX_TRIANGLE_FILTER_MIPMAP_LODBIAS__SHIFT 16
#define NV04_MULTITEX_TRIANGLE_FILTER_MINIFY__MASK 0x07000000
#define NV04_MULTITEX_TRIANGLE_FILTER_MINIFY__SHIFT 24
#define NV04_MULTITEX_TRIANGLE_FILTER_MINIFY_NEAREST 0x01000000
#define NV04_MULTITEX_TRIANGLE_FILTER_MINIFY_LINEAR 0x02000000
#define NV04_MULTITEX_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST 0x03000000
#define NV04_MULTITEX_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST 0x04000000
#define NV04_MULTITEX_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR 0x05000000
#define NV04_MULTITEX_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR 0x06000000
#define NV04_MULTITEX_TRIANGLE_FILTER_ANISOTROPIC_MINIFY_ENABLE 0x08000000
#define NV04_MULTITEX_TRIANGLE_FILTER_MAGNIFY__MASK 0x70000000
#define NV04_MULTITEX_TRIANGLE_FILTER_MAGNIFY__SHIFT 28
#define NV04_MULTITEX_TRIANGLE_FILTER_MAGNIFY_NEAREST 0x10000000
#define NV04_MULTITEX_TRIANGLE_FILTER_MAGNIFY_LINEAR 0x20000000
#define NV04_MULTITEX_TRIANGLE_FILTER_ANISOTROPIC_MAGNIFY_ENABLE 0x80000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA(i0) (0x00000320 + 0xc*(i0))
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA__ESIZE 0x0000000c
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA__LEN 0x00000002
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_INVERSE0 0x00000001
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT0__MASK 0x000000fc
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT0__SHIFT 2
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT0_ZERO 0x00000004
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT0_CONSTANT 0x00000008
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT0_PRIMARY_COLOR 0x0000000c
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT0_PREVIOUS 0x00000010
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT0_TEXTURE0 0x00000014
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT0_TEXTURE1 0x00000018
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT0_TEXTURELOD 0x0000001c
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_INVERSE1 0x00000100
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT1__MASK 0x0000fc00
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT1__SHIFT 10
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT1_ZERO 0x00000400
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT1_CONSTANT 0x00000800
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT1_PRIMARY_COLOR 0x00000c00
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT1_PREVIOUS 0x00001000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT1_TEXTURE0 0x00001400
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT1_TEXTURE1 0x00001800
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT1_TEXTURELOD 0x00001c00
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_INVERSE2 0x00010000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT2__MASK 0x00fc0000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT2__SHIFT 18
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT2_ZERO 0x00040000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT2_CONSTANT 0x00080000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT2_PRIMARY_COLOR 0x000c0000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT2_PREVIOUS 0x00100000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT2_TEXTURE0 0x00140000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT2_TEXTURE1 0x00180000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT2_TEXTURELOD 0x001c0000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_INVERSE3 0x01000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT3__MASK 0x1c000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT3__SHIFT 26
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT3_ZERO 0x04000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT3_CONSTANT 0x08000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT3_PRIMARY_COLOR 0x0c000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT3_PREVIOUS 0x10000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT3_TEXTURE0 0x14000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT3_TEXTURE1 0x18000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_ARGUMENT3_TEXTURELOD 0x1c000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_MAP__MASK 0xe0000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_MAP__SHIFT 29
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_MAP_IDENTITY 0x20000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_MAP_SCALE2 0x40000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_MAP_SCALE4 0x60000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_MAP_BIAS 0x80000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA_MAP_BIAS_SCALE2 0xe0000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR(i0) (0x00000324 + 0xc*(i0))
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR__ESIZE 0x0000000c
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR__LEN 0x00000002
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_INVERSE0 0x00000001
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ALPHA0 0x00000002
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0__MASK 0x000000fc
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0__SHIFT 2
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0_ZERO 0x00000004
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0_CONSTANT 0x00000008
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0_PRIMARY_COLOR 0x0000000c
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0_PREVIOUS 0x00000010
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0_TEXTURE0 0x00000014
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0_TEXTURE1 0x00000018
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0_TEXTURELOD 0x0000001c
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_INVERSE1 0x00000100
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ALPHA1 0x00000200
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT1__MASK 0x0000fc00
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT1__SHIFT 10
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT1_ZERO 0x00000400
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT1_CONSTANT 0x00000800
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT1_PRIMARY_COLOR 0x00000c00
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT1_PREVIOUS 0x00001000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT1_TEXTURE0 0x00001400
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT1_TEXTURE1 0x00001800
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT1_TEXTURELOD 0x00001c00
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_INVERSE2 0x00010000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ALPHA2 0x00020000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT2__MASK 0x00fc0000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT2__SHIFT 18
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT2_ZERO 0x00040000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT2_CONSTANT 0x00080000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT2_PRIMARY_COLOR 0x000c0000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT2_PREVIOUS 0x00100000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT2_TEXTURE0 0x00140000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT2_TEXTURE1 0x00180000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT2_TEXTURELOD 0x001c0000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_INVERSE3 0x01000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ALPHA3 0x02000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT3__MASK 0x1c000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT3__SHIFT 26
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT3_ZERO 0x04000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT3_CONSTANT 0x08000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT3_PRIMARY_COLOR 0x0c000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT3_PREVIOUS 0x10000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT3_TEXTURE0 0x14000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT3_TEXTURE1 0x18000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT3_TEXTURELOD 0x1c000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP__MASK 0xe0000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP__SHIFT 29
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP_IDENTITY 0x20000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP_SCALE2 0x40000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP_SCALE4 0x60000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP_BIAS 0x80000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP_BIAS_SCALE2 0xe0000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR 0x00000334
#define NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR_B__MASK 0x000000ff
#define NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR_B__SHIFT 0
#define NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR_G__MASK 0x0000ff00
#define NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR_G__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR_R__MASK 0x00ff0000
#define NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR_R__SHIFT 16
#define NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR_A__MASK 0xff000000
#define NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR_A__SHIFT 24
#define NV04_MULTITEX_TRIANGLE_BLEND 0x00000338
#define NV04_MULTITEX_TRIANGLE_BLEND_MASK_BIT__MASK 0x00000030
#define NV04_MULTITEX_TRIANGLE_BLEND_MASK_BIT__SHIFT 4
#define NV04_MULTITEX_TRIANGLE_BLEND_MASK_BIT_LSB 0x00000010
#define NV04_MULTITEX_TRIANGLE_BLEND_MASK_BIT_MSB 0x00000020
#define NV04_MULTITEX_TRIANGLE_BLEND_SHADE_MODE__MASK 0x000000c0
#define NV04_MULTITEX_TRIANGLE_BLEND_SHADE_MODE__SHIFT 6
#define NV04_MULTITEX_TRIANGLE_BLEND_SHADE_MODE_FLAT 0x00000040
#define NV04_MULTITEX_TRIANGLE_BLEND_SHADE_MODE_GOURAUD 0x00000080
#define NV04_MULTITEX_TRIANGLE_BLEND_SHADE_MODE_PHONG 0x000000c0
#define NV04_MULTITEX_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE 0x00000100
#define NV04_MULTITEX_TRIANGLE_BLEND_SPECULAR_ENABLE 0x00001000
#define NV04_MULTITEX_TRIANGLE_BLEND_FOG_ENABLE 0x00010000
#define NV04_MULTITEX_TRIANGLE_BLEND_BLEND_ENABLE 0x00100000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC__MASK 0x0f000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC__SHIFT 24
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_ZERO 0x01000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_ONE 0x02000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_SRC_COLOR 0x03000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_ONE_MINUS_SRC_COLOR 0x04000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_SRC_ALPHA 0x05000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_ONE_MINUS_SRC_ALPHA 0x06000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_DST_ALPHA 0x07000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_ONE_MINUS_DST_ALPHA 0x08000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_DST_COLOR 0x09000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_ONE_MINUS_DST_COLOR 0x0a000000
#define NV04_MULTITEX_TRIANGLE_BLEND_SRC_SRC_ALPHA_SATURATE 0x0b000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST__MASK 0xf0000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST__SHIFT 28
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_ZERO 0x10000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_ONE 0x20000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_SRC_COLOR 0x30000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_ONE_MINUS_SRC_COLOR 0x40000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_SRC_ALPHA 0x50000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_ONE_MINUS_SRC_ALPHA 0x60000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_DST_ALPHA 0x70000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_ONE_MINUS_DST_ALPHA 0x80000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_DST_COLOR 0x90000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_ONE_MINUS_DST_COLOR 0xa0000000
#define NV04_MULTITEX_TRIANGLE_BLEND_DST_SRC_ALPHA_SATURATE 0xb0000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0 0x0000033c
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_REF__MASK 0x000000ff
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_REF__SHIFT 0
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC__MASK 0x00000f00
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC_NEVER 0x00000100
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC_LESS 0x00000200
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC_EQUAL 0x00000300
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC_LEQUAL 0x00000400
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC_GREATER 0x00000500
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC_NOTEQUAL 0x00000600
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC_GEQUAL 0x00000700
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC_ALWAYS 0x00000800
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_ENABLE 0x00001000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ORIGIN__MASK 0x00002000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ORIGIN__SHIFT 13
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ORIGIN_CENTER 0x00000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ORIGIN_CORNER 0x00002000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_ENABLE 0x00004000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC__MASK 0x000f0000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC__SHIFT 16
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC_NEVER 0x00010000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC_LESS 0x00020000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC_EQUAL 0x00030000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC_LEQUAL 0x00040000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC_GREATER 0x00050000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC_NOTEQUAL 0x00060000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC_GEQUAL 0x00070000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC_ALWAYS 0x00080000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_CULL_MODE__MASK 0x00300000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_CULL_MODE__SHIFT 20
#define NV04_MULTITEX_TRIANGLE_CONTROL0_CULL_MODE_BOTH 0x00000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_CULL_MODE_NONE 0x00100000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_CULL_MODE_CW 0x00200000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_CULL_MODE_CCW 0x00300000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_DITHER_ENABLE 0x00400000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_PERSPECTIVE_ENABLE 0x00800000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_WRITE 0x01000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_STENCIL_WRITE 0x02000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_WRITE 0x04000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_RED_WRITE 0x08000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_GREEN_WRITE 0x10000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_BLUE_WRITE 0x20000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FORMAT__MASK 0xc0000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FORMAT__SHIFT 30
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FORMAT_FIXED 0x40000000
#define NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FORMAT_FLOAT 0x80000000
#define NV04_MULTITEX_TRIANGLE_CONTROL1 0x00000340
#define NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_ENABLE 0x00000001
#define NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_FUNC__MASK 0x000000f0
#define NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_FUNC__SHIFT 4
#define NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_REF__MASK 0x0000ff00
#define NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_REF__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_MASK_READ__MASK 0x00ff0000
#define NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_MASK_READ__SHIFT 16
#define NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_MASK_WRITE__MASK 0xff000000
#define NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_MASK_WRITE__SHIFT 24
#define NV04_MULTITEX_TRIANGLE_CONTROL2 0x00000344
#define NV04_MULTITEX_TRIANGLE_CONTROL2_STENCIL_OP_FAIL__MASK 0x0000000f
#define NV04_MULTITEX_TRIANGLE_CONTROL2_STENCIL_OP_FAIL__SHIFT 0
#define NV04_MULTITEX_TRIANGLE_CONTROL2_STENCIL_OP_ZFAIL__MASK 0x000000f0
#define NV04_MULTITEX_TRIANGLE_CONTROL2_STENCIL_OP_ZFAIL__SHIFT 4
#define NV04_MULTITEX_TRIANGLE_CONTROL2_STENCIL_OP_ZPASS__MASK 0x00000f00
#define NV04_MULTITEX_TRIANGLE_CONTROL2_STENCIL_OP_ZPASS__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_FOGCOLOR 0x00000348
#define NV04_MULTITEX_TRIANGLE_FOGCOLOR_B__MASK 0x000000ff
#define NV04_MULTITEX_TRIANGLE_FOGCOLOR_B__SHIFT 0
#define NV04_MULTITEX_TRIANGLE_FOGCOLOR_G__MASK 0x0000ff00
#define NV04_MULTITEX_TRIANGLE_FOGCOLOR_G__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_FOGCOLOR_R__MASK 0x00ff0000
#define NV04_MULTITEX_TRIANGLE_FOGCOLOR_R__SHIFT 16
#define NV04_MULTITEX_TRIANGLE_FOGCOLOR_A__MASK 0xff000000
#define NV04_MULTITEX_TRIANGLE_FOGCOLOR_A__SHIFT 24
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX(i0) (0x00000400 + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX__ESIZE 0x00000028
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX__LEN 0x00000008
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SX(i0) (0x00000400 + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SY(i0) (0x00000404 + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SZ(i0) (0x00000408 + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_RHW(i0) (0x0000040c + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_COLOR(i0) (0x00000410 + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_COLOR_B__MASK 0x000000ff
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_COLOR_B__SHIFT 0
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_COLOR_G__MASK 0x0000ff00
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_COLOR_G__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_COLOR_R__MASK 0x00ff0000
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_COLOR_R__SHIFT 16
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_COLOR_A__MASK 0xff000000
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_COLOR_A__SHIFT 24
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SPECULAR(i0) (0x00000414 + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SPECULAR_B__MASK 0x000000ff
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SPECULAR_B__SHIFT 0
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SPECULAR_G__MASK 0x0000ff00
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SPECULAR_G__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SPECULAR_R__MASK 0x00ff0000
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SPECULAR_R__SHIFT 16
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SPECULAR_FOG__MASK 0xff000000
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SPECULAR_FOG__SHIFT 24
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_TU0(i0) (0x00000418 + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_TV0(i0) (0x0000041c + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_TU1(i0) (0x00000420 + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_TLMTVERTEX_TV1(i0) (0x00000424 + 0x28*(i0))
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE(i0) (0x00000540 + 0x4*(i0))
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE__ESIZE 0x00000004
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE__LEN 0x00000030
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I0__MASK 0x0000000f
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I0__SHIFT 0
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I1__MASK 0x000000f0
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I1__SHIFT 4
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I2__MASK 0x00000f00
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I2__SHIFT 8
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I3__MASK 0x0000f000
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I3__SHIFT 12
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I4__MASK 0x000f0000
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I4__SHIFT 16
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I5__MASK 0x00f00000
#define NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE_I5__SHIFT 20
#endif /* NV04_3D_XML */

View File

@ -1,283 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_fbo.h"
#include "nouveau_util.h"
#include "nv04_3d.xml.h"
#include "nv04_driver.h"
#include "util/u_memory.h"
static GLboolean
texunit_needs_combiners(struct gl_texture_unit *u,
struct gl_fixedfunc_texture_unit *f)
{
struct gl_texture_object *t = u->_Current;
struct gl_texture_image *ti = t->Image[0][t->Attrib.BaseLevel];
return ti->TexFormat == MESA_FORMAT_A_UNORM8 ||
ti->TexFormat == MESA_FORMAT_L_UNORM8 ||
f->EnvMode == GL_COMBINE ||
f->EnvMode == GL_COMBINE4_NV ||
f->EnvMode == GL_BLEND ||
f->EnvMode == GL_ADD;
}
struct nouveau_object *
nv04_context_engine(struct gl_context *ctx)
{
struct nv04_context *nctx = to_nv04_context(ctx);
struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_object *fahrenheit;
if ((ctx->Texture.Unit[0]._Current &&
texunit_needs_combiners(&ctx->Texture.Unit[0],
&ctx->Texture.FixedFuncUnit[0])) ||
ctx->Texture.Unit[1]._Current ||
ctx->Stencil.Enabled ||
GET_COLORMASK(ctx->Color.ColorMask, 0) != 0xf)
fahrenheit = hw->eng3dm;
else
fahrenheit = hw->eng3d;
if (fahrenheit != nctx->eng3d) {
BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1);
PUSH_DATA (push, fahrenheit->handle);
nctx->eng3d = fahrenheit;
}
return fahrenheit;
}
static void
nv04_hwctx_init(struct gl_context *ctx)
{
struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
struct nouveau_pushbuf *push = context_push(ctx);
struct nv04_fifo *fifo = hw->chan->data;
BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1);
PUSH_DATA (push, hw->surf3d->handle);
BEGIN_NV04(push, NV04_SF3D(DMA_NOTIFY), 3);
PUSH_DATA (push, hw->ntfy->handle);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->vram);
BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1);
PUSH_DATA (push, hw->eng3d->handle);
BEGIN_NV04(push, NV04_TTRI(DMA_NOTIFY), 4);
PUSH_DATA (push, hw->ntfy->handle);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->gart);
PUSH_DATA (push, hw->surf3d->handle);
BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1);
PUSH_DATA (push, hw->eng3dm->handle);
BEGIN_NV04(push, NV04_MTRI(DMA_NOTIFY), 4);
PUSH_DATA (push, hw->ntfy->handle);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->gart);
PUSH_DATA (push, hw->surf3d->handle);
PUSH_KICK (push);
}
static void
init_dummy_texture(struct gl_context *ctx)
{
struct nouveau_surface *s = &to_nv04_context(ctx)->dummy_texture;
nouveau_surface_alloc(ctx, s, SWIZZLED,
NOUVEAU_BO_MAP | NOUVEAU_BO_VRAM,
MESA_FORMAT_B8G8R8A8_UNORM, 1, 1);
nouveau_bo_map(s->bo, NOUVEAU_BO_WR, context_client(ctx));
*(uint32_t *)s->bo->map = 0xffffffff;
}
static void
nv04_context_destroy(struct gl_context *ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
nv04_surface_takedown(ctx);
nv04_render_destroy(ctx);
nouveau_surface_ref(NULL, &to_nv04_context(ctx)->dummy_texture);
nouveau_object_del(&nctx->hw.eng3d);
nouveau_object_del(&nctx->hw.eng3dm);
nouveau_object_del(&nctx->hw.surf3d);
nouveau_context_deinit(ctx);
align_free(ctx);
}
static struct gl_context *
nv04_context_create(struct nouveau_screen *screen, gl_api api,
const struct gl_config *visual,
struct gl_context *share_ctx)
{
struct nv04_context *nctx;
struct nouveau_hw_state *hw;
struct gl_context *ctx;
int ret;
nctx = align_calloc(sizeof(struct nv04_context), 16);
if (!nctx)
return NULL;
ctx = &nctx->base.base;
hw = &nctx->base.hw;
if (!nouveau_context_init(ctx, api, screen, visual, share_ctx))
goto fail;
/* GL constants. */
ctx->Const.MaxTextureSize = 1024;
ctx->Const.MaxTextureCoordUnits = NV04_TEXTURE_UNITS;
ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = NV04_TEXTURE_UNITS;
ctx->Const.MaxTextureUnits = NV04_TEXTURE_UNITS;
ctx->Const.MaxTextureMaxAnisotropy = 2;
ctx->Const.MaxTextureLodBias = 15;
/* 2D engine. */
ret = nv04_surface_init(ctx);
if (!ret)
goto fail;
/* 3D engine. */
ret = nouveau_object_new(context_chan(ctx), 0xbeef0001,
NV04_TEXTURED_TRIANGLE_CLASS, NULL, 0,
&hw->eng3d);
if (ret)
goto fail;
ret = nouveau_object_new(context_chan(ctx), 0xbeef0002,
NV04_MULTITEX_TRIANGLE_CLASS, NULL, 0,
&hw->eng3dm);
if (ret)
goto fail;
ret = nouveau_object_new(context_chan(ctx), 0xbeef0003,
NV04_SURFACE_3D_CLASS, NULL, 0,
&hw->surf3d);
if (ret)
goto fail;
init_dummy_texture(ctx);
nv04_hwctx_init(ctx);
nv04_render_init(ctx);
return ctx;
fail:
nv04_context_destroy(ctx);
return NULL;
}
const struct nouveau_driver nv04_driver = {
.context_create = nv04_context_create,
.context_destroy = nv04_context_destroy,
.surface_copy = nv04_surface_copy,
.surface_fill = nv04_surface_fill,
.emit = (nouveau_state_func[]) {
nv04_defer_control,
nouveau_emit_nothing,
nv04_defer_blend,
nv04_defer_blend,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nv04_defer_control,
nouveau_emit_nothing,
nv04_defer_control,
nouveau_emit_nothing,
nv04_defer_control,
nv04_defer_control,
nouveau_emit_nothing,
nv04_emit_framebuffer,
nv04_defer_blend,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nv04_emit_scissor,
nv04_defer_blend,
nv04_defer_control,
nv04_defer_control,
nv04_defer_control,
nv04_emit_tex_env,
nv04_emit_tex_env,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nv04_emit_tex_obj,
nv04_emit_tex_obj,
nouveau_emit_nothing,
nouveau_emit_nothing,
nouveau_emit_nothing,
nv04_emit_blend,
nv04_emit_control,
},
.num_emit = NUM_NV04_STATE,
};

View File

@ -1,59 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NV04_CONTEXT_H__
#define __NV04_CONTEXT_H__
#include "nouveau_context.h"
#include "nv_object.xml.h"
struct nv04_context {
struct nouveau_context base;
struct nouveau_object *eng3d;
struct nouveau_surface dummy_texture;
float viewport[16];
uint32_t colorkey;
struct nouveau_surface *texture[2];
uint32_t format[2];
uint32_t filter[2];
uint32_t alpha[2];
uint32_t color[2];
uint32_t factor;
uint32_t blend;
uint32_t ctrl[3];
uint32_t fog;
};
#define to_nv04_context(ctx) ((struct nv04_context *)(ctx))
#define nv04_mtex_engine(obj) ((obj)->oclass == NV04_MULTITEX_TRIANGLE_CLASS)
struct nouveau_object *
nv04_context_engine(struct gl_context *ctx);
extern const struct nouveau_driver nv04_driver;
#endif

View File

@ -1,93 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NV04_DRIVER_H__
#define __NV04_DRIVER_H__
#include "nv04_context.h"
enum {
NOUVEAU_STATE_BLEND = NUM_NOUVEAU_STATE,
NOUVEAU_STATE_CONTROL,
NUM_NV04_STATE
};
#define NV04_TEXTURE_UNITS 2
/* nv04_render.c */
void
nv04_render_init(struct gl_context *ctx);
void
nv04_render_destroy(struct gl_context *ctx);
/* nv04_surface.c */
GLboolean
nv04_surface_init(struct gl_context *ctx);
void
nv04_surface_takedown(struct gl_context *ctx);
void
nv04_surface_copy(struct gl_context *ctx,
struct nouveau_surface *dst, struct nouveau_surface *src,
int dx, int dy, int sx, int sy, int w, int h);
void
nv04_surface_fill(struct gl_context *ctx,
struct nouveau_surface *dst,
unsigned mask, unsigned value,
int dx, int dy, int w, int h);
/* nv04_state_fb.c */
void
nv04_emit_framebuffer(struct gl_context *ctx, int emit);
void
nv04_emit_scissor(struct gl_context *ctx, int emit);
/* nv04_state_raster.c */
void
nv04_defer_control(struct gl_context *ctx, int emit);
void
nv04_emit_control(struct gl_context *ctx, int emit);
void
nv04_defer_blend(struct gl_context *ctx, int emit);
void
nv04_emit_blend(struct gl_context *ctx, int emit);
/* nv04_state_frag.c */
void
nv04_emit_tex_env(struct gl_context *ctx, int emit);
/* nv04_state_tex.c */
void
nv04_emit_tex_obj(struct gl_context *ctx, int emit);
#endif

View File

@ -1,293 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_util.h"
#include "nv04_3d.xml.h"
#include "nv04_driver.h"
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
#include "tnl/t_vertex.h"
#define NUM_VERTEX_ATTRS 6
static void
swtnl_update_viewport(struct gl_context *ctx)
{
float *viewport = to_nv04_context(ctx)->viewport;
struct gl_framebuffer *fb = ctx->DrawBuffer;
get_viewport_scale(ctx, viewport);
get_viewport_translate(ctx, &viewport[MAT_TX]);
/* It wants normalized Z coordinates. */
viewport[MAT_SZ] /= fb->_DepthMaxF;
viewport[MAT_TZ] /= fb->_DepthMaxF;
}
static void
swtnl_emit_attr(struct gl_context *ctx, struct tnl_attr_map *m, int attr, int emit)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
if (tnl->render_inputs_bitset & BITFIELD64_BIT(attr))
*m = (struct tnl_attr_map) {
.attrib = attr,
.format = emit,
};
else
*m = (struct tnl_attr_map) {
.format = EMIT_PAD,
.offset = _tnl_format_info[emit].attrsize,
};
}
static void
swtnl_choose_attrs(struct gl_context *ctx)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct nouveau_object *fahrenheit = nv04_context_engine(ctx);
struct nv04_context *nctx = to_nv04_context(ctx);
static struct tnl_attr_map map[NUM_VERTEX_ATTRS];
int n = 0;
tnl->vb.AttribPtr[VERT_ATTRIB_POS] = tnl->vb.NdcPtr;
swtnl_emit_attr(ctx, &map[n++], _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT);
swtnl_emit_attr(ctx, &map[n++], _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA);
swtnl_emit_attr(ctx, &map[n++], _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR);
swtnl_emit_attr(ctx, &map[n++], _TNL_ATTRIB_FOG, EMIT_1UB_1F);
swtnl_emit_attr(ctx, &map[n++], _TNL_ATTRIB_TEX0, EMIT_2F);
if (nv04_mtex_engine(fahrenheit))
swtnl_emit_attr(ctx, &map[n++], _TNL_ATTRIB_TEX1, EMIT_2F);
swtnl_update_viewport(ctx);
_tnl_install_attrs(ctx, map, n, nctx->viewport, 0);
}
/* TnL renderer entry points */
static void
swtnl_restart_ttri(struct nv04_context *nv04, struct nouveau_pushbuf *push)
{
BEGIN_NV04(push, NV04_TTRI(COLORKEY), 7);
PUSH_DATA (push, nv04->colorkey);
PUSH_RELOC(push, nv04->texture[0]->bo, nv04->texture[0]->offset,
NOUVEAU_BO_LOW, 0, 0);
PUSH_RELOC(push, nv04->texture[0]->bo, nv04->format[0], NOUVEAU_BO_OR,
NV04_TEXTURED_TRIANGLE_FORMAT_DMA_A,
NV04_TEXTURED_TRIANGLE_FORMAT_DMA_B);
PUSH_DATA (push, nv04->filter[0]);
PUSH_DATA (push, nv04->blend);
PUSH_DATA (push, nv04->ctrl[0] & ~0x3e000000);
PUSH_DATA (push, nv04->fog);
}
static void
swtnl_restart_mtri(struct nv04_context *nv04, struct nouveau_pushbuf *push)
{
BEGIN_NV04(push, NV04_MTRI(OFFSET(0)), 8);
PUSH_RELOC(push, nv04->texture[0]->bo, nv04->texture[0]->offset,
NOUVEAU_BO_LOW, 0, 0);
PUSH_RELOC(push, nv04->texture[1]->bo, nv04->texture[1]->offset,
NOUVEAU_BO_LOW, 0, 0);
PUSH_RELOC(push, nv04->texture[0]->bo, nv04->format[0], NOUVEAU_BO_OR,
NV04_TEXTURED_TRIANGLE_FORMAT_DMA_A,
NV04_TEXTURED_TRIANGLE_FORMAT_DMA_B);
PUSH_RELOC(push, nv04->texture[1]->bo, nv04->format[1], NOUVEAU_BO_OR,
NV04_TEXTURED_TRIANGLE_FORMAT_DMA_A,
NV04_TEXTURED_TRIANGLE_FORMAT_DMA_B);
PUSH_DATA (push, nv04->filter[0]);
PUSH_DATA (push, nv04->filter[1]);
PUSH_DATA (push, nv04->alpha[0]);
PUSH_DATA (push, nv04->color[0]);
BEGIN_NV04(push, NV04_MTRI(COMBINE_ALPHA(1)), 8);
PUSH_DATA (push, nv04->alpha[1]);
PUSH_DATA (push, nv04->color[1]);
PUSH_DATA (push, nv04->factor);
PUSH_DATA (push, nv04->blend & ~0x0000000f);
PUSH_DATA (push, nv04->ctrl[0]);
PUSH_DATA (push, nv04->ctrl[1]);
PUSH_DATA (push, nv04->ctrl[2]);
PUSH_DATA (push, nv04->fog);
}
static inline bool
swtnl_restart(struct gl_context *ctx, int multi, unsigned vertex_size)
{
const int tex_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
struct nv04_context *nv04 = to_nv04_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_pushbuf_refn refs[] = {
{ nv04->texture[0]->bo, tex_flags },
{ nv04->texture[1]->bo, tex_flags },
};
/* wait for enough space for state, and at least one whole primitive */
if (nouveau_pushbuf_space(push, 32 + (4 * vertex_size), 4, 0) ||
nouveau_pushbuf_refn (push, refs, multi ? 2 : 1))
return false;
/* emit engine state */
if (multi)
swtnl_restart_mtri(nv04, push);
else
swtnl_restart_ttri(nv04, push);
return true;
}
static void
swtnl_start(struct gl_context *ctx)
{
struct nouveau_object *eng3d = nv04_context_engine(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
unsigned vertex_size;
nouveau_pushbuf_bufctx(push, push->user_priv);
nouveau_pushbuf_validate(push);
swtnl_choose_attrs(ctx);
vertex_size = TNL_CONTEXT(ctx)->clipspace.vertex_size / 4;
if (eng3d->oclass == NV04_MULTITEX_TRIANGLE_CLASS)
swtnl_restart(ctx, 1, vertex_size);
else
swtnl_restart(ctx, 0, vertex_size);
}
static void
swtnl_finish(struct gl_context *ctx)
{
struct nouveau_pushbuf *push = context_push(ctx);
nouveau_pushbuf_bufctx(push, NULL);
}
static void
swtnl_primitive(struct gl_context *ctx, GLenum mode)
{
}
static void
swtnl_reset_stipple(struct gl_context *ctx)
{
}
/* Primitive rendering */
#define BEGIN_PRIMITIVE(n) \
struct nouveau_object *eng3d = to_nv04_context(ctx)->eng3d; \
struct nouveau_pushbuf *push = context_push(ctx); \
int vertex_size = TNL_CONTEXT(ctx)->clipspace.vertex_size / 4; \
int multi = (eng3d->oclass == NV04_MULTITEX_TRIANGLE_CLASS); \
\
if (PUSH_AVAIL(push) < 32 + (n * vertex_size)) { \
if (!swtnl_restart(ctx, multi, vertex_size)) \
return; \
} \
\
BEGIN_NV04(push, NV04_TTRI(TLVERTEX_SX(0)), n * vertex_size);
#define OUT_VERTEX(i) \
PUSH_DATAp(push, _tnl_get_vertex(ctx, i), vertex_size);
#define END_PRIMITIVE(draw) \
if (multi) { \
BEGIN_NV04(push, NV04_MTRI(DRAWPRIMITIVE(0)), 1); \
PUSH_DATA (push, draw); \
} else { \
BEGIN_NV04(push, NV04_TTRI(DRAWPRIMITIVE(0)), 1); \
PUSH_DATA (push, draw); \
}
static void
swtnl_points(struct gl_context *ctx, GLuint first, GLuint last)
{
}
static void
swtnl_line(struct gl_context *ctx, GLuint v1, GLuint v2)
{
}
static void
swtnl_triangle(struct gl_context *ctx, GLuint v1, GLuint v2, GLuint v3)
{
BEGIN_PRIMITIVE(3);
OUT_VERTEX(v1);
OUT_VERTEX(v2);
OUT_VERTEX(v3);
END_PRIMITIVE(0x102);
}
static void
swtnl_quad(struct gl_context *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint v4)
{
BEGIN_PRIMITIVE(4);
OUT_VERTEX(v1);
OUT_VERTEX(v2);
OUT_VERTEX(v3);
OUT_VERTEX(v4);
END_PRIMITIVE(0x213103);
}
/* TnL initialization. */
void
nv04_render_init(struct gl_context *ctx)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
tnl->Driver.RunPipeline = _tnl_run_pipeline;
tnl->Driver.Render.Interp = _tnl_interp;
tnl->Driver.Render.CopyPV = _tnl_copy_pv;
tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine;
tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
tnl->Driver.Render.Start = swtnl_start;
tnl->Driver.Render.Finish = swtnl_finish;
tnl->Driver.Render.PrimitiveNotify = swtnl_primitive;
tnl->Driver.Render.ResetLineStipple = swtnl_reset_stipple;
tnl->Driver.Render.Points = swtnl_points;
tnl->Driver.Render.Line = swtnl_line;
tnl->Driver.Render.Triangle = swtnl_triangle;
tnl->Driver.Render.Quad = swtnl_quad;
_tnl_need_projected_coords(ctx, GL_TRUE);
_tnl_init_vertices(ctx, tnl->vb.Size,
NUM_VERTEX_ATTRS * 4 * sizeof(GLfloat));
_tnl_allow_pixel_fog(ctx, GL_FALSE);
}
void
nv04_render_destroy(struct gl_context *ctx)
{
}

View File

@ -1,110 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_fbo.h"
#include "nouveau_util.h"
#include "nv04_3d.xml.h"
#include "nv04_driver.h"
static inline unsigned
get_rt_format(mesa_format format)
{
switch (format) {
case MESA_FORMAT_B8G8R8X8_UNORM:
return NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_X8R8G8B8_X8R8G8B8;
case MESA_FORMAT_B8G8R8A8_UNORM:
return NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_A8R8G8B8;
case MESA_FORMAT_B5G6R5_UNORM:
return NV04_CONTEXT_SURFACES_3D_FORMAT_COLOR_R5G6B5;
default:
assert(0);
}
}
void
nv04_emit_framebuffer(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct nouveau_surface *s;
uint32_t rt_format = NV04_CONTEXT_SURFACES_3D_FORMAT_TYPE_PITCH;
uint32_t rt_pitch = 0, zeta_pitch = 0;
unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR;
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT)
return;
PUSH_RESET(push, BUFCTX_FB);
/* Render target */
if (fb->_ColorDrawBuffers[0]) {
s = &to_nouveau_renderbuffer(
fb->_ColorDrawBuffers[0])->surface;
rt_format |= get_rt_format(s->format);
zeta_pitch = rt_pitch = s->pitch;
BEGIN_NV04(push, NV04_SF3D(OFFSET_COLOR), 1);
PUSH_MTHDl(push, NV04_SF3D(OFFSET_COLOR), BUFCTX_FB,
s->bo, 0, bo_flags);
}
/* depth/stencil */
if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
s = &to_nouveau_renderbuffer(
fb->Attachment[BUFFER_DEPTH].Renderbuffer)->surface;
zeta_pitch = s->pitch;
BEGIN_NV04(push, NV04_SF3D(OFFSET_ZETA), 1);
PUSH_MTHDl(push, NV04_SF3D(OFFSET_ZETA), BUFCTX_FB,
s->bo, 0, bo_flags);
}
BEGIN_NV04(push, NV04_SF3D(FORMAT), 1);
PUSH_DATA (push, rt_format);
BEGIN_NV04(push, NV04_SF3D(PITCH), 1);
PUSH_DATA (push, zeta_pitch << 16 | rt_pitch);
/* Recompute the scissor state. */
context_dirty(ctx, SCISSOR);
context_dirty(ctx, CONTROL);
}
void
nv04_emit_scissor(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
int x, y, w, h;
get_scissors(ctx->DrawBuffer, &x, &y, &w, &h);
BEGIN_NV04(push, NV04_SF3D(CLIP_HORIZONTAL), 2);
PUSH_DATA (push, w << 16 | x);
PUSH_DATA (push, h << 16 | y);
}

View File

@ -1,299 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_util.h"
#include "nv_object.xml.h"
#include "nv04_3d.xml.h"
#include "nv04_driver.h"
#define COMBINER_SHIFT(in) \
(NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT##in##__SHIFT \
- NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0__SHIFT)
#define COMBINER_SOURCE(reg) \
NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ARGUMENT0_##reg
#define COMBINER_INVERT \
NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_INVERSE0
#define COMBINER_ALPHA \
NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ALPHA0
struct combiner_state {
struct gl_context *ctx;
int unit;
GLboolean alpha;
GLboolean premodulate;
/* GL state */
GLenum mode;
GLenum16 *source;
GLenum16 *operand;
GLuint logscale;
/* Derived HW state */
uint32_t hw;
};
#define __INIT_COMBINER_ALPHA_A GL_TRUE
#define __INIT_COMBINER_ALPHA_RGB GL_FALSE
/* Initialize a combiner_state struct from the texture unit
* context. */
#define INIT_COMBINER(chan, ctx, rc, i) do { \
struct gl_tex_env_combine_state *c = \
ctx->Texture.FixedFuncUnit[i]._CurrentCombine; \
(rc)->ctx = ctx; \
(rc)->unit = i; \
(rc)->alpha = __INIT_COMBINER_ALPHA_##chan; \
(rc)->premodulate = c->_NumArgs##chan == 4; \
(rc)->mode = c->Mode##chan; \
(rc)->source = c->Source##chan; \
(rc)->operand = c->Operand##chan; \
(rc)->logscale = c->ScaleShift##chan; \
(rc)->hw = 0; \
} while (0)
/* Get the combiner source for the specified EXT_texture_env_combine
* source. */
static uint32_t
get_input_source(struct combiner_state *rc, int source)
{
switch (source) {
case GL_ZERO:
return COMBINER_SOURCE(ZERO);
case GL_TEXTURE:
return rc->unit ? COMBINER_SOURCE(TEXTURE1) :
COMBINER_SOURCE(TEXTURE0);
case GL_TEXTURE0:
return COMBINER_SOURCE(TEXTURE0);
case GL_TEXTURE1:
return COMBINER_SOURCE(TEXTURE1);
case GL_CONSTANT:
return COMBINER_SOURCE(CONSTANT);
case GL_PRIMARY_COLOR:
return COMBINER_SOURCE(PRIMARY_COLOR);
case GL_PREVIOUS:
return rc->unit ? COMBINER_SOURCE(PREVIOUS) :
COMBINER_SOURCE(PRIMARY_COLOR);
default:
assert(0);
}
}
/* Get the (possibly inverted) combiner input mapping for the
* specified EXT_texture_env_combine operand. */
#define INVERT 0x1
static uint32_t
get_input_mapping(struct combiner_state *rc, int operand, int flags)
{
int map = 0;
if (!is_color_operand(operand) && !rc->alpha)
map |= COMBINER_ALPHA;
if (is_negative_operand(operand) == !(flags & INVERT))
map |= COMBINER_INVERT;
return map;
}
static uint32_t
get_input_arg(struct combiner_state *rc, int arg, int flags)
{
int source = rc->source[arg];
int operand = rc->operand[arg];
/* Fake several unsupported texture formats. */
if (is_texture_source(source)) {
int i = (source == GL_TEXTURE ?
rc->unit : source - GL_TEXTURE0);
struct gl_texture_object *t = rc->ctx->Texture.Unit[i]._Current;
mesa_format format = t->Image[0][t->Attrib.BaseLevel]->TexFormat;
if (format == MESA_FORMAT_A_UNORM8) {
/* Emulated using I8. */
if (is_color_operand(operand))
return COMBINER_SOURCE(ZERO) |
get_input_mapping(rc, operand, flags);
} else if (format == MESA_FORMAT_L_UNORM8) {
/* Emulated using I8. */
if (!is_color_operand(operand))
return COMBINER_SOURCE(ZERO) |
get_input_mapping(rc, operand,
flags ^ INVERT);
}
}
return get_input_source(rc, source) |
get_input_mapping(rc, operand, flags);
}
/* Bind the combiner input <in> to the combiner source <src>,
* possibly inverted. */
#define INPUT_SRC(rc, in, src, flags) \
(rc)->hw |= ((flags & INVERT ? COMBINER_INVERT : 0) | \
COMBINER_SOURCE(src)) << COMBINER_SHIFT(in)
/* Bind the combiner input <in> to the EXT_texture_env_combine
* argument <arg>, possibly inverted. */
#define INPUT_ARG(rc, in, arg, flags) \
(rc)->hw |= get_input_arg(rc, arg, flags) << COMBINER_SHIFT(in)
#define UNSIGNED_OP(rc) \
(rc)->hw |= ((rc)->logscale ? \
NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP_SCALE2 : \
NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP_IDENTITY)
#define SIGNED_OP(rc) \
(rc)->hw |= ((rc)->logscale ? \
NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP_BIAS_SCALE2 : \
NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_MAP_BIAS)
static void
setup_combiner(struct combiner_state *rc)
{
switch (rc->mode) {
case GL_REPLACE:
INPUT_ARG(rc, 0, 0, 0);
INPUT_SRC(rc, 1, ZERO, INVERT);
INPUT_SRC(rc, 2, ZERO, 0);
INPUT_SRC(rc, 3, ZERO, 0);
UNSIGNED_OP(rc);
break;
case GL_MODULATE:
INPUT_ARG(rc, 0, 0, 0);
INPUT_ARG(rc, 1, 1, 0);
INPUT_SRC(rc, 2, ZERO, 0);
INPUT_SRC(rc, 3, ZERO, 0);
UNSIGNED_OP(rc);
break;
case GL_ADD:
case GL_ADD_SIGNED:
if (rc->premodulate) {
INPUT_ARG(rc, 0, 0, 0);
INPUT_ARG(rc, 1, 1, 0);
INPUT_ARG(rc, 2, 2, 0);
INPUT_ARG(rc, 3, 3, 0);
} else {
INPUT_ARG(rc, 0, 0, 0);
INPUT_SRC(rc, 1, ZERO, INVERT);
INPUT_ARG(rc, 2, 1, 0);
INPUT_SRC(rc, 3, ZERO, INVERT);
}
if (rc->mode == GL_ADD_SIGNED)
SIGNED_OP(rc);
else
UNSIGNED_OP(rc);
break;
case GL_INTERPOLATE:
INPUT_ARG(rc, 0, 0, 0);
INPUT_ARG(rc, 1, 2, 0);
INPUT_ARG(rc, 2, 1, 0);
INPUT_ARG(rc, 3, 2, INVERT);
UNSIGNED_OP(rc);
break;
default:
assert(0);
}
}
static unsigned
get_texenv_mode(unsigned mode)
{
switch (mode) {
case GL_REPLACE:
return 0x1;
case GL_DECAL:
return 0x3;
case GL_MODULATE:
return 0x4;
default:
assert(0);
}
}
void
nv04_emit_tex_env(struct gl_context *ctx, int emit)
{
struct nv04_context *nv04 = to_nv04_context(ctx);
const int i = emit - NOUVEAU_STATE_TEX_ENV0;
struct combiner_state rc_a = {}, rc_c = {};
/* Compute the new combiner state. */
if (ctx->Texture.Unit[i]._Current) {
INIT_COMBINER(A, ctx, &rc_a, i);
setup_combiner(&rc_a);
INIT_COMBINER(RGB, ctx, &rc_c, i);
setup_combiner(&rc_c);
} else {
if (i == 0) {
INPUT_SRC(&rc_a, 0, PRIMARY_COLOR, 0);
INPUT_SRC(&rc_c, 0, PRIMARY_COLOR, 0);
} else {
INPUT_SRC(&rc_a, 0, PREVIOUS, 0);
INPUT_SRC(&rc_c, 0, PREVIOUS, 0);
}
INPUT_SRC(&rc_a, 1, ZERO, INVERT);
INPUT_SRC(&rc_c, 1, ZERO, INVERT);
INPUT_SRC(&rc_a, 2, ZERO, 0);
INPUT_SRC(&rc_c, 2, ZERO, 0);
INPUT_SRC(&rc_a, 3, ZERO, 0);
INPUT_SRC(&rc_c, 3, ZERO, 0);
UNSIGNED_OP(&rc_a);
UNSIGNED_OP(&rc_c);
}
/* calculate non-multitex state */
nv04->blend &= ~NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP__MASK;
if (ctx->Texture._MaxEnabledTexImageUnit != -1)
nv04->blend |= get_texenv_mode(ctx->Texture.FixedFuncUnit[0].EnvMode);
else
nv04->blend |= get_texenv_mode(GL_MODULATE);
/* update calculated multitex state */
nv04->alpha[i] = rc_a.hw;
nv04->color[i] = rc_c.hw;
nv04->factor = pack_rgba_f(MESA_FORMAT_B8G8R8A8_UNORM,
ctx->Texture.FixedFuncUnit[0].EnvColor);
}

View File

@ -1,228 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_util.h"
#include "nv_object.xml.h"
#include "nv04_3d.xml.h"
#include "nv04_driver.h"
#include "main/stencil.h"
static unsigned
get_comparison_op(unsigned op)
{
switch (op) {
case GL_NEVER:
return 0x1;
case GL_LESS:
return 0x2;
case GL_EQUAL:
return 0x3;
case GL_LEQUAL:
return 0x4;
case GL_GREATER:
return 0x5;
case GL_NOTEQUAL:
return 0x6;
case GL_GEQUAL:
return 0x7;
case GL_ALWAYS:
return 0x8;
default:
assert(0);
}
}
static unsigned
get_stencil_op(unsigned op)
{
switch (op) {
case GL_KEEP:
return 0x1;
case GL_ZERO:
return 0x2;
case GL_REPLACE:
return 0x3;
case GL_INCR:
return 0x4;
case GL_DECR:
return 0x5;
case GL_INVERT:
return 0x6;
case GL_INCR_WRAP:
return 0x7;
case GL_DECR_WRAP:
return 0x8;
default:
assert(0);
}
}
static unsigned
get_blend_func(unsigned func)
{
switch (func) {
case GL_ZERO:
return 0x1;
case GL_ONE:
return 0x2;
case GL_SRC_COLOR:
return 0x3;
case GL_ONE_MINUS_SRC_COLOR:
return 0x4;
case GL_SRC_ALPHA:
return 0x5;
case GL_ONE_MINUS_SRC_ALPHA:
return 0x6;
case GL_DST_ALPHA:
return 0x7;
case GL_ONE_MINUS_DST_ALPHA:
return 0x8;
case GL_DST_COLOR:
return 0x9;
case GL_ONE_MINUS_DST_COLOR:
return 0xa;
case GL_SRC_ALPHA_SATURATE:
return 0xb;
default:
assert(0);
}
}
void
nv04_defer_control(struct gl_context *ctx, int emit)
{
context_dirty(ctx, CONTROL);
}
void
nv04_emit_control(struct gl_context *ctx, int emit)
{
struct nv04_context *nv04 = to_nv04_context(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
int cull = ctx->Polygon.CullFaceMode;
int front = ctx->Polygon.FrontFace;
nv04->ctrl[0] = NV04_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT_FIXED |
NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN_CORNER;
nv04->ctrl[1] = 0;
nv04->ctrl[2] = 0;
/* Dithering. */
if (ctx->Color.DitherFlag)
nv04->ctrl[0] |= NV04_TEXTURED_TRIANGLE_CONTROL_DITHER_ENABLE;
/* Cull mode. */
if (!ctx->Polygon.CullFlag)
nv04->ctrl[0] |= NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_NONE;
else if (cull == GL_FRONT_AND_BACK)
nv04->ctrl[0] |= NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_BOTH;
else
nv04->ctrl[0] |= (cull == GL_FRONT) ^ (front == GL_CCW) ?
NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_CW :
NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_CCW;
/* Depth test. */
if (ctx->Depth.Test && fb->Visual.depthBits > 0)
nv04->ctrl[0] |= NV04_TEXTURED_TRIANGLE_CONTROL_Z_ENABLE;
if (ctx->Depth.Mask && fb->Visual.depthBits > 0)
nv04->ctrl[0] |= NV04_TEXTURED_TRIANGLE_CONTROL_Z_WRITE;
nv04->ctrl[0] |= get_comparison_op(ctx->Depth.Func) << 16;
/* Alpha test. */
if (ctx->Color.AlphaEnabled)
nv04->ctrl[0] |= NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_ENABLE;
nv04->ctrl[0] |= get_comparison_op(ctx->Color.AlphaFunc) << 8 |
FLOAT_TO_UBYTE(ctx->Color.AlphaRef);
/* Color mask. */
if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0))
nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_RED_WRITE;
if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1))
nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_GREEN_WRITE;
if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2))
nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_BLUE_WRITE;
if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3))
nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_WRITE;
/* Stencil test. */
if (ctx->Stencil.WriteMask[0])
nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_STENCIL_WRITE;
if (_mesa_stencil_is_enabled(ctx))
nv04->ctrl[1] |= NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_ENABLE;
nv04->ctrl[1] |= get_comparison_op(ctx->Stencil.Function[0]) << 4 |
_mesa_get_stencil_ref(ctx, 0) << 8 |
ctx->Stencil.ValueMask[0] << 16 |
ctx->Stencil.WriteMask[0] << 24;
nv04->ctrl[2] |= get_stencil_op(ctx->Stencil.ZPassFunc[0]) << 8 |
get_stencil_op(ctx->Stencil.ZFailFunc[0]) << 4 |
get_stencil_op(ctx->Stencil.FailFunc[0]);
}
void
nv04_defer_blend(struct gl_context *ctx, int emit)
{
context_dirty(ctx, BLEND);
}
void
nv04_emit_blend(struct gl_context *ctx, int emit)
{
struct nv04_context *nv04 = to_nv04_context(ctx);
nv04->blend &= NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP__MASK;
nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_MASK_BIT_MSB |
NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE;
/* Alpha blending. */
nv04->blend |= get_blend_func(ctx->Color.Blend[0].DstRGB) << 28 |
get_blend_func(ctx->Color.Blend[0].SrcRGB) << 24;
if (ctx->Color.BlendEnabled)
nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_BLEND_ENABLE;
/* Shade model. */
if (ctx->Light.ShadeModel == GL_SMOOTH)
nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_GOURAUD;
else
nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_FLAT;
/* Secondary color */
if (_mesa_need_secondary_color(ctx))
nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_SPECULAR_ENABLE;
/* Fog. */
if (ctx->Fog.Enabled) {
nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_FOG_ENABLE;
nv04->fog = pack_rgba_f(MESA_FORMAT_B8G8R8A8_UNORM, ctx->Fog.Color);
}
}

View File

@ -1,116 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_texture.h"
#include "nouveau_util.h"
#include "nouveau_gldefs.h"
#include "nv_object.xml.h"
#include "nv04_3d.xml.h"
#include "nv04_driver.h"
#include "main/samplerobj.h"
static uint32_t
get_tex_format(struct gl_texture_image *ti)
{
switch (ti->TexFormat) {
case MESA_FORMAT_A_UNORM8:
case MESA_FORMAT_L_UNORM8:
case MESA_FORMAT_I_UNORM8:
return NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_Y8;
case MESA_FORMAT_B5G5R5A1_UNORM:
return NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_A1R5G5B5;
case MESA_FORMAT_B4G4R4A4_UNORM:
return NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_A4R4G4B4;
case MESA_FORMAT_B5G6R5_UNORM:
return NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_R5G6B5;
case MESA_FORMAT_B8G8R8A8_UNORM:
return NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_A8R8G8B8;
case MESA_FORMAT_B8G8R8X8_UNORM:
return NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_X8R8G8B8;
default:
assert(0);
}
}
void
nv04_emit_tex_obj(struct gl_context *ctx, int emit)
{
struct nv04_context *nv04 = to_nv04_context(ctx);
const int i = emit - NOUVEAU_STATE_TEX_OBJ0;
struct nouveau_surface *s;
uint32_t format = 0xa0, filter = 0x1010;
if (ctx->Texture.Unit[i]._Current) {
struct gl_texture_object *t = ctx->Texture.Unit[i]._Current;
struct gl_texture_image *ti = t->Image[0][t->Attrib.BaseLevel];
const struct gl_sampler_object *sa = _mesa_get_samplerobj(ctx, i);
int lod_max = 1, lod_bias = 0;
if (!nouveau_texture_validate(ctx, t))
return;
s = &to_nouveau_texture(t)->surfaces[t->Attrib.BaseLevel];
if (sa->Attrib.MinFilter != GL_NEAREST &&
sa->Attrib.MinFilter != GL_LINEAR) {
lod_max = CLAMP(MIN2(sa->Attrib.MaxLod, t->_MaxLambda),
0, 15) + 1;
lod_bias = CLAMP(ctx->Texture.Unit[i].LodBias +
sa->Attrib.LodBias, -16, 15) * 8;
}
format |= nvgl_wrap_mode(sa->Attrib.WrapT) << 28 |
nvgl_wrap_mode(sa->Attrib.WrapS) << 24 |
ti->HeightLog2 << 20 |
ti->WidthLog2 << 16 |
lod_max << 12 |
get_tex_format(ti);
filter |= log2i(sa->Attrib.MaxAnisotropy) << 31 |
nvgl_filter_mode(sa->Attrib.MagFilter) << 28 |
log2i(sa->Attrib.MaxAnisotropy) << 27 |
nvgl_filter_mode(sa->Attrib.MinFilter) << 24 |
(lod_bias & 0xff) << 16;
} else {
s = &to_nv04_context(ctx)->dummy_texture;
format |= NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_REPEAT |
NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_REPEAT |
1 << 12 |
NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_A8R8G8B8;
filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST |
NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_NEAREST;
}
nv04->texture[i] = s;
nv04->format[i] = format;
nv04->filter[i] = filter;
}

View File

@ -1,611 +0,0 @@
/*
* Copyright (C) 2007-2010 The Nouveau Project.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nv_object.xml.h"
#include "nv_m2mf.xml.h"
#include "nv01_2d.xml.h"
#include "nv04_3d.xml.h"
#include "nouveau_context.h"
#include "nouveau_util.h"
#include "nv04_driver.h"
static inline int
swzsurf_format(mesa_format format)
{
switch (format) {
case MESA_FORMAT_A_UNORM8:
case MESA_FORMAT_L_UNORM8:
case MESA_FORMAT_I_UNORM8:
case MESA_FORMAT_B2G3R3_UNORM:
return NV04_SWIZZLED_SURFACE_FORMAT_COLOR_Y8;
case MESA_FORMAT_B5G6R5_UNORM:
case MESA_FORMAT_R5G6B5_UNORM:
case MESA_FORMAT_B4G4R4A4_UNORM:
case MESA_FORMAT_A4R4G4B4_UNORM:
case MESA_FORMAT_B5G5R5A1_UNORM:
case MESA_FORMAT_A1B5G5R5_UNORM:
case MESA_FORMAT_A1R5G5B5_UNORM:
case MESA_FORMAT_LA_UNORM8:
case MESA_FORMAT_YCBCR:
case MESA_FORMAT_YCBCR_REV:
case MESA_FORMAT_Z_UNORM16:
return NV04_SWIZZLED_SURFACE_FORMAT_COLOR_R5G6B5;
case MESA_FORMAT_A8B8G8R8_UNORM:
case MESA_FORMAT_R8G8B8A8_UNORM:
case MESA_FORMAT_B8G8R8X8_UNORM:
case MESA_FORMAT_B8G8R8A8_UNORM:
case MESA_FORMAT_A8R8G8B8_UNORM:
case MESA_FORMAT_Z24_UNORM_S8_UINT:
case MESA_FORMAT_S8_UINT_Z24_UNORM:
case MESA_FORMAT_Z_UNORM32:
return NV04_SWIZZLED_SURFACE_FORMAT_COLOR_A8R8G8B8;
default:
assert(0);
}
}
static inline int
surf2d_format(mesa_format format)
{
switch (format) {
case MESA_FORMAT_A_UNORM8:
case MESA_FORMAT_L_UNORM8:
case MESA_FORMAT_I_UNORM8:
case MESA_FORMAT_B2G3R3_UNORM:
return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
case MESA_FORMAT_B5G6R5_UNORM:
case MESA_FORMAT_R5G6B5_UNORM:
case MESA_FORMAT_B4G4R4A4_UNORM:
case MESA_FORMAT_A4R4G4B4_UNORM:
case MESA_FORMAT_B5G5R5A1_UNORM:
case MESA_FORMAT_A1B5G5R5_UNORM:
case MESA_FORMAT_A1R5G5B5_UNORM:
case MESA_FORMAT_LA_UNORM8:
case MESA_FORMAT_YCBCR:
case MESA_FORMAT_YCBCR_REV:
case MESA_FORMAT_Z_UNORM16:
return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
case MESA_FORMAT_A8B8G8R8_UNORM:
case MESA_FORMAT_R8G8B8A8_UNORM:
case MESA_FORMAT_B8G8R8X8_UNORM:
case MESA_FORMAT_B8G8R8A8_UNORM:
case MESA_FORMAT_A8R8G8B8_UNORM:
case MESA_FORMAT_Z24_UNORM_S8_UINT:
case MESA_FORMAT_S8_UINT_Z24_UNORM:
case MESA_FORMAT_Z_UNORM32:
return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
default:
assert(0);
}
}
static inline int
rect_format(mesa_format format)
{
switch (format) {
case MESA_FORMAT_A_UNORM8:
case MESA_FORMAT_L_UNORM8:
case MESA_FORMAT_I_UNORM8:
case MESA_FORMAT_B2G3R3_UNORM:
return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
case MESA_FORMAT_B5G6R5_UNORM:
case MESA_FORMAT_R5G6B5_UNORM:
case MESA_FORMAT_B4G4R4A4_UNORM:
case MESA_FORMAT_A4R4G4B4_UNORM:
case MESA_FORMAT_B5G5R5A1_UNORM:
case MESA_FORMAT_A1B5G5R5_UNORM:
case MESA_FORMAT_A1R5G5B5_UNORM:
case MESA_FORMAT_LA_UNORM8:
case MESA_FORMAT_YCBCR:
case MESA_FORMAT_YCBCR_REV:
case MESA_FORMAT_Z_UNORM16:
return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
case MESA_FORMAT_A8B8G8R8_UNORM:
case MESA_FORMAT_R8G8B8A8_UNORM:
case MESA_FORMAT_B8G8R8X8_UNORM:
case MESA_FORMAT_B8G8R8A8_UNORM:
case MESA_FORMAT_A8R8G8B8_UNORM:
case MESA_FORMAT_Z24_UNORM_S8_UINT:
case MESA_FORMAT_S8_UINT_Z24_UNORM:
case MESA_FORMAT_Z_UNORM32:
return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
default:
assert(0);
}
}
static inline int
sifm_format(mesa_format format)
{
switch (format) {
case MESA_FORMAT_A_UNORM8:
case MESA_FORMAT_L_UNORM8:
case MESA_FORMAT_I_UNORM8:
case MESA_FORMAT_B2G3R3_UNORM:
return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_AY8;
case MESA_FORMAT_B5G6R5_UNORM:
case MESA_FORMAT_R5G6B5_UNORM:
case MESA_FORMAT_B4G4R4A4_UNORM:
case MESA_FORMAT_A4R4G4B4_UNORM:
case MESA_FORMAT_B5G5R5A1_UNORM:
case MESA_FORMAT_A1B5G5R5_UNORM:
case MESA_FORMAT_A1R5G5B5_UNORM:
case MESA_FORMAT_LA_UNORM8:
case MESA_FORMAT_YCBCR:
case MESA_FORMAT_YCBCR_REV:
case MESA_FORMAT_Z_UNORM16:
return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5;
case MESA_FORMAT_A8B8G8R8_UNORM:
case MESA_FORMAT_R8G8B8A8_UNORM:
case MESA_FORMAT_B8G8R8X8_UNORM:
case MESA_FORMAT_B8G8R8A8_UNORM:
case MESA_FORMAT_A8R8G8B8_UNORM:
case MESA_FORMAT_Z24_UNORM_S8_UINT:
case MESA_FORMAT_S8_UINT_Z24_UNORM:
case MESA_FORMAT_Z_UNORM32:
return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8;
default:
assert(0);
}
}
static void
nv04_surface_copy_swizzle(struct gl_context *ctx,
struct nouveau_surface *dst,
struct nouveau_surface *src,
int dx, int dy, int sx, int sy,
int w, int h)
{
struct nouveau_pushbuf_refn refs[] = {
{ src->bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART },
{ dst->bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
};
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
struct nouveau_object *swzsurf = hw->swzsurf;
struct nv04_fifo *fifo = hw->chan->data;
/* Max width & height may not be the same on all HW, but must be POT */
const unsigned max_w = 1024;
const unsigned max_h = 1024;
unsigned sub_w = w > max_w ? max_w : w;
unsigned sub_h = h > max_h ? max_h : h;
unsigned x, y;
/* Swizzled surfaces must be POT */
assert(util_is_power_of_two_or_zero(dst->width) &&
util_is_power_of_two_or_zero(dst->height));
if (context_chipset(ctx) < 0x10) {
BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1);
PUSH_DATA (push, swzsurf->handle);
}
for (y = 0; y < h; y += sub_h) {
sub_h = MIN2(sub_h, h - y);
for (x = 0; x < w; x += sub_w) {
sub_w = MIN2(sub_w, w - x);
if (nouveau_pushbuf_space(push, 64, 4, 0) ||
nouveau_pushbuf_refn (push, refs, 2))
return;
BEGIN_NV04(push, NV04_SSWZ(DMA_IMAGE), 1);
PUSH_DATA (push, fifo->vram);
BEGIN_NV04(push, NV04_SSWZ(FORMAT), 2);
PUSH_DATA (push, swzsurf_format(dst->format) |
log2i(dst->width) << 16 |
log2i(dst->height) << 24);
PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0);
BEGIN_NV04(push, NV03_SIFM(DMA_IMAGE), 1);
PUSH_RELOC(push, src->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
BEGIN_NV04(push, NV05_SIFM(SURFACE), 1);
PUSH_DATA (push, swzsurf->handle);
BEGIN_NV04(push, NV03_SIFM(COLOR_FORMAT), 8);
PUSH_DATA (push, sifm_format(src->format));
PUSH_DATA (push, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
PUSH_DATA (push, (y + dy) << 16 | (x + dx));
PUSH_DATA (push, sub_h << 16 | sub_w);
PUSH_DATA (push, (y + dy) << 16 | (x + dx));
PUSH_DATA (push, sub_h << 16 | sub_w);
PUSH_DATA (push, 1 << 20);
PUSH_DATA (push, 1 << 20);
BEGIN_NV04(push, NV03_SIFM(SIZE), 4);
PUSH_DATA (push, align(sub_h, 2) << 16 | align(sub_w, 2));
PUSH_DATA (push, src->pitch |
NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
PUSH_RELOC(push, src->bo, src->offset + (y + sy) * src->pitch +
(x + sx) * src->cpp, NOUVEAU_BO_LOW, 0, 0);
PUSH_DATA (push, 0);
}
}
if (context_chipset(ctx) < 0x10) {
BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1);
PUSH_DATA (push, hw->surf3d->handle);
}
}
static void
nv04_surface_copy_m2mf(struct gl_context *ctx,
struct nouveau_surface *dst,
struct nouveau_surface *src,
int dx, int dy, int sx, int sy,
int w, int h)
{
struct nouveau_pushbuf_refn refs[] = {
{ src->bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART },
{ dst->bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART },
};
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
struct nv04_fifo *fifo = hw->chan->data;
unsigned dst_offset = dst->offset + dy * dst->pitch + dx * dst->cpp;
unsigned src_offset = src->offset + sy * src->pitch + sx * src->cpp;
while (h) {
int count = (h > 2047) ? 2047 : h;
if (nouveau_pushbuf_space(push, 16, 4, 0) ||
nouveau_pushbuf_refn (push, refs, 2))
return;
BEGIN_NV04(push, NV03_M2MF(DMA_BUFFER_IN), 2);
PUSH_RELOC(push, src->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
PUSH_RELOC(push, dst->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
BEGIN_NV04(push, NV03_M2MF(OFFSET_IN), 8);
PUSH_RELOC(push, src->bo, src->offset, NOUVEAU_BO_LOW, 0, 0);
PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0);
PUSH_DATA (push, src->pitch);
PUSH_DATA (push, dst->pitch);
PUSH_DATA (push, w * src->cpp);
PUSH_DATA (push, count);
PUSH_DATA (push, 0x0101);
PUSH_DATA (push, 0);
src_offset += src->pitch * count;
dst_offset += dst->pitch * count;
h -= count;
}
}
typedef unsigned (*get_offset_t)(struct nouveau_surface *s,
unsigned x, unsigned y);
static unsigned
get_linear_offset(struct nouveau_surface *s, unsigned x, unsigned y)
{
return x * s->cpp + y * s->pitch;
}
static unsigned
get_swizzled_offset(struct nouveau_surface *s, unsigned x, unsigned y)
{
unsigned k = log2i(MIN2(s->width, s->height));
unsigned u = (x & 0x001) << 0 |
(x & 0x002) << 1 |
(x & 0x004) << 2 |
(x & 0x008) << 3 |
(x & 0x010) << 4 |
(x & 0x020) << 5 |
(x & 0x040) << 6 |
(x & 0x080) << 7 |
(x & 0x100) << 8 |
(x & 0x200) << 9 |
(x & 0x400) << 10 |
(x & 0x800) << 11;
unsigned v = (y & 0x001) << 1 |
(y & 0x002) << 2 |
(y & 0x004) << 3 |
(y & 0x008) << 4 |
(y & 0x010) << 5 |
(y & 0x020) << 6 |
(y & 0x040) << 7 |
(y & 0x080) << 8 |
(y & 0x100) << 9 |
(y & 0x200) << 10 |
(y & 0x400) << 11 |
(y & 0x800) << 12;
return s->cpp * (((u | v) & ~(~0 << 2*k)) |
(x & (~0 << k)) << k |
(y & (~0 << k)) << k);
}
static void
nv04_surface_copy_cpu(struct gl_context *ctx,
struct nouveau_surface *dst,
struct nouveau_surface *src,
int dx, int dy, int sx, int sy,
int w, int h)
{
int x, y;
get_offset_t get_dst = (dst->layout == SWIZZLED ?
get_swizzled_offset : get_linear_offset);
get_offset_t get_src = (src->layout == SWIZZLED ?
get_swizzled_offset : get_linear_offset);
void *dp, *sp;
nouveau_bo_map(dst->bo, NOUVEAU_BO_WR, context_client(ctx));
nouveau_bo_map(src->bo, NOUVEAU_BO_RD, context_client(ctx));
dp = dst->bo->map + dst->offset;
sp = src->bo->map + src->offset;
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
memcpy(dp + get_dst(dst, dx + x, dy + y),
sp + get_src(src, sx + x, sy + y), dst->cpp);
}
}
}
void
nv04_surface_copy(struct gl_context *ctx,
struct nouveau_surface *dst,
struct nouveau_surface *src,
int dx, int dy, int sx, int sy,
int w, int h)
{
if (_mesa_is_format_compressed(src->format)) {
sx = get_format_blocksx(src->format, sx);
sy = get_format_blocksy(src->format, sy);
dx = get_format_blocksx(dst->format, dx);
dy = get_format_blocksy(dst->format, dy);
w = get_format_blocksx(src->format, w);
h = get_format_blocksy(src->format, h);
}
/* Linear texture copy. */
if ((src->layout == LINEAR && dst->layout == LINEAR) ||
dst->width <= 2 || dst->height <= 1) {
nv04_surface_copy_m2mf(ctx, dst, src, dx, dy, sx, sy, w, h);
return;
}
/* Swizzle using sifm+swzsurf. */
if (src->layout == LINEAR && dst->layout == SWIZZLED &&
dst->cpp != 1 && !(dst->offset & 63)) {
nv04_surface_copy_swizzle(ctx, dst, src, dx, dy, sx, sy, w, h);
return;
}
/* Fallback to CPU copy. */
nv04_surface_copy_cpu(ctx, dst, src, dx, dy, sx, sy, w, h);
}
void
nv04_surface_fill(struct gl_context *ctx,
struct nouveau_surface *dst,
unsigned mask, unsigned value,
int dx, int dy, int w, int h)
{
struct nouveau_pushbuf_refn refs[] = {
{ dst->bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART },
};
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
struct nv04_fifo *fifo = hw->chan->data;
if (nouveau_pushbuf_space(push, 64, 4, 0) ||
nouveau_pushbuf_refn (push, refs, 1))
return;
BEGIN_NV04(push, NV04_SF2D(DMA_IMAGE_SOURCE), 2);
PUSH_RELOC(push, dst->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
PUSH_RELOC(push, dst->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
BEGIN_NV04(push, NV04_SF2D(FORMAT), 4);
PUSH_DATA (push, surf2d_format(dst->format));
PUSH_DATA (push, (dst->pitch << 16) | dst->pitch);
PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0);
PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0);
BEGIN_NV04(push, NV01_PATT(COLOR_FORMAT), 1);
PUSH_DATA (push, rect_format(dst->format));
BEGIN_NV04(push, NV01_PATT(MONOCHROME_COLOR1), 1);
PUSH_DATA (push, mask | ~0ll << (8 * dst->cpp));
BEGIN_NV04(push, NV04_GDI(COLOR_FORMAT), 1);
PUSH_DATA (push, rect_format(dst->format));
BEGIN_NV04(push, NV04_GDI(COLOR1_A), 1);
PUSH_DATA (push, value);
BEGIN_NV04(push, NV04_GDI(UNCLIPPED_RECTANGLE_POINT(0)), 2);
PUSH_DATA (push, (dx << 16) | dy);
PUSH_DATA (push, ( w << 16) | h);
}
void
nv04_surface_takedown(struct gl_context *ctx)
{
struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
nouveau_object_del(&hw->swzsurf);
nouveau_object_del(&hw->sifm);
nouveau_object_del(&hw->rect);
nouveau_object_del(&hw->rop);
nouveau_object_del(&hw->patt);
nouveau_object_del(&hw->surf2d);
nouveau_object_del(&hw->m2mf);
nouveau_object_del(&hw->ntfy);
}
GLboolean
nv04_surface_init(struct gl_context *ctx)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
struct nouveau_object *chan = hw->chan;
unsigned handle = 0x88000000, class;
int ret;
/* Notifier object. */
ret = nouveau_object_new(chan, handle++, NOUVEAU_NOTIFIER_CLASS,
&(struct nv04_notify) {
.length = 32,
}, sizeof(struct nv04_notify), &hw->ntfy);
if (ret)
goto fail;
/* Memory to memory format. */
ret = nouveau_object_new(chan, handle++, NV03_M2MF_CLASS,
NULL, 0, &hw->m2mf);
if (ret)
goto fail;
BEGIN_NV04(push, NV01_SUBC(M2MF, OBJECT), 1);
PUSH_DATA (push, hw->m2mf->handle);
BEGIN_NV04(push, NV03_M2MF(DMA_NOTIFY), 1);
PUSH_DATA (push, hw->ntfy->handle);
/* Context surfaces 2D. */
if (context_chipset(ctx) < 0x10)
class = NV04_SURFACE_2D_CLASS;
else
class = NV10_SURFACE_2D_CLASS;
ret = nouveau_object_new(chan, handle++, class, NULL, 0, &hw->surf2d);
if (ret)
goto fail;
BEGIN_NV04(push, NV01_SUBC(SF2D, OBJECT), 1);
PUSH_DATA (push, hw->surf2d->handle);
/* Raster op. */
ret = nouveau_object_new(chan, handle++, NV03_ROP_CLASS,
NULL, 0, &hw->rop);
if (ret)
goto fail;
BEGIN_NV04(push, NV01_SUBC(PATT, OBJECT), 1);
PUSH_DATA (push, hw->rop->handle);
BEGIN_NV04(push, NV01_ROP(DMA_NOTIFY), 1);
PUSH_DATA (push, hw->ntfy->handle);
BEGIN_NV04(push, NV01_ROP(ROP), 1);
PUSH_DATA (push, 0xca); /* DPSDxax in the GDI speech. */
/* Image pattern. */
ret = nouveau_object_new(chan, handle++, NV04_PATTERN_CLASS,
NULL, 0, &hw->patt);
if (ret)
goto fail;
BEGIN_NV04(push, NV01_SUBC(PATT, OBJECT), 1);
PUSH_DATA (push, hw->patt->handle);
BEGIN_NV04(push, NV01_PATT(DMA_NOTIFY), 1);
PUSH_DATA (push, hw->ntfy->handle);
BEGIN_NV04(push, NV01_PATT(MONOCHROME_FORMAT), 3);
PUSH_DATA (push, NV04_IMAGE_PATTERN_MONOCHROME_FORMAT_LE);
PUSH_DATA (push, NV04_IMAGE_PATTERN_MONOCHROME_SHAPE_8X8);
PUSH_DATA (push, NV04_IMAGE_PATTERN_PATTERN_SELECT_MONO);
BEGIN_NV04(push, NV01_PATT(MONOCHROME_COLOR0), 4);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, ~0);
PUSH_DATA (push, ~0);
/* GDI rectangle text. */
ret = nouveau_object_new(chan, handle++, NV04_GDI_CLASS,
NULL, 0, &hw->rect);
if (ret)
goto fail;
BEGIN_NV04(push, NV01_SUBC(GDI, OBJECT), 1);
PUSH_DATA (push, hw->rect->handle);
BEGIN_NV04(push, NV04_GDI(DMA_NOTIFY), 1);
PUSH_DATA (push, hw->ntfy->handle);
BEGIN_NV04(push, NV04_GDI(SURFACE), 1);
PUSH_DATA (push, hw->surf2d->handle);
BEGIN_NV04(push, NV04_GDI(ROP), 1);
PUSH_DATA (push, hw->rop->handle);
BEGIN_NV04(push, NV04_GDI(PATTERN), 1);
PUSH_DATA (push, hw->patt->handle);
BEGIN_NV04(push, NV04_GDI(OPERATION), 1);
PUSH_DATA (push, NV04_GDI_RECTANGLE_TEXT_OPERATION_ROP_AND);
BEGIN_NV04(push, NV04_GDI(MONOCHROME_FORMAT), 1);
PUSH_DATA (push, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE);
/* Swizzled surface. */
if (context_chipset(ctx) < 0x20)
class = NV04_SURFACE_SWZ_CLASS;
else if (context_chipset (ctx) < 0x30)
class = NV20_SURFACE_SWZ_CLASS;
else
class = NV30_SURFACE_SWZ_CLASS;
ret = nouveau_object_new(chan, handle++, class, NULL, 0, &hw->swzsurf);
if (ret)
goto fail;
BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1);
PUSH_DATA (push, hw->swzsurf->handle);
/* Scaled image from memory. */
if (context_chipset(ctx) < 0x10)
class = NV04_SIFM_CLASS;
else
class = NV10_SIFM_CLASS;
ret = nouveau_object_new(chan, handle++, class, NULL, 0, &hw->sifm);
if (ret)
goto fail;
BEGIN_NV04(push, NV01_SUBC(SIFM, OBJECT), 1);
PUSH_DATA (push, hw->sifm->handle);
if (context_chipset(ctx) >= 0x10) {
BEGIN_NV04(push, NV05_SIFM(COLOR_CONVERSION), 1);
PUSH_DATA (push, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
}
return GL_TRUE;
fail:
nv04_surface_takedown(ctx);
return GL_FALSE;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,575 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <stdbool.h>
#include "main/state.h"
#include "util/u_memory.h"
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_fbo.h"
#include "nouveau_util.h"
#include "nv_object.xml.h"
#include "nv10_3d.xml.h"
#include "nv04_driver.h"
#include "nv10_driver.h"
static GLboolean
use_fast_zclear(struct gl_context *ctx, GLbitfield buffers)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
if (buffers & BUFFER_BIT_STENCIL) {
/*
* The stencil test is bypassed when fast Z clears are
* enabled.
*/
nctx->hierz.clear_blocked = GL_TRUE;
context_dirty(ctx, ZCLEAR);
return GL_FALSE;
}
return !nctx->hierz.clear_blocked &&
fb->_Xmax == fb->Width && fb->_Xmin == 0 &&
fb->_Ymax == fb->Height && fb->_Ymin == 0;
}
GLboolean
nv10_use_viewport_zclear(struct gl_context *ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct gl_renderbuffer *depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
return context_eng3d(ctx)->oclass < NV17_3D_CLASS &&
!nctx->hierz.clear_blocked && depthRb &&
(_mesa_get_format_bits(depthRb->Format,
GL_DEPTH_BITS) >= 24);
}
float
nv10_transform_depth(struct gl_context *ctx, float z)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
if (nv10_use_viewport_zclear(ctx))
return 2097152.0 * (z + (nctx->hierz.clear_seq & 7));
else
return ctx->DrawBuffer->_DepthMaxF * z;
}
static void
nv10_zclear(struct gl_context *ctx, GLbitfield *buffers)
{
/*
* Pre-nv17 cards don't have native support for fast Z clears,
* but in some cases we can still "clear" the Z buffer without
* actually blitting to it if we're willing to sacrifice a few
* bits of depth precision.
*
* Each time a clear is requested we modify the viewport
* transform in such a way that the old contents of the depth
* buffer are clamped to the requested clear value when
* they're read by the GPU.
*/
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb);
struct nouveau_surface *s = &to_nouveau_renderbuffer(
fb->Attachment[BUFFER_DEPTH].Renderbuffer)->surface;
if (nv10_use_viewport_zclear(ctx)) {
int x, y, w, h;
float z = ctx->Depth.Clear;
uint32_t value = pack_zs_f(s->format, z, 0);
get_scissors(fb, &x, &y, &w, &h);
*buffers &= ~BUFFER_BIT_DEPTH;
if (use_fast_zclear(ctx, *buffers)) {
if (nfb->hierz.clear_value != value) {
/* Don't fast clear if we're changing
* the depth value. */
nfb->hierz.clear_value = value;
} else if (z == 0.0) {
nctx->hierz.clear_seq++;
context_dirty(ctx, ZCLEAR);
if ((nctx->hierz.clear_seq & 7) != 0 &&
nctx->hierz.clear_seq != 1)
/* We didn't wrap around -- no need to
* clear the depth buffer for real. */
return;
} else if (z == 1.0) {
nctx->hierz.clear_seq--;
context_dirty(ctx, ZCLEAR);
if ((nctx->hierz.clear_seq & 7) != 7)
/* No wrap around */
return;
}
}
value = pack_zs_f(s->format,
(z + (nctx->hierz.clear_seq & 7)) / 8, 0);
context_drv(ctx)->surface_fill(ctx, s, ~0, value, x, y, w, h);
}
}
static void
nv17_zclear(struct gl_context *ctx, GLbitfield *buffers)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(
ctx->DrawBuffer);
struct nouveau_surface *s = &to_nouveau_renderbuffer(
nfb->base.Attachment[BUFFER_DEPTH].Renderbuffer)->surface;
/* Clear the hierarchical depth buffer */
BEGIN_NV04(push, NV17_3D(HIERZ_FILL_VALUE), 1);
PUSH_DATA (push, pack_zs_f(s->format, ctx->Depth.Clear, 0));
BEGIN_NV04(push, NV17_3D(HIERZ_BUFFER_CLEAR), 1);
PUSH_DATA (push, 1);
/* Mark the depth buffer as cleared */
if (use_fast_zclear(ctx, *buffers)) {
if (nctx->hierz.clear_seq)
*buffers &= ~BUFFER_BIT_DEPTH;
nfb->hierz.clear_value =
pack_zs_f(s->format, ctx->Depth.Clear, 0);
nctx->hierz.clear_seq++;
context_dirty(ctx, ZCLEAR);
}
}
static void
nv10_clear(struct gl_context *ctx, GLbitfield buffers)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
nouveau_validate_framebuffer(ctx);
nouveau_pushbuf_bufctx(push, nctx->hw.bufctx);
if (nouveau_pushbuf_validate(push)) {
nouveau_pushbuf_bufctx(push, NULL);
return;
}
if ((buffers & BUFFER_BIT_DEPTH) && ctx->Depth.Mask) {
if (context_eng3d(ctx)->oclass >= NV17_3D_CLASS)
nv17_zclear(ctx, &buffers);
else
nv10_zclear(ctx, &buffers);
/* Emit the zclear state if it's dirty */
_mesa_update_state(ctx);
}
nouveau_pushbuf_bufctx(push, NULL);
nouveau_clear(ctx, buffers);
}
static void
nv10_hwctx_init(struct gl_context *ctx)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
struct nv04_fifo *fifo = hw->chan->data;
int i;
BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1);
PUSH_DATA (push, hw->eng3d->handle);
BEGIN_NV04(push, NV10_3D(DMA_NOTIFY), 1);
PUSH_DATA (push, hw->ntfy->handle);
BEGIN_NV04(push, NV10_3D(DMA_TEXTURE0), 3);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->gart);
PUSH_DATA (push, fifo->gart);
BEGIN_NV04(push, NV10_3D(DMA_COLOR), 2);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->vram);
BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(RT_HORIZ), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_HORIZ(0)), 1);
PUSH_DATA (push, 0x7ff << 16 | 0x800);
BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_VERT(0)), 1);
PUSH_DATA (push, 0x7ff << 16 | 0x800);
for (i = 1; i < 8; i++) {
BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_HORIZ(i)), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_VERT(i)), 1);
PUSH_DATA (push, 0);
}
BEGIN_NV04(push, SUBC_3D(0x290), 1);
PUSH_DATA (push, 0x10 << 16 | 1);
BEGIN_NV04(push, SUBC_3D(0x3f4), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1);
PUSH_DATA (push, 0);
if (context_eng3d(ctx)->oclass >= NV17_3D_CLASS) {
BEGIN_NV04(push, NV17_3D(UNK01AC), 2);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->vram);
BEGIN_NV04(push, SUBC_3D(0xd84), 1);
PUSH_DATA (push, 0x3);
BEGIN_NV04(push, NV17_3D(COLOR_MASK_ENABLE), 1);
PUSH_DATA (push, 1);
}
if (context_eng3d(ctx)->oclass >= NV15_3D_CLASS) {
BEGIN_NV04(push, SUBC_3D(0x120), 3);
PUSH_DATA (push, 0);
PUSH_DATA (push, 1);
PUSH_DATA (push, 2);
BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1);
PUSH_DATA (push, 0);
}
BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1);
PUSH_DATA (push, 0);
/* Set state */
BEGIN_NV04(push, NV10_3D(FOG_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_FUNC), 2);
PUSH_DATA (push, 0x207);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(TEX_ENABLE(0)), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(BLEND_FUNC_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(DITHER_ENABLE), 2);
PUSH_DATA (push, 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(LINE_SMOOTH_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(VERTEX_WEIGHT_ENABLE), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(BLEND_FUNC_SRC), 4);
PUSH_DATA (push, 1);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0x8006);
BEGIN_NV04(push, NV10_3D(STENCIL_MASK), 8);
PUSH_DATA (push, 0xff);
PUSH_DATA (push, 0x207);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0xff);
PUSH_DATA (push, 0x1e00);
PUSH_DATA (push, 0x1e00);
PUSH_DATA (push, 0x1e00);
PUSH_DATA (push, 0x1d01);
BEGIN_NV04(push, NV10_3D(NORMALIZE_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(FOG_ENABLE), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(LIGHT_MODEL), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(SEPARATE_SPECULAR_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(ENABLED_LIGHTS), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(POLYGON_OFFSET_POINT_ENABLE), 3);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(DEPTH_FUNC), 1);
PUSH_DATA (push, 0x201);
BEGIN_NV04(push, NV10_3D(DEPTH_WRITE_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(DEPTH_TEST_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(POLYGON_OFFSET_FACTOR), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(POINT_SIZE), 1);
PUSH_DATA (push, 8);
BEGIN_NV04(push, NV10_3D(POINT_PARAMETERS_ENABLE), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(LINE_WIDTH), 1);
PUSH_DATA (push, 8);
BEGIN_NV04(push, NV10_3D(LINE_SMOOTH_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(POLYGON_MODE_FRONT), 2);
PUSH_DATA (push, 0x1b02);
PUSH_DATA (push, 0x1b02);
BEGIN_NV04(push, NV10_3D(CULL_FACE), 2);
PUSH_DATA (push, 0x405);
PUSH_DATA (push, 0x901);
BEGIN_NV04(push, NV10_3D(POLYGON_SMOOTH_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(CULL_FACE_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(TEX_GEN_MODE(0, 0)), 8);
for (i = 0; i < 8; i++)
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(TEX_MATRIX_ENABLE(0)), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(FOG_COEFF(0)), 3);
PUSH_DATA (push, 0x3fc00000); /* -1.50 */
PUSH_DATA (push, 0xbdb8aa0a); /* -0.09 */
PUSH_DATA (push, 0); /* 0.00 */
BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(FOG_MODE), 2);
PUSH_DATA (push, 0x802);
PUSH_DATA (push, 2);
/* for some reason VIEW_MATRIX_ENABLE need to be 6 instead of 4 when
* using texturing, except when using the texture matrix
*/
BEGIN_NV04(push, NV10_3D(VIEW_MATRIX_ENABLE), 1);
PUSH_DATA (push, 6);
BEGIN_NV04(push, NV10_3D(COLOR_MASK), 1);
PUSH_DATA (push, 0x01010101);
/* Set vertex component */
BEGIN_NV04(push, NV10_3D(VERTEX_COL_4F_R), 4);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
BEGIN_NV04(push, NV10_3D(VERTEX_COL2_3F_R), 3);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV10_3D(VERTEX_NOR_3F_X), 3);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATAf(push, 1.0);
BEGIN_NV04(push, NV10_3D(VERTEX_TX0_4F_S), 4);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
BEGIN_NV04(push, NV10_3D(VERTEX_TX1_4F_S), 4);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
BEGIN_NV04(push, NV10_3D(VERTEX_FOG_1F), 1);
PUSH_DATAf(push, 0.0);
BEGIN_NV04(push, NV10_3D(EDGEFLAG_ENABLE), 1);
PUSH_DATA (push, 1);
BEGIN_NV04(push, NV10_3D(DEPTH_RANGE_NEAR), 2);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 16777216.0);
PUSH_KICK (push);
}
static void
nv10_context_destroy(struct gl_context *ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
nv04_surface_takedown(ctx);
nv10_swtnl_destroy(ctx);
nv10_vbo_destroy(ctx);
nouveau_object_del(&nctx->hw.eng3d);
nouveau_context_deinit(ctx);
align_free(ctx);
}
static struct gl_context *
nv10_context_create(struct nouveau_screen *screen, gl_api api,
const struct gl_config *visual,
struct gl_context *share_ctx)
{
struct nouveau_context *nctx;
struct gl_context *ctx;
unsigned celsius_class;
int ret;
nctx = align_calloc(sizeof(struct nouveau_context), 16);
if (!nctx)
return NULL;
ctx = &nctx->base;
if (!nouveau_context_init(ctx, api, screen, visual, share_ctx))
goto fail;
ctx->Extensions.ARB_texture_env_crossbar = true;
ctx->Extensions.ARB_texture_env_combine = true;
ctx->Extensions.ARB_texture_env_dot3 = true;
ctx->Extensions.EXT_texture_env_dot3 = true;
ctx->Extensions.NV_fog_distance = true;
ctx->Extensions.NV_texture_rectangle = true;
ctx->Extensions.EXT_texture_compression_s3tc = true;
ctx->Extensions.ANGLE_texture_compression_dxt = true;
/* GL constants. */
ctx->Const.MaxTextureSize = 2048;
ctx->Const.MaxTextureCoordUnits = NV10_TEXTURE_UNITS;
ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = NV10_TEXTURE_UNITS;
ctx->Const.MaxTextureUnits = NV10_TEXTURE_UNITS;
ctx->Const.MaxTextureMaxAnisotropy = 2;
ctx->Const.MaxTextureLodBias = 15;
ctx->Driver.Clear = nv10_clear;
/* 2D engine. */
ret = nv04_surface_init(ctx);
if (!ret)
goto fail;
/* 3D engine. */
if (context_chipset(ctx) >= 0x17 && context_chipset(ctx) != 0x1a)
celsius_class = NV17_3D_CLASS;
else if (context_chipset(ctx) >= 0x11)
celsius_class = NV15_3D_CLASS;
else
celsius_class = NV10_3D_CLASS;
ret = nouveau_object_new(context_chan(ctx), 0xbeef0001, celsius_class,
NULL, 0, &nctx->hw.eng3d);
if (ret)
goto fail;
nv10_hwctx_init(ctx);
nv10_vbo_init(ctx);
nv10_swtnl_init(ctx);
return ctx;
fail:
nv10_context_destroy(ctx);
return NULL;
}
const struct nouveau_driver nv10_driver = {
.context_create = nv10_context_create,
.context_destroy = nv10_context_destroy,
.surface_copy = nv04_surface_copy,
.surface_fill = nv04_surface_fill,
.emit = (nouveau_state_func[]) {
nv10_emit_alpha_func,
nv10_emit_blend_color,
nv10_emit_blend_equation,
nv10_emit_blend_func,
nv10_emit_clip_plane,
nv10_emit_clip_plane,
nv10_emit_clip_plane,
nv10_emit_clip_plane,
nv10_emit_clip_plane,
nv10_emit_clip_plane,
nv10_emit_color_mask,
nv10_emit_color_material,
nv10_emit_cull_face,
nv10_emit_front_face,
nv10_emit_depth,
nv10_emit_dither,
nv10_emit_frag,
nv10_emit_framebuffer,
nv10_emit_fog,
nv10_emit_light_enable,
nv10_emit_light_model,
nv10_emit_light_source,
nv10_emit_light_source,
nv10_emit_light_source,
nv10_emit_light_source,
nv10_emit_light_source,
nv10_emit_light_source,
nv10_emit_light_source,
nv10_emit_light_source,
nv10_emit_line_stipple,
nv10_emit_line_mode,
nv10_emit_logic_opcode,
nv10_emit_material_ambient,
nouveau_emit_nothing,
nv10_emit_material_diffuse,
nouveau_emit_nothing,
nv10_emit_material_specular,
nouveau_emit_nothing,
nv10_emit_material_shininess,
nouveau_emit_nothing,
nv10_emit_modelview,
nv10_emit_point_mode,
nv10_emit_point_parameter,
nv10_emit_polygon_mode,
nv10_emit_polygon_offset,
nv10_emit_polygon_stipple,
nv10_emit_projection,
nv10_emit_render_mode,
nv10_emit_scissor,
nv10_emit_shade_model,
nv10_emit_stencil_func,
nv10_emit_stencil_mask,
nv10_emit_stencil_op,
nv10_emit_tex_env,
nv10_emit_tex_env,
nouveau_emit_nothing,
nouveau_emit_nothing,
nv10_emit_tex_gen,
nv10_emit_tex_gen,
nouveau_emit_nothing,
nouveau_emit_nothing,
nv10_emit_tex_mat,
nv10_emit_tex_mat,
nouveau_emit_nothing,
nouveau_emit_nothing,
nv10_emit_tex_obj,
nv10_emit_tex_obj,
nouveau_emit_nothing,
nouveau_emit_nothing,
nv10_emit_viewport,
nv10_emit_zclear
},
.num_emit = NUM_NV10_STATE,
};

View File

@ -1,211 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NV10_DRIVER_H__
#define __NV10_DRIVER_H__
enum {
NOUVEAU_STATE_ZCLEAR = NUM_NOUVEAU_STATE,
NUM_NV10_STATE
};
#define NV10_TEXTURE_UNITS 2
/* nv10_context.c */
extern const struct nouveau_driver nv10_driver;
GLboolean
nv10_use_viewport_zclear(struct gl_context *ctx);
float
nv10_transform_depth(struct gl_context *ctx, float z);
/* nv10_render.c */
void
nv10_vbo_init(struct gl_context *ctx);
void
nv10_vbo_destroy(struct gl_context *ctx);
void
nv10_swtnl_init(struct gl_context *ctx);
void
nv10_swtnl_destroy(struct gl_context *ctx);
/* nv10_state_fb.c */
void
nv10_emit_framebuffer(struct gl_context *ctx, int emit);
void
nv10_emit_render_mode(struct gl_context *ctx, int emit);
void
nv10_emit_scissor(struct gl_context *ctx, int emit);
void
nv10_emit_viewport(struct gl_context *ctx, int emit);
void
nv10_emit_zclear(struct gl_context *ctx, int emit);
/* nv10_state_polygon.c */
void
nv10_emit_cull_face(struct gl_context *ctx, int emit);
void
nv10_emit_front_face(struct gl_context *ctx, int emit);
void
nv10_emit_line_mode(struct gl_context *ctx, int emit);
void
nv10_emit_line_stipple(struct gl_context *ctx, int emit);
void
nv10_emit_point_mode(struct gl_context *ctx, int emit);
void
nv10_emit_polygon_mode(struct gl_context *ctx, int emit);
void
nv10_emit_polygon_offset(struct gl_context *ctx, int emit);
void
nv10_emit_polygon_stipple(struct gl_context *ctx, int emit);
/* nv10_state_raster.c */
void
nv10_emit_alpha_func(struct gl_context *ctx, int emit);
void
nv10_emit_blend_color(struct gl_context *ctx, int emit);
void
nv10_emit_blend_equation(struct gl_context *ctx, int emit);
void
nv10_emit_blend_func(struct gl_context *ctx, int emit);
void
nv10_emit_color_mask(struct gl_context *ctx, int emit);
void
nv10_emit_depth(struct gl_context *ctx, int emit);
void
nv10_emit_dither(struct gl_context *ctx, int emit);
void
nv10_emit_logic_opcode(struct gl_context *ctx, int emit);
void
nv10_emit_shade_model(struct gl_context *ctx, int emit);
void
nv10_emit_stencil_func(struct gl_context *ctx, int emit);
void
nv10_emit_stencil_mask(struct gl_context *ctx, int emit);
void
nv10_emit_stencil_op(struct gl_context *ctx, int emit);
/* nv10_state_frag.c */
void
nv10_get_general_combiner(struct gl_context *ctx, int i,
uint32_t *a_in, uint32_t *a_out,
uint32_t *c_in, uint32_t *c_out, uint32_t *k);
void
nv10_get_final_combiner(struct gl_context *ctx, uint64_t *in, int *n);
void
nv10_emit_tex_env(struct gl_context *ctx, int emit);
void
nv10_emit_frag(struct gl_context *ctx, int emit);
/* nv10_state_tex.c */
void
nv10_emit_tex_gen(struct gl_context *ctx, int emit);
void
nv10_emit_tex_mat(struct gl_context *ctx, int emit);
void
nv10_emit_tex_obj(struct gl_context *ctx, int emit);
/* nv10_state_tnl.c */
void
nv10_get_fog_coeff(struct gl_context *ctx, float k[3]);
void
nv10_get_spot_coeff(struct gl_light *l, struct gl_light_uniforms *lu, float k[7]);
void
nv10_get_shininess_coeff(float s, float k[6]);
void
nv10_emit_clip_plane(struct gl_context *ctx, int emit);
void
nv10_emit_color_material(struct gl_context *ctx, int emit);
void
nv10_emit_fog(struct gl_context *ctx, int emit);
void
nv10_emit_light_enable(struct gl_context *ctx, int emit);
void
nv10_emit_light_model(struct gl_context *ctx, int emit);
void
nv10_emit_light_source(struct gl_context *ctx, int emit);
void
nv10_emit_material_ambient(struct gl_context *ctx, int emit);
void
nv10_emit_material_diffuse(struct gl_context *ctx, int emit);
void
nv10_emit_material_specular(struct gl_context *ctx, int emit);
void
nv10_emit_material_shininess(struct gl_context *ctx, int emit);
void
nv10_emit_modelview(struct gl_context *ctx, int emit);
void
nv10_emit_point_parameter(struct gl_context *ctx, int emit);
void
nv10_emit_projection(struct gl_context *ctx, int emit);
#endif

View File

@ -1,200 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nv10_3d.xml.h"
#include "nv10_driver.h"
#define NUM_VERTEX_ATTRS 8
static void
nv10_emit_material(struct gl_context *ctx, struct nouveau_array *a,
const void *v);
/* Vertex attribute format. */
static struct nouveau_attr_info nv10_vertex_attrs[VERT_ATTRIB_MAX] = {
[VERT_ATTRIB_POS] = {
.vbo_index = 0,
.imm_method = NV10_3D_VERTEX_POS_4F_X,
.imm_fields = 4,
},
[VERT_ATTRIB_COLOR0] = {
.vbo_index = 1,
.imm_method = NV10_3D_VERTEX_COL_4F_R,
.imm_fields = 4,
},
[VERT_ATTRIB_COLOR1] = {
.vbo_index = 2,
.imm_method = NV10_3D_VERTEX_COL2_3F_R,
.imm_fields = 3,
},
[VERT_ATTRIB_TEX0] = {
.vbo_index = 3,
.imm_method = NV10_3D_VERTEX_TX0_4F_S,
.imm_fields = 4,
},
[VERT_ATTRIB_TEX1] = {
.vbo_index = 4,
.imm_method = NV10_3D_VERTEX_TX1_4F_S,
.imm_fields = 4,
},
[VERT_ATTRIB_NORMAL] = {
.vbo_index = 5,
.imm_method = NV10_3D_VERTEX_NOR_3F_X,
.imm_fields = 3,
},
[VERT_ATTRIB_FOG] = {
.vbo_index = 7,
.imm_method = NV10_3D_VERTEX_FOG_1F,
.imm_fields = 1,
},
[VERT_ATTRIB_MAT(0)] = {
.emit = nv10_emit_material,
},
[VERT_ATTRIB_MAT(2)] = {
.emit = nv10_emit_material,
},
[VERT_ATTRIB_MAT(4)] = {
.emit = nv10_emit_material,
},
[VERT_ATTRIB_MAT(6)] = {
.emit = nv10_emit_material,
},
[VERT_ATTRIB_MAT(8)] = {
.emit = nv10_emit_material,
},
};
static int
get_hw_format(int type)
{
switch (type) {
case GL_FLOAT:
return NV10_3D_VTXBUF_FMT_TYPE_V32_FLOAT;
case GL_SHORT:
case GL_UNSIGNED_SHORT:
return NV10_3D_VTXBUF_FMT_TYPE_V16_SNORM;
case GL_UNSIGNED_BYTE:
return NV10_3D_VTXBUF_FMT_TYPE_U8_UNORM;
default:
assert(0);
}
}
static void
nv10_render_set_format(struct gl_context *ctx)
{
struct nouveau_render_state *render = to_render_state(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
int i, attr, hw_format;
FOR_EACH_ATTR(render, i, attr) {
if (attr >= 0) {
struct nouveau_array *a = &render->attrs[attr];
hw_format = a->stride << 8 |
a->fields << 4 |
get_hw_format(a->type);
if (attr == VERT_ATTRIB_POS && a->fields == 4)
hw_format |= NV10_3D_VTXBUF_FMT_HOMOGENEOUS;
} else {
/* Unused attribute. */
hw_format = NV10_3D_VTXBUF_FMT_TYPE_V32_FLOAT;
}
BEGIN_NV04(push, NV10_3D(VTXBUF_FMT(i)), 1);
PUSH_DATA (push, hw_format);
}
}
static void
nv10_render_bind_vertices(struct gl_context *ctx)
{
struct nouveau_render_state *render = to_render_state(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
int i, attr;
FOR_EACH_BOUND_ATTR(render, i, attr) {
struct nouveau_array *a = &render->attrs[attr];
BEGIN_NV04(push, NV10_3D(VTXBUF_OFFSET(i)), 1);
PUSH_MTHDl(push, NV10_3D(VTXBUF_OFFSET(i)), BUFCTX_VTX,
a->bo, a->offset, NOUVEAU_BO_GART |
NOUVEAU_BO_RD);
}
}
static void
nv10_render_release_vertices(struct gl_context *ctx)
{
PUSH_RESET(context_push(ctx), BUFCTX_VTX);
}
/* Vertex array rendering defs. */
#define RENDER_LOCALS(ctx)
#define BATCH_VALIDATE() \
BEGIN_NV04(push, NV10_3D(VTXBUF_VALIDATE), 1); \
PUSH_DATA (push, 0)
#define BATCH_BEGIN(prim) \
BEGIN_NV04(push, NV10_3D(VTXBUF_BEGIN_END), 1); \
PUSH_DATA (push, prim)
#define BATCH_END() \
BEGIN_NV04(push, NV10_3D(VTXBUF_BEGIN_END), 1); \
PUSH_DATA (push, 0)
#define MAX_PACKET 0x400
#define MAX_OUT_L 0x100
#define BATCH_PACKET_L(n) \
BEGIN_NI04(push, NV10_3D(VTXBUF_BATCH), n)
#define BATCH_OUT_L(i, n) \
PUSH_DATA (push, ((n) - 1) << 24 | (i))
#define MAX_OUT_I16 0x2
#define BATCH_PACKET_I16(n) \
BEGIN_NI04(push, NV10_3D(VTXBUF_ELEMENT_U16), n)
#define BATCH_OUT_I16(i0, i1) \
PUSH_DATA (push, (i1) << 16 | (i0))
#define MAX_OUT_I32 0x1
#define BATCH_PACKET_I32(n) \
BEGIN_NI04(push, NV10_3D(VTXBUF_ELEMENT_U32), n)
#define BATCH_OUT_I32(i) \
PUSH_DATA (push, i)
#define IMM_PACKET(m, n) \
BEGIN_NV04(push, SUBC_3D(m), n)
#define IMM_OUT(x) \
PUSH_DATAf(push, x)
#define TAG(x) nv10_##x
#include "nouveau_render_t.c"
#include "nouveau_vbo_t.c"
#include "nouveau_swtnl_t.c"

View File

@ -1,220 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_fbo.h"
#include "nouveau_util.h"
#include "nv_object.xml.h"
#include "nv10_3d.xml.h"
#include "nv10_driver.h"
static inline unsigned
get_rt_format(mesa_format format)
{
switch (format) {
case MESA_FORMAT_B8G8R8X8_UNORM:
return NV10_3D_RT_FORMAT_COLOR_X8R8G8B8;
case MESA_FORMAT_B8G8R8A8_UNORM:
return NV10_3D_RT_FORMAT_COLOR_A8R8G8B8;
case MESA_FORMAT_B5G6R5_UNORM:
return NV10_3D_RT_FORMAT_COLOR_R5G6B5;
case MESA_FORMAT_Z_UNORM16:
return NV10_3D_RT_FORMAT_DEPTH_Z16;
case MESA_FORMAT_S8_UINT_Z24_UNORM:
return NV10_3D_RT_FORMAT_DEPTH_Z24S8;
default:
assert(0);
}
}
static void
setup_hierz_buffer(struct gl_context *ctx)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb);
unsigned pitch = align(fb->Width, 128),
height = align(fb->Height, 2),
size = pitch * height;
if (!nfb->hierz.bo || nfb->hierz.bo->size != size) {
union nouveau_bo_config config = {
.nv04.surf_flags = NV04_BO_ZETA,
.nv04.surf_pitch = 0
};
nouveau_bo_ref(NULL, &nfb->hierz.bo);
nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_VRAM, 0, size,
&config, &nfb->hierz.bo);
}
PUSH_SPACE(push, 11);
BEGIN_NV04(push, NV17_3D(HIERZ_OFFSET), 1);
PUSH_MTHDl(push, NV17_3D(HIERZ_OFFSET), BUFCTX_FB,
nfb->hierz.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
BEGIN_NV04(push, NV17_3D(HIERZ_WINDOW_X), 4);
PUSH_DATAf(push, - 1792);
PUSH_DATAf(push, - 2304 + fb->Height);
PUSH_DATAf(push, fb->_DepthMaxF / 2);
PUSH_DATAf(push, 0);
BEGIN_NV04(push, NV17_3D(HIERZ_PITCH), 1);
PUSH_DATA (push, pitch);
BEGIN_NV04(push, NV17_3D(HIERZ_ENABLE), 1);
PUSH_DATA (push, 1);
}
void
nv10_emit_framebuffer(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct nouveau_surface *s;
unsigned rt_format = NV10_3D_RT_FORMAT_TYPE_LINEAR;
unsigned rt_pitch = 0, zeta_pitch = 0;
unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR;
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT)
return;
PUSH_RESET(push, BUFCTX_FB);
/* At least nv11 seems to get sad if we don't do this before
* swapping RTs.*/
if (context_eng3d(ctx)->oclass < NV17_3D_CLASS) {
int i;
for (i = 0; i < 6; i++) {
BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1);
PUSH_DATA (push, 0);
}
}
/* Render target */
if (fb->_ColorDrawBuffers[0]) {
s = &to_nouveau_renderbuffer(
fb->_ColorDrawBuffers[0])->surface;
rt_format |= get_rt_format(s->format);
zeta_pitch = rt_pitch = s->pitch;
BEGIN_NV04(push, NV10_3D(COLOR_OFFSET), 1);
PUSH_MTHDl(push, NV10_3D(COLOR_OFFSET), BUFCTX_FB,
s->bo, 0, bo_flags);
}
/* depth/stencil */
if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
s = &to_nouveau_renderbuffer(
fb->Attachment[BUFFER_DEPTH].Renderbuffer)->surface;
rt_format |= get_rt_format(s->format);
zeta_pitch = s->pitch;
BEGIN_NV04(push, NV10_3D(ZETA_OFFSET), 1);
PUSH_MTHDl(push, NV10_3D(ZETA_OFFSET), BUFCTX_FB,
s->bo, 0, bo_flags);
if (context_eng3d(ctx)->oclass >= NV17_3D_CLASS) {
setup_hierz_buffer(ctx);
context_dirty(ctx, ZCLEAR);
}
}
BEGIN_NV04(push, NV10_3D(RT_FORMAT), 2);
PUSH_DATA (push, rt_format);
PUSH_DATA (push, zeta_pitch << 16 | rt_pitch);
context_dirty(ctx, VIEWPORT);
context_dirty(ctx, SCISSOR);
context_dirty(ctx, DEPTH);
}
void
nv10_emit_render_mode(struct gl_context *ctx, int emit)
{
}
void
nv10_emit_scissor(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
int x, y, w, h;
get_scissors(ctx->DrawBuffer, &x, &y, &w, &h);
BEGIN_NV04(push, NV10_3D(RT_HORIZ), 2);
PUSH_DATA (push, w << 16 | x);
PUSH_DATA (push, h << 16 | y);
}
void
nv10_emit_viewport(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_viewport_attrib *vp = &ctx->ViewportArray[0];
struct gl_framebuffer *fb = ctx->DrawBuffer;
float a[4] = {};
get_viewport_translate(ctx, a);
a[0] -= 2048;
a[1] -= 2048;
if (nv10_use_viewport_zclear(ctx))
a[2] = nv10_transform_depth(ctx, (vp->Far + vp->Near) / 2);
BEGIN_NV04(push, NV10_3D(VIEWPORT_TRANSLATE_X), 4);
PUSH_DATAp(push, a, 4);
BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_HORIZ(0)), 1);
PUSH_DATA (push, (fb->Width - 1) << 16 | 0x08000800);
BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_VERT(0)), 1);
PUSH_DATA (push, (fb->Height - 1) << 16 | 0x08000800);
context_dirty(ctx, PROJECTION);
}
void
nv10_emit_zclear(struct gl_context *ctx, int emit)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_framebuffer *nfb =
to_nouveau_framebuffer(ctx->DrawBuffer);
if (nfb->hierz.bo) {
BEGIN_NV04(push, NV17_3D(ZCLEAR_ENABLE), 2);
PUSH_DATAb(push, !nctx->hierz.clear_blocked);
PUSH_DATA (push, nfb->hierz.clear_value |
(nctx->hierz.clear_seq & 0xff));
} else {
BEGIN_NV04(push, NV10_3D(DEPTH_RANGE_NEAR), 2);
PUSH_DATAf(push, nv10_transform_depth(ctx, 0));
PUSH_DATAf(push, nv10_transform_depth(ctx, 1));
context_dirty(ctx, VIEWPORT);
}
}

View File

@ -1,423 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_gldefs.h"
#include "nv10_3d.xml.h"
#include "nouveau_util.h"
#include "nv10_driver.h"
#include "nv20_driver.h"
#define RC_IN_SHIFT_A 24
#define RC_IN_SHIFT_B 16
#define RC_IN_SHIFT_C 8
#define RC_IN_SHIFT_D 0
#define RC_IN_SHIFT_E 56
#define RC_IN_SHIFT_F 48
#define RC_IN_SHIFT_G 40
#define RC_IN_SOURCE(source) \
((uint64_t)NV10_3D_RC_IN_RGB_D_INPUT_##source)
#define RC_IN_USAGE(usage) \
((uint64_t)NV10_3D_RC_IN_RGB_D_COMPONENT_USAGE_##usage)
#define RC_IN_MAPPING(mapping) \
((uint64_t)NV10_3D_RC_IN_RGB_D_MAPPING_##mapping)
#define RC_OUT_BIAS NV10_3D_RC_OUT_RGB_BIAS_BIAS_BY_NEGATIVE_ONE_HALF
#define RC_OUT_SCALE_1 NV10_3D_RC_OUT_RGB_SCALE_NONE
#define RC_OUT_SCALE_2 NV10_3D_RC_OUT_RGB_SCALE_SCALE_BY_TWO
#define RC_OUT_SCALE_4 NV10_3D_RC_OUT_RGB_SCALE_SCALE_BY_FOUR
/* Make the combiner do: spare0_i = A_i * B_i */
#define RC_OUT_AB NV10_3D_RC_OUT_RGB_AB_OUTPUT_SPARE0
/* spare0_i = dot3(A, B) */
#define RC_OUT_DOT_AB (NV10_3D_RC_OUT_RGB_AB_OUTPUT_SPARE0 | \
NV10_3D_RC_OUT_RGB_AB_DOT_PRODUCT)
/* spare0_i = A_i * B_i + C_i * D_i */
#define RC_OUT_SUM NV10_3D_RC_OUT_RGB_SUM_OUTPUT_SPARE0
struct combiner_state {
struct gl_context *ctx;
int unit;
GLboolean premodulate;
/* GL state */
GLenum mode;
GLenum16 *source;
GLenum16 *operand;
GLuint logscale;
/* Derived HW state */
uint64_t in;
uint32_t out;
};
/* Initialize a combiner_state struct from the texture unit
* context. */
#define INIT_COMBINER(chan, ctx, rc, i) do { \
struct gl_tex_env_combine_state *c = \
ctx->Texture.FixedFuncUnit[i]._CurrentCombine; \
(rc)->ctx = ctx; \
(rc)->unit = i; \
(rc)->premodulate = c->_NumArgs##chan == 4; \
(rc)->mode = c->Mode##chan; \
(rc)->source = c->Source##chan; \
(rc)->operand = c->Operand##chan; \
(rc)->logscale = c->ScaleShift##chan; \
(rc)->in = (rc)->out = 0; \
} while (0)
/* Get the RC input source for the specified EXT_texture_env_combine
* source. */
static uint32_t
get_input_source(struct combiner_state *rc, int source)
{
switch (source) {
case GL_ZERO:
return RC_IN_SOURCE(ZERO);
case GL_TEXTURE:
return RC_IN_SOURCE(TEXTURE0) + rc->unit;
case GL_TEXTURE0:
return RC_IN_SOURCE(TEXTURE0);
case GL_TEXTURE1:
return RC_IN_SOURCE(TEXTURE1);
case GL_TEXTURE2:
return RC_IN_SOURCE(TEXTURE2);
case GL_TEXTURE3:
return RC_IN_SOURCE(TEXTURE3);
case GL_CONSTANT:
return context_chipset(rc->ctx) >= 0x20 ?
RC_IN_SOURCE(CONSTANT_COLOR0) :
RC_IN_SOURCE(CONSTANT_COLOR0) + rc->unit;
case GL_PRIMARY_COLOR:
return RC_IN_SOURCE(PRIMARY_COLOR);
case GL_PREVIOUS:
return rc->unit ? RC_IN_SOURCE(SPARE0)
: RC_IN_SOURCE(PRIMARY_COLOR);
default:
assert(0);
}
}
/* Get the RC input mapping for the specified texture_env_combine
* operand, possibly inverted or biased. */
#define INVERT 0x1
#define NORMALIZE 0x2
static uint32_t
get_input_mapping(struct combiner_state *rc, int operand, int flags)
{
int map = 0;
if (is_color_operand(operand))
map |= RC_IN_USAGE(RGB);
else
map |= RC_IN_USAGE(ALPHA);
if (is_negative_operand(operand) == !(flags & INVERT))
map |= flags & NORMALIZE ?
RC_IN_MAPPING(EXPAND_NEGATE) :
RC_IN_MAPPING(UNSIGNED_INVERT);
else
map |= flags & NORMALIZE ?
RC_IN_MAPPING(EXPAND_NORMAL) :
RC_IN_MAPPING(UNSIGNED_IDENTITY);
return map;
}
static uint32_t
get_input_arg(struct combiner_state *rc, int arg, int flags)
{
int source = rc->source[arg];
int operand = rc->operand[arg];
/* Fake several unsupported texture formats. */
if (is_texture_source(source)) {
int i = (source == GL_TEXTURE ?
rc->unit : source - GL_TEXTURE0);
struct gl_texture_object *t = rc->ctx->Texture.Unit[i]._Current;
mesa_format format = t->Image[0][t->Attrib.BaseLevel]->TexFormat;
if (format == MESA_FORMAT_A_UNORM8) {
/* Emulated using I8. */
if (is_color_operand(operand))
return RC_IN_SOURCE(ZERO) |
get_input_mapping(rc, operand, flags);
} else if (format == MESA_FORMAT_L_UNORM8) {
/* Sometimes emulated using I8. */
if (!is_color_operand(operand))
return RC_IN_SOURCE(ZERO) |
get_input_mapping(rc, operand,
flags ^ INVERT);
} else if (format == MESA_FORMAT_B8G8R8X8_UNORM) {
/* Sometimes emulated using ARGB8888. */
if (!is_color_operand(operand))
return RC_IN_SOURCE(ZERO) |
get_input_mapping(rc, operand,
flags ^ INVERT);
}
}
return get_input_source(rc, source) |
get_input_mapping(rc, operand, flags);
}
/* Bind the RC input variable <var> to the EXT_texture_env_combine
* argument <arg>, possibly inverted or biased. */
#define INPUT_ARG(rc, var, arg, flags) \
(rc)->in |= get_input_arg(rc, arg, flags) << RC_IN_SHIFT_##var
/* Bind the RC input variable <var> to the RC source <src>. */
#define INPUT_SRC(rc, var, src, chan) \
(rc)->in |= (RC_IN_SOURCE(src) | \
RC_IN_USAGE(chan)) << RC_IN_SHIFT_##var
/* Bind the RC input variable <var> to a constant +/-1 */
#define INPUT_ONE(rc, var, flags) \
(rc)->in |= (RC_IN_SOURCE(ZERO) | \
(flags & INVERT ? RC_IN_MAPPING(EXPAND_NORMAL) : \
RC_IN_MAPPING(UNSIGNED_INVERT))) << RC_IN_SHIFT_##var
static void
setup_combiner(struct combiner_state *rc)
{
switch (rc->mode) {
case GL_REPLACE:
INPUT_ARG(rc, A, 0, 0);
INPUT_ONE(rc, B, 0);
rc->out = RC_OUT_AB;
break;
case GL_MODULATE:
INPUT_ARG(rc, A, 0, 0);
INPUT_ARG(rc, B, 1, 0);
rc->out = RC_OUT_AB;
break;
case GL_ADD:
case GL_ADD_SIGNED:
if (rc->premodulate) {
INPUT_ARG(rc, A, 0, 0);
INPUT_ARG(rc, B, 1, 0);
INPUT_ARG(rc, C, 2, 0);
INPUT_ARG(rc, D, 3, 0);
} else {
INPUT_ARG(rc, A, 0, 0);
INPUT_ONE(rc, B, 0);
INPUT_ARG(rc, C, 1, 0);
INPUT_ONE(rc, D, 0);
}
rc->out = RC_OUT_SUM |
(rc->mode == GL_ADD_SIGNED ? RC_OUT_BIAS : 0);
break;
case GL_INTERPOLATE:
INPUT_ARG(rc, A, 0, 0);
INPUT_ARG(rc, B, 2, 0);
INPUT_ARG(rc, C, 1, 0);
INPUT_ARG(rc, D, 2, INVERT);
rc->out = RC_OUT_SUM;
break;
case GL_SUBTRACT:
INPUT_ARG(rc, A, 0, 0);
INPUT_ONE(rc, B, 0);
INPUT_ARG(rc, C, 1, 0);
INPUT_ONE(rc, D, INVERT);
rc->out = RC_OUT_SUM;
break;
case GL_DOT3_RGB:
case GL_DOT3_RGBA:
INPUT_ARG(rc, A, 0, NORMALIZE);
INPUT_ARG(rc, B, 1, NORMALIZE);
rc->out = RC_OUT_DOT_AB;
break;
case GL_DOT3_RGB_EXT:
case GL_DOT3_RGBA_EXT:
INPUT_ARG(rc, A, 0, NORMALIZE);
INPUT_ARG(rc, B, 1, NORMALIZE);
rc->out = RC_OUT_DOT_AB;
/* The EXT version of the DOT3 extension does not support the
* scale factor, but the ARB version (and the version in
* OpenGL 1.3) does.
*/
rc->logscale = 0;
break;
default:
assert(0);
}
switch (rc->logscale) {
case 0:
rc->out |= RC_OUT_SCALE_1;
break;
case 1:
rc->out |= RC_OUT_SCALE_2;
break;
case 2:
rc->out |= RC_OUT_SCALE_4;
break;
default:
assert(0);
}
}
void
nv10_get_general_combiner(struct gl_context *ctx, int i,
uint32_t *a_in, uint32_t *a_out,
uint32_t *c_in, uint32_t *c_out, uint32_t *k)
{
struct combiner_state rc_a, rc_c;
if (ctx->Texture.Unit[i]._Current) {
INIT_COMBINER(RGB, ctx, &rc_c, i);
if (rc_c.mode == GL_DOT3_RGBA || rc_c.mode == GL_DOT3_RGBA_EXT)
rc_a = rc_c;
else
INIT_COMBINER(A, ctx, &rc_a, i);
setup_combiner(&rc_c);
setup_combiner(&rc_a);
} else {
rc_a.in = rc_a.out = rc_c.in = rc_c.out = 0;
}
*k = pack_rgba_f(MESA_FORMAT_B8G8R8A8_UNORM,
ctx->Texture.FixedFuncUnit[i].EnvColor);
*a_in = rc_a.in;
*a_out = rc_a.out;
*c_in = rc_c.in;
*c_out = rc_c.out;
}
void
nv10_get_final_combiner(struct gl_context *ctx, uint64_t *in, int *n)
{
struct combiner_state rc = {};
/*
* The final fragment value equation is something like:
* x_i = A_i * B_i + (1 - A_i) * C_i + D_i
* x_alpha = G_alpha
* where D_i = E_i * F_i, i one of {red, green, blue}.
*/
if (ctx->Fog.ColorSumEnabled || ctx->Light.Enabled) {
INPUT_SRC(&rc, D, E_TIMES_F, RGB);
INPUT_SRC(&rc, F, SECONDARY_COLOR, RGB);
}
if (ctx->Fog.Enabled) {
INPUT_SRC(&rc, A, FOG, ALPHA);
INPUT_SRC(&rc, C, FOG, RGB);
INPUT_SRC(&rc, E, FOG, ALPHA);
} else {
INPUT_ONE(&rc, A, 0);
INPUT_ONE(&rc, C, 0);
INPUT_ONE(&rc, E, 0);
}
if (ctx->Texture._MaxEnabledTexImageUnit != -1) {
INPUT_SRC(&rc, B, SPARE0, RGB);
INPUT_SRC(&rc, G, SPARE0, ALPHA);
} else {
INPUT_SRC(&rc, B, PRIMARY_COLOR, RGB);
INPUT_SRC(&rc, G, PRIMARY_COLOR, ALPHA);
}
*in = rc.in;
*n = ctx->Texture._MaxEnabledTexImageUnit + 1;
}
void
nv10_emit_tex_env(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_TEX_ENV0;
struct nouveau_pushbuf *push = context_push(ctx);
uint32_t a_in, a_out, c_in, c_out, k;
nv10_get_general_combiner(ctx, i, &a_in, &a_out, &c_in, &c_out, &k);
/* Enable the combiners we're going to need. */
if (i == 1) {
if (c_out || a_out)
c_out |= 0x5 << 27;
else
c_out |= 0x3 << 27;
}
BEGIN_NV04(push, NV10_3D(RC_IN_ALPHA(i)), 1);
PUSH_DATA (push, a_in);
BEGIN_NV04(push, NV10_3D(RC_IN_RGB(i)), 1);
PUSH_DATA (push, c_in);
BEGIN_NV04(push, NV10_3D(RC_COLOR(i)), 1);
PUSH_DATA (push, k);
BEGIN_NV04(push, NV10_3D(RC_OUT_ALPHA(i)), 1);
PUSH_DATA (push, a_out);
BEGIN_NV04(push, NV10_3D(RC_OUT_RGB(i)), 1);
PUSH_DATA (push, c_out);
context_dirty(ctx, FRAG);
}
void
nv10_emit_frag(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
uint64_t in;
int n;
nv10_get_final_combiner(ctx, &in, &n);
BEGIN_NV04(push, NV10_3D(RC_FINAL0), 2);
PUSH_DATA (push, in);
PUSH_DATA (push, in >> 32);
}

View File

@ -1,121 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_gldefs.h"
#include "nouveau_util.h"
#include "nv10_3d.xml.h"
#include "nv10_driver.h"
void
nv10_emit_cull_face(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
GLenum mode = ctx->Polygon.CullFaceMode;
BEGIN_NV04(push, NV10_3D(CULL_FACE_ENABLE), 1);
PUSH_DATAb(push, ctx->Polygon.CullFlag);
BEGIN_NV04(push, NV10_3D(CULL_FACE), 1);
PUSH_DATA (push, (mode == GL_FRONT ? NV10_3D_CULL_FACE_FRONT :
mode == GL_BACK ? NV10_3D_CULL_FACE_BACK :
NV10_3D_CULL_FACE_FRONT_AND_BACK));
}
void
nv10_emit_front_face(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(FRONT_FACE), 1);
PUSH_DATA (push, ctx->Polygon.FrontFace == GL_CW ?
NV10_3D_FRONT_FACE_CW : NV10_3D_FRONT_FACE_CCW);
}
void
nv10_emit_line_mode(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
GLboolean smooth = ctx->Line.SmoothFlag &&
ctx->Hint.LineSmooth == GL_NICEST;
BEGIN_NV04(push, NV10_3D(LINE_WIDTH), 1);
PUSH_DATA (push, MAX2(smooth ? 0 : 1,
ctx->Line.Width) * 8);
BEGIN_NV04(push, NV10_3D(LINE_SMOOTH_ENABLE), 1);
PUSH_DATAb(push, smooth);
}
void
nv10_emit_line_stipple(struct gl_context *ctx, int emit)
{
}
void
nv10_emit_point_mode(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(POINT_SIZE), 1);
PUSH_DATA (push, (uint32_t)(ctx->Point.Size * 8));
BEGIN_NV04(push, NV10_3D(POINT_SMOOTH_ENABLE), 1);
PUSH_DATAb(push, ctx->Point.SmoothFlag);
}
void
nv10_emit_polygon_mode(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(POLYGON_MODE_FRONT), 2);
PUSH_DATA (push, nvgl_polygon_mode(ctx->Polygon.FrontMode));
PUSH_DATA (push, nvgl_polygon_mode(ctx->Polygon.BackMode));
BEGIN_NV04(push, NV10_3D(POLYGON_SMOOTH_ENABLE), 1);
PUSH_DATAb(push, ctx->Polygon.SmoothFlag);
}
void
nv10_emit_polygon_offset(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(POLYGON_OFFSET_POINT_ENABLE), 3);
PUSH_DATAb(push, ctx->Polygon.OffsetPoint);
PUSH_DATAb(push, ctx->Polygon.OffsetLine);
PUSH_DATAb(push, ctx->Polygon.OffsetFill);
BEGIN_NV04(push, NV10_3D(POLYGON_OFFSET_FACTOR), 2);
PUSH_DATAf(push, ctx->Polygon.OffsetFactor);
PUSH_DATAf(push, ctx->Polygon.OffsetUnits);
}
void
nv10_emit_polygon_stipple(struct gl_context *ctx, int emit)
{
}

View File

@ -1,174 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_gldefs.h"
#include "nouveau_util.h"
#include "nv_object.xml.h"
#include "nv10_3d.xml.h"
#include "nv10_driver.h"
#include "main/stencil.h"
void
nv10_emit_alpha_func(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_ENABLE), 1);
PUSH_DATAb(push, ctx->Color.AlphaEnabled);
BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_FUNC), 2);
PUSH_DATA (push, nvgl_comparison_op(ctx->Color.AlphaFunc));
PUSH_DATA (push, FLOAT_TO_UBYTE(ctx->Color.AlphaRef));
}
void
nv10_emit_blend_color(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(BLEND_COLOR), 1);
PUSH_DATA (push, FLOAT_TO_UBYTE(ctx->Color.BlendColor[3]) << 24 |
FLOAT_TO_UBYTE(ctx->Color.BlendColor[0]) << 16 |
FLOAT_TO_UBYTE(ctx->Color.BlendColor[1]) << 8 |
FLOAT_TO_UBYTE(ctx->Color.BlendColor[2]) << 0);
}
void
nv10_emit_blend_equation(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(BLEND_FUNC_ENABLE), 1);
PUSH_DATAb(push, ctx->Color.BlendEnabled);
BEGIN_NV04(push, NV10_3D(BLEND_EQUATION), 1);
PUSH_DATA (push, nvgl_blend_eqn(ctx->Color.Blend[0].EquationRGB));
}
void
nv10_emit_blend_func(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(BLEND_FUNC_SRC), 2);
PUSH_DATA (push, nvgl_blend_func(ctx->Color.Blend[0].SrcRGB));
PUSH_DATA (push, nvgl_blend_func(ctx->Color.Blend[0].DstRGB));
}
void
nv10_emit_color_mask(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(COLOR_MASK), 1);
PUSH_DATA (push, ((GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3) ? 1 << 24 : 0) |
(GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0) ? 1 << 16 : 0) |
(GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1) ? 1 << 8 : 0) |
(GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2) ? 1 << 0 : 0)));
}
void
nv10_emit_depth(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
BEGIN_NV04(push, NV10_3D(DEPTH_TEST_ENABLE), 1);
PUSH_DATAb(push, ctx->Depth.Test && fb->Visual.depthBits > 0);
BEGIN_NV04(push, NV10_3D(DEPTH_WRITE_ENABLE), 1);
PUSH_DATAb(push, ctx->Depth.Mask && fb->Visual.depthBits > 0);
BEGIN_NV04(push, NV10_3D(DEPTH_FUNC), 1);
PUSH_DATA (push, nvgl_comparison_op(ctx->Depth.Func));
}
void
nv10_emit_dither(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(DITHER_ENABLE), 1);
PUSH_DATAb(push, ctx->Color.DitherFlag);
}
void
nv10_emit_logic_opcode(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
assert(!ctx->Color.ColorLogicOpEnabled
|| context_eng3d(ctx)->oclass >= NV15_3D_CLASS);
BEGIN_NV04(push, NV11_3D(COLOR_LOGIC_OP_ENABLE), 2);
PUSH_DATAb(push, ctx->Color.ColorLogicOpEnabled);
PUSH_DATA (push, ctx->Color.LogicOp);
}
void
nv10_emit_shade_model(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(SHADE_MODEL), 1);
PUSH_DATA (push, ctx->Light.ShadeModel == GL_SMOOTH ?
NV10_3D_SHADE_MODEL_SMOOTH : NV10_3D_SHADE_MODEL_FLAT);
}
void
nv10_emit_stencil_func(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(STENCIL_ENABLE), 1);
PUSH_DATAb(push, _mesa_stencil_is_enabled(ctx));
BEGIN_NV04(push, NV10_3D(STENCIL_FUNC_FUNC), 3);
PUSH_DATA (push, nvgl_comparison_op(ctx->Stencil.Function[0]));
PUSH_DATA (push, _mesa_get_stencil_ref(ctx, 0));
PUSH_DATA (push, ctx->Stencil.ValueMask[0]);
}
void
nv10_emit_stencil_mask(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(STENCIL_MASK), 1);
PUSH_DATA (push, ctx->Stencil.WriteMask[0]);
}
void
nv10_emit_stencil_op(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(STENCIL_OP_FAIL), 3);
PUSH_DATA (push, nvgl_stencil_op(ctx->Stencil.FailFunc[0]));
PUSH_DATA (push, nvgl_stencil_op(ctx->Stencil.ZFailFunc[0]));
PUSH_DATA (push, nvgl_stencil_op(ctx->Stencil.ZPassFunc[0]));
}

View File

@ -1,241 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_gldefs.h"
#include "nouveau_texture.h"
#include "nv10_3d.xml.h"
#include "nouveau_util.h"
#include "nv10_driver.h"
#include "main/samplerobj.h"
void
nv10_emit_tex_gen(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_TEX_GEN0;
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_fixedfunc_texture_unit *unit =
&ctx->Texture.FixedFuncUnit[i];
int j;
for (j = 0; j < 4; j++) {
if (nctx->fallback == HWTNL && (unit->TexGenEnabled & 1 << j)) {
struct gl_texgen *coord = get_texgen_coord(unit, j);
float *k = get_texgen_coeff(unit, coord->Mode, j);
if (k) {
BEGIN_NV04(push, NV10_3D(TEX_GEN_COEFF(i, j)), 4);
PUSH_DATAp(push, k, 4);
}
BEGIN_NV04(push, NV10_3D(TEX_GEN_MODE(i,j)), 1);
PUSH_DATA (push, nvgl_texgen_mode(coord->Mode));
} else {
BEGIN_NV04(push, NV10_3D(TEX_GEN_MODE(i,j)), 1);
PUSH_DATA (push, 0);
}
}
context_dirty_i(ctx, TEX_MAT, i);
}
void
nv10_emit_tex_mat(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_TEX_MAT0;
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
if (nctx->fallback == HWTNL &&
((ctx->Texture._TexMatEnabled & 1 << i) ||
ctx->Texture.FixedFuncUnit[i]._GenFlags)) {
BEGIN_NV04(push, NV10_3D(TEX_MATRIX_ENABLE(i)), 1);
PUSH_DATA (push, 1);
BEGIN_NV04(push, NV10_3D(TEX_MATRIX(i, 0)), 16);
PUSH_DATAm(push, ctx->TextureMatrixStack[i].Top->m);
} else {
BEGIN_NV04(push, NV10_3D(TEX_MATRIX_ENABLE(i)), 1);
PUSH_DATA (push, 0);
}
}
static uint32_t
get_tex_format_pot(struct gl_texture_image *ti)
{
switch (ti->TexFormat) {
case MESA_FORMAT_B8G8R8A8_UNORM:
return NV10_3D_TEX_FORMAT_FORMAT_A8R8G8B8;
case MESA_FORMAT_B8G8R8X8_UNORM:
return NV10_3D_TEX_FORMAT_FORMAT_X8R8G8B8;
case MESA_FORMAT_B5G5R5A1_UNORM:
return NV10_3D_TEX_FORMAT_FORMAT_A1R5G5B5;
case MESA_FORMAT_B4G4R4A4_UNORM:
return NV10_3D_TEX_FORMAT_FORMAT_A4R4G4B4;
case MESA_FORMAT_B5G6R5_UNORM:
return NV10_3D_TEX_FORMAT_FORMAT_R5G6B5;
case MESA_FORMAT_A_UNORM8:
case MESA_FORMAT_I_UNORM8:
return NV10_3D_TEX_FORMAT_FORMAT_I8;
case MESA_FORMAT_L_UNORM8:
return NV10_3D_TEX_FORMAT_FORMAT_L8;
case MESA_FORMAT_RGB_DXT1:
case MESA_FORMAT_RGBA_DXT1:
return NV10_3D_TEX_FORMAT_FORMAT_DXT1;
case MESA_FORMAT_RGBA_DXT3:
return NV10_3D_TEX_FORMAT_FORMAT_DXT3;
case MESA_FORMAT_RGBA_DXT5:
return NV10_3D_TEX_FORMAT_FORMAT_DXT5;
default:
assert(0);
}
}
static uint32_t
get_tex_format_rect(struct gl_texture_image *ti)
{
switch (ti->TexFormat) {
case MESA_FORMAT_B5G5R5A1_UNORM:
return NV10_3D_TEX_FORMAT_FORMAT_A1R5G5B5_RECT;
case MESA_FORMAT_B5G6R5_UNORM:
return NV10_3D_TEX_FORMAT_FORMAT_R5G6B5_RECT;
case MESA_FORMAT_B8G8R8A8_UNORM:
case MESA_FORMAT_B8G8R8X8_UNORM:
return NV10_3D_TEX_FORMAT_FORMAT_A8R8G8B8_RECT;
case MESA_FORMAT_A_UNORM8:
case MESA_FORMAT_L_UNORM8:
case MESA_FORMAT_I_UNORM8:
return NV10_3D_TEX_FORMAT_FORMAT_I8_RECT;
default:
assert(0);
}
}
void
nv10_emit_tex_obj(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_TEX_OBJ0;
struct nouveau_pushbuf *push = context_push(ctx);
const int bo_flags = NOUVEAU_BO_RD | NOUVEAU_BO_GART | NOUVEAU_BO_VRAM;
struct gl_texture_object *t;
struct nouveau_surface *s;
struct gl_texture_image *ti;
const struct gl_sampler_object *sa;
uint32_t tx_format, tx_filter, tx_enable;
PUSH_RESET(push, BUFCTX_TEX(i));
if (!ctx->Texture.Unit[i]._Current) {
BEGIN_NV04(push, NV10_3D(TEX_ENABLE(i)), 1);
PUSH_DATA (push, 0);
return;
}
t = ctx->Texture.Unit[i]._Current;
s = &to_nouveau_texture(t)->surfaces[t->Attrib.BaseLevel];
ti = t->Image[0][t->Attrib.BaseLevel];
sa = _mesa_get_samplerobj(ctx, i);
if (!nouveau_texture_validate(ctx, t))
return;
/* Recompute the texturing registers. */
tx_format = nvgl_wrap_mode(sa->Attrib.WrapT) << 28
| nvgl_wrap_mode(sa->Attrib.WrapS) << 24
| ti->HeightLog2 << 20
| ti->WidthLog2 << 16
| 5 << 4 | 1 << 12;
tx_filter = nvgl_filter_mode(sa->Attrib.MagFilter) << 28
| nvgl_filter_mode(sa->Attrib.MinFilter) << 24;
tx_enable = NV10_3D_TEX_ENABLE_ENABLE
| log2i(sa->Attrib.MaxAnisotropy) << 4;
if (t->Target == GL_TEXTURE_RECTANGLE) {
BEGIN_NV04(push, NV10_3D(TEX_NPOT_PITCH(i)), 1);
PUSH_DATA (push, s->pitch << 16);
BEGIN_NV04(push, NV10_3D(TEX_NPOT_SIZE(i)), 1);
PUSH_DATA (push, align(s->width, 2) << 16 | s->height);
tx_format |= get_tex_format_rect(ti);
} else {
tx_format |= get_tex_format_pot(ti);
}
if (sa->Attrib.MinFilter != GL_NEAREST &&
sa->Attrib.MinFilter != GL_LINEAR) {
int lod_min = sa->Attrib.MinLod;
int lod_max = MIN2(sa->Attrib.MaxLod, t->_MaxLambda);
int lod_bias = sa->Attrib.LodBias
+ ctx->Texture.Unit[i].LodBias;
lod_max = CLAMP(lod_max, 0, 15);
lod_min = CLAMP(lod_min, 0, 15);
lod_bias = CLAMP(lod_bias, 0, 15);
tx_format |= NV10_3D_TEX_FORMAT_MIPMAP;
tx_filter |= lod_bias << 8;
tx_enable |= lod_min << 26
| lod_max << 14;
}
/* Write it to the hardware. */
BEGIN_NV04(push, NV10_3D(TEX_FORMAT(i)), 1);
PUSH_MTHD (push, NV10_3D(TEX_FORMAT(i)), BUFCTX_TEX(i),
s->bo, tx_format, bo_flags | NOUVEAU_BO_OR,
NV10_3D_TEX_FORMAT_DMA0,
NV10_3D_TEX_FORMAT_DMA1);
BEGIN_NV04(push, NV10_3D(TEX_OFFSET(i)), 1);
PUSH_MTHDl(push, NV10_3D(TEX_OFFSET(i)), BUFCTX_TEX(i),
s->bo, s->offset, bo_flags);
BEGIN_NV04(push, NV10_3D(TEX_FILTER(i)), 1);
PUSH_DATA (push, tx_filter);
BEGIN_NV04(push, NV10_3D(TEX_ENABLE(i)), 1);
PUSH_DATA (push, tx_enable);
}

View File

@ -1,497 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_gldefs.h"
#include "nouveau_util.h"
#include "nv10_3d.xml.h"
#include "nv10_driver.h"
#include "util/bitscan.h"
void
nv10_emit_clip_plane(struct gl_context *ctx, int emit)
{
}
static inline unsigned
get_material_bitmask(unsigned m)
{
unsigned ret = 0;
if (m & MAT_BIT_FRONT_EMISSION)
ret |= NV10_3D_COLOR_MATERIAL_EMISSION;
if (m & MAT_BIT_FRONT_AMBIENT)
ret |= NV10_3D_COLOR_MATERIAL_AMBIENT;
if (m & MAT_BIT_FRONT_DIFFUSE)
ret |= NV10_3D_COLOR_MATERIAL_DIFFUSE;
if (m & MAT_BIT_FRONT_SPECULAR)
ret |= NV10_3D_COLOR_MATERIAL_SPECULAR;
return ret;
}
void
nv10_emit_color_material(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
unsigned mask = get_material_bitmask(ctx->Light._ColorMaterialBitmask);
BEGIN_NV04(push, NV10_3D(COLOR_MATERIAL), 1);
PUSH_DATA (push, ctx->Light.ColorMaterialEnabled ? mask : 0);
}
static unsigned
get_fog_mode(unsigned mode)
{
switch (mode) {
case GL_LINEAR:
return NV10_3D_FOG_MODE_LINEAR;
case GL_EXP:
return NV10_3D_FOG_MODE_EXP;
case GL_EXP2:
return NV10_3D_FOG_MODE_EXP2;
default:
assert(0);
}
}
static unsigned
get_fog_source(unsigned source, unsigned distance_mode)
{
switch (source) {
case GL_FOG_COORDINATE_EXT:
return NV10_3D_FOG_COORD_FOG;
case GL_FRAGMENT_DEPTH_EXT:
switch (distance_mode) {
case GL_EYE_PLANE_ABSOLUTE_NV:
return NV10_3D_FOG_COORD_DIST_ORTHOGONAL_ABS;
case GL_EYE_PLANE:
return NV10_3D_FOG_COORD_DIST_ORTHOGONAL;
case GL_EYE_RADIAL_NV:
return NV10_3D_FOG_COORD_DIST_RADIAL;
default:
assert(0);
}
default:
assert(0);
}
}
void
nv10_get_fog_coeff(struct gl_context *ctx, float k[3])
{
struct gl_fog_attrib *f = &ctx->Fog;
switch (f->Mode) {
case GL_LINEAR:
k[0] = 2 + f->Start / (f->End - f->Start);
k[1] = -1 / (f->End - f->Start);
break;
case GL_EXP:
k[0] = 1.5;
k[1] = -0.09 * f->Density;
break;
case GL_EXP2:
k[0] = 1.5;
k[1] = -0.21 * f->Density;
break;
default:
assert(0);
}
k[2] = 0;
}
void
nv10_emit_fog(struct gl_context *ctx, int emit)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_fog_attrib *f = &ctx->Fog;
unsigned source = nctx->fallback == HWTNL ?
f->FogCoordinateSource : GL_FOG_COORDINATE_EXT;
float k[3];
nv10_get_fog_coeff(ctx, k);
BEGIN_NV04(push, NV10_3D(FOG_MODE), 4);
PUSH_DATA (push, get_fog_mode(f->Mode));
PUSH_DATA (push, get_fog_source(source, f->FogDistanceMode));
PUSH_DATAb(push, f->Enabled);
PUSH_DATA (push, pack_rgba_f(MESA_FORMAT_R8G8B8A8_UNORM, f->Color));
BEGIN_NV04(push, NV10_3D(FOG_COEFF(0)), 3);
PUSH_DATAp(push, k, 3);
context_dirty(ctx, FRAG);
}
static inline unsigned
get_light_mode(struct gl_light *l)
{
if (l->Enabled) {
if (l->_Flags & LIGHT_SPOT)
return NV10_3D_ENABLED_LIGHTS_0_DIRECTIONAL;
else if (l->_Flags & LIGHT_POSITIONAL)
return NV10_3D_ENABLED_LIGHTS_0_POSITIONAL;
else
return NV10_3D_ENABLED_LIGHTS_0_NONPOSITIONAL;
} else {
return NV10_3D_ENABLED_LIGHTS_0_DISABLED;
}
}
void
nv10_emit_light_enable(struct gl_context *ctx, int emit)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
uint32_t en_lights = 0;
int i;
if (nctx->fallback != HWTNL) {
BEGIN_NV04(push, NV10_3D(LIGHTING_ENABLE), 1);
PUSH_DATA (push, 0);
return;
}
for (i = 0; i < MAX_LIGHTS; i++)
en_lights |= get_light_mode(&ctx->Light.Light[i]) << 2 * i;
BEGIN_NV04(push, NV10_3D(ENABLED_LIGHTS), 1);
PUSH_DATA (push, en_lights);
BEGIN_NV04(push, NV10_3D(LIGHTING_ENABLE), 1);
PUSH_DATAb(push, ctx->Light.Enabled);
BEGIN_NV04(push, NV10_3D(NORMALIZE_ENABLE), 1);
PUSH_DATAb(push, ctx->Transform.Normalize);
}
void
nv10_emit_light_model(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_lightmodel *m = &ctx->Light.Model;
BEGIN_NV04(push, NV10_3D(SEPARATE_SPECULAR_ENABLE), 1);
PUSH_DATAb(push, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR);
BEGIN_NV04(push, NV10_3D(LIGHT_MODEL), 1);
PUSH_DATA (push, ((m->LocalViewer ?
NV10_3D_LIGHT_MODEL_LOCAL_VIEWER : 0) |
(_mesa_need_secondary_color(ctx) ?
NV10_3D_LIGHT_MODEL_SEPARATE_SPECULAR : 0) |
(!ctx->Light.Enabled && ctx->Fog.ColorSumEnabled ?
NV10_3D_LIGHT_MODEL_VERTEX_SPECULAR : 0)));
}
static float
get_shine(const float p[], float x)
{
const int n = 15;
const float *y = &p[1];
float f = (n - 1) * (1 - 1 / (1 + p[0] * x))
/ (1 - 1 / (1 + p[0] * 1024));
int i = f;
/* Linear interpolation in f-space (Faster and somewhat more
* accurate than x-space). */
if (x == 0)
return y[0];
else if (i > n - 2)
return y[n - 1];
else
return y[i] + (y[i + 1] - y[i]) * (f - i);
}
static const float nv10_spot_params[2][16] = {
{ 0.02, -3.80e-05, -1.77, -2.41, -2.71, -2.88, -2.98, -3.06,
-3.11, -3.17, -3.23, -3.28, -3.37, -3.47, -3.83, -5.11 },
{ 0.02, -0.01, 1.77, 2.39, 2.70, 2.87, 2.98, 3.06,
3.10, 3.16, 3.23, 3.27, 3.37, 3.47, 3.83, 5.11 },
};
void
nv10_get_spot_coeff(struct gl_light *l, struct gl_light_uniforms *lu, float k[7])
{
float e = lu->SpotExponent;
float a0, b0, a1, a2, b2, a3;
if (e > 0)
a0 = -1 - 5.36e-3 / sqrtf(e);
else
a0 = -1;
b0 = 1 / (1 + 0.273 * e);
a1 = get_shine(nv10_spot_params[0], e);
a2 = get_shine(nv10_spot_params[1], e);
b2 = 1 / (1 + 0.273 * e);
a3 = 0.9 + 0.278 * e;
if (lu->SpotCutoff > 0) {
float cutoff = MAX2(a3, 1 / (1 - lu->_CosCutoff));
k[0] = MAX2(0, a0 + b0 * cutoff);
k[1] = a1;
k[2] = a2 + b2 * cutoff;
k[3] = - cutoff * l->_NormSpotDirection[0];
k[4] = - cutoff * l->_NormSpotDirection[1];
k[5] = - cutoff * l->_NormSpotDirection[2];
k[6] = 1 - cutoff;
} else {
k[0] = b0;
k[1] = a1;
k[2] = a2 + b2;
k[3] = - l->_NormSpotDirection[0];
k[4] = - l->_NormSpotDirection[1];
k[5] = - l->_NormSpotDirection[2];
k[6] = -1;
}
}
void
nv10_emit_light_source(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_LIGHT_SOURCE0;
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_light *l = &ctx->Light.Light[i];
struct gl_light_uniforms *lu = &ctx->Light.LightSource[i];
if (l->_Flags & LIGHT_POSITIONAL) {
BEGIN_NV04(push, NV10_3D(LIGHT_POSITION_X(i)), 3);
PUSH_DATAp(push, l->_Position, 3);
BEGIN_NV04(push, NV10_3D(LIGHT_ATTENUATION_CONSTANT(i)), 3);
PUSH_DATAf(push, lu->ConstantAttenuation);
PUSH_DATAf(push, lu->LinearAttenuation);
PUSH_DATAf(push, lu->QuadraticAttenuation);
} else {
BEGIN_NV04(push, NV10_3D(LIGHT_DIRECTION_X(i)), 3);
PUSH_DATAp(push, l->_VP_inf_norm, 3);
BEGIN_NV04(push, NV10_3D(LIGHT_HALF_VECTOR_X(i)), 3);
PUSH_DATAp(push, l->_h_inf_norm, 3);
}
if (l->_Flags & LIGHT_SPOT) {
float k[7];
nv10_get_spot_coeff(l, lu, k);
BEGIN_NV04(push, NV10_3D(LIGHT_SPOT_CUTOFF(i, 0)), 7);
PUSH_DATAp(push, k, 7);
}
}
#define USE_COLOR_MATERIAL(attr) \
(ctx->Light.ColorMaterialEnabled && \
ctx->Light._ColorMaterialBitmask & (1 << MAT_ATTRIB_FRONT_##attr))
void
nv10_emit_material_ambient(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
float (*mat)[4] = ctx->Light.Material.Attrib;
float c_scene[3], c_factor[3];
GLbitfield mask;
if (USE_COLOR_MATERIAL(AMBIENT)) {
COPY_3V(c_scene, ctx->Light.Model.Ambient);
COPY_3V(c_factor, mat[MAT_ATTRIB_FRONT_EMISSION]);
} else if (USE_COLOR_MATERIAL(EMISSION)) {
SCALE_3V(c_scene, mat[MAT_ATTRIB_FRONT_AMBIENT],
ctx->Light.Model.Ambient);
ZERO_3V(c_factor);
} else {
COPY_3V(c_scene, ctx->Light._BaseColor[0]);
ZERO_3V(c_factor);
}
BEGIN_NV04(push, NV10_3D(LIGHT_MODEL_AMBIENT_R), 3);
PUSH_DATAp(push, c_scene, 3);
if (ctx->Light.ColorMaterialEnabled) {
BEGIN_NV04(push, NV10_3D(MATERIAL_FACTOR_R), 3);
PUSH_DATAp(push, c_factor, 3);
}
mask = ctx->Light._EnabledLights;
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *l = &ctx->Light.Light[i];
struct gl_light_uniforms *lu = &ctx->Light.LightSource[i];
float *c_light = (USE_COLOR_MATERIAL(AMBIENT) ?
lu->Ambient :
l->_MatAmbient[0]);
BEGIN_NV04(push, NV10_3D(LIGHT_AMBIENT_R(i)), 3);
PUSH_DATAp(push, c_light, 3);
}
}
void
nv10_emit_material_diffuse(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
GLbitfield mask;
BEGIN_NV04(push, NV10_3D(MATERIAL_FACTOR_A), 1);
PUSH_DATAf(push, mat[MAT_ATTRIB_FRONT_DIFFUSE][3]);
mask = ctx->Light._EnabledLights;
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *l = &ctx->Light.Light[i];
struct gl_light_uniforms *lu = &ctx->Light.LightSource[i];
float *c_light = (USE_COLOR_MATERIAL(DIFFUSE) ?
lu->Diffuse :
l->_MatDiffuse[0]);
BEGIN_NV04(push, NV10_3D(LIGHT_DIFFUSE_R(i)), 3);
PUSH_DATAp(push, c_light, 3);
}
}
void
nv10_emit_material_specular(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
GLbitfield mask;
mask = ctx->Light._EnabledLights;
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *l = &ctx->Light.Light[i];
struct gl_light_uniforms *lu = &ctx->Light.LightSource[i];
float *c_light = (USE_COLOR_MATERIAL(SPECULAR) ?
lu->Specular :
l->_MatSpecular[0]);
BEGIN_NV04(push, NV10_3D(LIGHT_SPECULAR_R(i)), 3);
PUSH_DATAp(push, c_light, 3);
}
}
static const float nv10_shininess_param[6][16] = {
{ 0.70, 0.00, 0.06, 0.06, 0.05, 0.04, 0.02, 0.00,
-0.06, -0.13, -0.24, -0.36, -0.51, -0.66, -0.82, -1.00 },
{ 0.01, 1.00, -2.29, -2.77, -2.96, -3.06, -3.12, -3.18,
-3.24, -3.29, -3.36, -3.43, -3.51, -3.75, -4.33, -5.11 },
{ 0.02, 0.00, 2.28, 2.75, 2.94, 3.04, 3.1, 3.15,
3.18, 3.22, 3.27, 3.32, 3.39, 3.48, 3.84, 5.11 },
{ 0.70, 0.00, 0.05, 0.06, 0.06, 0.06, 0.05, 0.04,
0.02, 0.01, -0.03, -0.12, -0.25, -0.43, -0.68, -0.99 },
{ 0.01, 1.00, -1.61, -2.35, -2.67, -2.84, -2.96, -3.05,
-3.08, -3.14, -3.2, -3.26, -3.32, -3.42, -3.54, -4.21 },
{ 0.01, 0.00, 2.25, 2.73, 2.92, 3.03, 3.09, 3.15,
3.16, 3.21, 3.25, 3.29, 3.35, 3.43, 3.56, 4.22 },
};
void
nv10_get_shininess_coeff(float s, float k[6])
{
int i;
for (i = 0; i < 6; i++)
k[i] = get_shine(nv10_shininess_param[i], s);
}
void
nv10_emit_material_shininess(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
float (*mat)[4] = ctx->Light.Material.Attrib;
float k[6];
nv10_get_shininess_coeff(
CLAMP(mat[MAT_ATTRIB_FRONT_SHININESS][0], 0, 1024),
k);
BEGIN_NV04(push, NV10_3D(MATERIAL_SHININESS(0)), 6);
PUSH_DATAp(push, k, 6);
}
void
nv10_emit_modelview(struct gl_context *ctx, int emit)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
GLmatrix *m = ctx->ModelviewMatrixStack.Top;
if (nctx->fallback != HWTNL)
return;
if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled ||
(ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) {
BEGIN_NV04(push, NV10_3D(MODELVIEW_MATRIX(0, 0)), 16);
PUSH_DATAm(push, m->m);
}
if (ctx->Light.Enabled ||
(ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) {
int i, j;
BEGIN_NV04(push, NV10_3D(INVERSE_MODELVIEW_MATRIX(0, 0)), 12);
for (i = 0; i < 3; i++)
for (j = 0; j < 4; j++)
PUSH_DATAf(push, m->inv[4*i + j]);
}
}
void
nv10_emit_point_parameter(struct gl_context *ctx, int emit)
{
}
void
nv10_emit_projection(struct gl_context *ctx, int emit)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
GLmatrix m;
_math_matrix_ctr(&m);
get_viewport_scale(ctx, m.m);
if (nv10_use_viewport_zclear(ctx))
m.m[MAT_SZ] /= 8;
if (nctx->fallback == HWTNL)
_math_matrix_mul_matrix(&m, &m, &ctx->_ModelProjectMatrix);
BEGIN_NV04(push, NV10_3D(PROJECTION_MATRIX(0)), 16);
PUSH_DATAm(push, m.m);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,583 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <stdbool.h>
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_fbo.h"
#include "nouveau_util.h"
#include "nv_object.xml.h"
#include "nv20_3d.xml.h"
#include "nv04_driver.h"
#include "nv10_driver.h"
#include "nv20_driver.h"
#include "util/u_memory.h"
static void
nv20_clear(struct gl_context *ctx, GLbitfield buffers)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
uint32_t clear = 0;
nouveau_validate_framebuffer(ctx);
nouveau_pushbuf_bufctx(push, nctx->hw.bufctx);
if (nouveau_pushbuf_validate(push)) {
nouveau_pushbuf_bufctx(push, NULL);
return;
}
if (buffers & BUFFER_BITS_COLOR) {
struct nouveau_surface *s = &to_nouveau_renderbuffer(
fb->_ColorDrawBuffers[0])->surface;
if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0))
clear |= NV20_3D_CLEAR_BUFFERS_COLOR_R;
if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1))
clear |= NV20_3D_CLEAR_BUFFERS_COLOR_G;
if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2))
clear |= NV20_3D_CLEAR_BUFFERS_COLOR_B;
if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3))
clear |= NV20_3D_CLEAR_BUFFERS_COLOR_A;
BEGIN_NV04(push, NV20_3D(CLEAR_VALUE), 1);
PUSH_DATA (push, pack_rgba_clamp_f(s->format, ctx->Color.ClearColor.f));
buffers &= ~BUFFER_BITS_COLOR;
}
if (buffers & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) {
struct nouveau_surface *s = &to_nouveau_renderbuffer(
fb->Attachment[BUFFER_DEPTH].Renderbuffer)->surface;
if (buffers & BUFFER_BIT_DEPTH && ctx->Depth.Mask)
clear |= NV20_3D_CLEAR_BUFFERS_DEPTH;
if (buffers & BUFFER_BIT_STENCIL && ctx->Stencil.WriteMask[0])
clear |= NV20_3D_CLEAR_BUFFERS_STENCIL;
BEGIN_NV04(push, NV20_3D(CLEAR_DEPTH_VALUE), 1);
PUSH_DATA (push, pack_zs_f(s->format, ctx->Depth.Clear,
ctx->Stencil.Clear));
buffers &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
}
BEGIN_NV04(push, NV20_3D(CLEAR_BUFFERS), 1);
PUSH_DATA (push, clear);
nouveau_pushbuf_bufctx(push, NULL);
nouveau_clear(ctx, buffers);
}
static void
nv20_hwctx_init(struct gl_context *ctx)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
struct nv04_fifo *fifo = hw->chan->data;
int i;
BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1);
PUSH_DATA (push, hw->eng3d->handle);
BEGIN_NV04(push, NV20_3D(DMA_NOTIFY), 1);
PUSH_DATA (push, hw->ntfy->handle);
BEGIN_NV04(push, NV20_3D(DMA_TEXTURE0), 2);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->gart);
BEGIN_NV04(push, NV20_3D(DMA_COLOR), 2);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->vram);
BEGIN_NV04(push, NV20_3D(DMA_VTXBUF0), 2);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->gart);
BEGIN_NV04(push, NV20_3D(DMA_QUERY), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(RT_HORIZ), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_HORIZ(0)), 1);
PUSH_DATA (push, 0xfff << 16 | 0x0);
BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_VERT(0)), 1);
PUSH_DATA (push, 0xfff << 16 | 0x0);
for (i = 1; i < NV20_3D_VIEWPORT_CLIP_HORIZ__LEN; i++) {
BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_HORIZ(i)), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_VERT(i)), 1);
PUSH_DATA (push, 0);
}
BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_MODE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_3D(0x17e0), 3);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
if (context_chipset(ctx) >= 0x25) {
BEGIN_NV04(push, NV20_3D(TEX_RCOMP), 1);
PUSH_DATA (push, NV20_3D_TEX_RCOMP_LEQUAL | 0xdb0);
} else {
BEGIN_NV04(push, SUBC_3D(0x1e68), 1);
PUSH_DATA (push, 0x4b800000); /* 16777216.000000 */
BEGIN_NV04(push, NV20_3D(TEX_RCOMP), 1);
PUSH_DATA (push, NV20_3D_TEX_RCOMP_LEQUAL);
}
BEGIN_NV04(push, SUBC_3D(0x290), 1);
PUSH_DATA (push, 0x10 << 16 | 1);
BEGIN_NV04(push, SUBC_3D(0x9fc), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_3D(0x1d80), 1);
PUSH_DATA (push, 1);
BEGIN_NV04(push, SUBC_3D(0x9f8), 1);
PUSH_DATA (push, 4);
BEGIN_NV04(push, SUBC_3D(0x17ec), 3);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
if (context_chipset(ctx) >= 0x25) {
BEGIN_NV04(push, SUBC_3D(0x1d88), 1);
PUSH_DATA (push, 3);
BEGIN_NV04(push, NV25_3D(DMA_HIERZ), 1);
PUSH_DATA (push, fifo->vram);
BEGIN_NV04(push, NV25_3D(UNK01AC), 1);
PUSH_DATA (push, fifo->vram);
}
BEGIN_NV04(push, NV20_3D(DMA_FENCE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_3D(0x1e98), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV04_GRAPH(3D, NOTIFY), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_3D(0x120), 3);
PUSH_DATA (push, 0);
PUSH_DATA (push, 1);
PUSH_DATA (push, 2);
if (context_chipset(ctx) >= 0x25) {
BEGIN_NV04(push, SUBC_3D(0x1da4), 1);
PUSH_DATA (push, 0);
}
BEGIN_NV04(push, NV20_3D(RT_HORIZ), 2);
PUSH_DATA (push, 0 << 16 | 0);
PUSH_DATA (push, 0 << 16 | 0);
BEGIN_NV04(push, NV20_3D(ALPHA_FUNC_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(ALPHA_FUNC_FUNC), 2);
PUSH_DATA (push, NV20_3D_ALPHA_FUNC_FUNC_ALWAYS);
PUSH_DATA (push, 0);
for (i = 0; i < NV20_3D_TEX__LEN; i++) {
BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1);
PUSH_DATA (push, 0);
}
BEGIN_NV04(push, NV20_3D(TEX_SHADER_OP), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(TEX_SHADER_CULL_MODE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(RC_IN_ALPHA(0)), 4);
PUSH_DATA (push, 0x30d410d0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(RC_OUT_RGB(0)), 4);
PUSH_DATA (push, 0x00000c00);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(RC_ENABLE), 1);
PUSH_DATA (push, 0x00011101);
BEGIN_NV04(push, NV20_3D(RC_FINAL0), 2);
PUSH_DATA (push, 0x130e0300);
PUSH_DATA (push, 0x0c091c80);
BEGIN_NV04(push, NV20_3D(RC_OUT_ALPHA(0)), 4);
PUSH_DATA (push, 0x00000c00);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(RC_IN_RGB(0)), 4);
PUSH_DATA (push, 0x20c400c0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(RC_COLOR0), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(RC_CONSTANT_COLOR0(0)), 4);
PUSH_DATA (push, 0x035125a0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0x40002000);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(MULTISAMPLE_CONTROL), 1);
PUSH_DATA (push, 0xffff0000);
BEGIN_NV04(push, NV20_3D(BLEND_FUNC_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(DITHER_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(STENCIL_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(BLEND_FUNC_SRC), 4);
PUSH_DATA (push, NV20_3D_BLEND_FUNC_SRC_ONE);
PUSH_DATA (push, NV20_3D_BLEND_FUNC_DST_ZERO);
PUSH_DATA (push, 0);
PUSH_DATA (push, NV20_3D_BLEND_EQUATION_FUNC_ADD);
BEGIN_NV04(push, NV20_3D(STENCIL_MASK), 7);
PUSH_DATA (push, 0xff);
PUSH_DATA (push, NV20_3D_STENCIL_FUNC_FUNC_ALWAYS);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0xff);
PUSH_DATA (push, NV20_3D_STENCIL_OP_FAIL_KEEP);
PUSH_DATA (push, NV20_3D_STENCIL_OP_ZFAIL_KEEP);
PUSH_DATA (push, NV20_3D_STENCIL_OP_ZPASS_KEEP);
BEGIN_NV04(push, NV20_3D(COLOR_LOGIC_OP_ENABLE), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, NV20_3D_COLOR_LOGIC_OP_OP_COPY);
BEGIN_NV04(push, SUBC_3D(0x17cc), 1);
PUSH_DATA (push, 0);
if (context_chipset(ctx) >= 0x25) {
BEGIN_NV04(push, SUBC_3D(0x1d84), 1);
PUSH_DATA (push, 1);
}
BEGIN_NV04(push, NV20_3D(LIGHTING_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(LIGHT_MODEL), 1);
PUSH_DATA (push, NV20_3D_LIGHT_MODEL_VIEWER_NONLOCAL);
BEGIN_NV04(push, NV20_3D(SEPARATE_SPECULAR_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(LIGHT_MODEL_TWO_SIDE_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(ENABLED_LIGHTS), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(NORMALIZE_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(POLYGON_STIPPLE_PATTERN(0)),
NV20_3D_POLYGON_STIPPLE_PATTERN__LEN);
for (i = 0; i < NV20_3D_POLYGON_STIPPLE_PATTERN__LEN; i++) {
PUSH_DATA (push, 0xffffffff);
}
BEGIN_NV04(push, NV20_3D(POLYGON_OFFSET_POINT_ENABLE), 3);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(DEPTH_FUNC), 1);
PUSH_DATA (push, NV20_3D_DEPTH_FUNC_LESS);
BEGIN_NV04(push, NV20_3D(DEPTH_WRITE_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(DEPTH_TEST_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(POLYGON_OFFSET_FACTOR), 2);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
BEGIN_NV04(push, NV20_3D(DEPTH_CLAMP), 1);
PUSH_DATA (push, 1);
if (context_chipset(ctx) < 0x25) {
BEGIN_NV04(push, SUBC_3D(0x1d84), 1);
PUSH_DATA (push, 3);
}
BEGIN_NV04(push, NV20_3D(POINT_SIZE), 1);
if (context_chipset(ctx) >= 0x25)
PUSH_DATAf(push, 1.0);
else
PUSH_DATA (push, 8);
if (context_chipset(ctx) >= 0x25) {
BEGIN_NV04(push, NV20_3D(POINT_PARAMETERS_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_3D(0x0a1c), 1);
PUSH_DATA (push, 0x800);
} else {
BEGIN_NV04(push, NV20_3D(POINT_PARAMETERS_ENABLE), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
}
BEGIN_NV04(push, NV20_3D(LINE_WIDTH), 1);
PUSH_DATA (push, 8);
BEGIN_NV04(push, NV20_3D(LINE_SMOOTH_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(POLYGON_MODE_FRONT), 2);
PUSH_DATA (push, NV20_3D_POLYGON_MODE_FRONT_FILL);
PUSH_DATA (push, NV20_3D_POLYGON_MODE_BACK_FILL);
BEGIN_NV04(push, NV20_3D(CULL_FACE), 2);
PUSH_DATA (push, NV20_3D_CULL_FACE_BACK);
PUSH_DATA (push, NV20_3D_FRONT_FACE_CCW);
BEGIN_NV04(push, NV20_3D(POLYGON_SMOOTH_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(CULL_FACE_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(SHADE_MODEL), 1);
PUSH_DATA (push, NV20_3D_SHADE_MODEL_SMOOTH);
BEGIN_NV04(push, NV20_3D(POLYGON_STIPPLE_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(TEX_GEN_MODE(0,0)),
4 * NV20_3D_TEX_GEN_MODE__ESIZE);
for (i=0; i < 4 * NV20_3D_TEX_GEN_MODE__LEN; i++)
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(FOG_COEFF(0)), 3);
PUSH_DATAf(push, 1.5);
PUSH_DATAf(push, -0.090168);
PUSH_DATAf(push, 0.0);
BEGIN_NV04(push, NV20_3D(FOG_MODE), 2);
PUSH_DATA (push, NV20_3D_FOG_MODE_EXP_SIGNED);
PUSH_DATA (push, NV20_3D_FOG_COORD_FOG);
BEGIN_NV04(push, NV20_3D(FOG_ENABLE), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(ENGINE), 1);
PUSH_DATA (push, NV20_3D_ENGINE_FIXED);
for (i = 0; i < NV20_3D_TEX_MATRIX_ENABLE__LEN; i++) {
BEGIN_NV04(push, NV20_3D(TEX_MATRIX_ENABLE(i)), 1);
PUSH_DATA (push, 0);
}
BEGIN_NV04(push, NV20_3D(VERTEX_ATTR_4F_X(1)), 4 * 15);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 1.0);
for (i = 0; i < 12; i++) {
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
}
BEGIN_NV04(push, NV20_3D(EDGEFLAG_ENABLE), 1);
PUSH_DATA (push, 1);
BEGIN_NV04(push, NV20_3D(COLOR_MASK), 1);
PUSH_DATA (push, 0x00010101);
BEGIN_NV04(push, NV20_3D(CLEAR_VALUE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV20_3D(DEPTH_RANGE_NEAR), 2);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 16777216.0);
BEGIN_NV04(push, NV20_3D(VIEWPORT_TRANSLATE_X), 4);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 16777215.0);
BEGIN_NV04(push, NV20_3D(VIEWPORT_SCALE_X), 4);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 16777215.0 * 0.5);
PUSH_DATAf(push, 65535.0);
PUSH_KICK (push);
}
static void
nv20_context_destroy(struct gl_context *ctx)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
nv04_surface_takedown(ctx);
nv20_swtnl_destroy(ctx);
nv20_vbo_destroy(ctx);
nouveau_object_del(&nctx->hw.eng3d);
nouveau_context_deinit(ctx);
align_free(ctx);
}
static struct gl_context *
nv20_context_create(struct nouveau_screen *screen, gl_api api,
const struct gl_config *visual,
struct gl_context *share_ctx)
{
struct nouveau_context *nctx;
struct gl_context *ctx;
unsigned kelvin_class;
int ret;
nctx = align_calloc(sizeof(struct nouveau_context), 16);
if (!nctx)
return NULL;
ctx = &nctx->base;
if (!nouveau_context_init(ctx, api, screen, visual, share_ctx))
goto fail;
ctx->Extensions.ARB_texture_env_crossbar = true;
ctx->Extensions.ARB_texture_env_combine = true;
ctx->Extensions.ARB_texture_env_dot3 = true;
ctx->Extensions.EXT_texture_env_dot3 = true;
ctx->Extensions.NV_fog_distance = true;
ctx->Extensions.NV_texture_rectangle = true;
ctx->Extensions.EXT_texture_compression_s3tc = true;
ctx->Extensions.ANGLE_texture_compression_dxt = true;
/* GL constants. */
ctx->Const.MaxTextureCoordUnits = NV20_TEXTURE_UNITS;
ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = NV20_TEXTURE_UNITS;
ctx->Const.MaxTextureUnits = NV20_TEXTURE_UNITS;
ctx->Const.MaxTextureMaxAnisotropy = 8;
ctx->Const.MaxTextureLodBias = 15;
ctx->Driver.Clear = nv20_clear;
/* 2D engine. */
ret = nv04_surface_init(ctx);
if (!ret)
goto fail;
/* 3D engine. */
if (context_chipset(ctx) >= 0x25)
kelvin_class = NV25_3D_CLASS;
else
kelvin_class = NV20_3D_CLASS;
ret = nouveau_object_new(context_chan(ctx), 0xbeef0001, kelvin_class,
NULL, 0, &nctx->hw.eng3d);
if (ret)
goto fail;
nv20_hwctx_init(ctx);
nv20_vbo_init(ctx);
nv20_swtnl_init(ctx);
return ctx;
fail:
nv20_context_destroy(ctx);
return NULL;
}
const struct nouveau_driver nv20_driver = {
.context_create = nv20_context_create,
.context_destroy = nv20_context_destroy,
.surface_copy = nv04_surface_copy,
.surface_fill = nv04_surface_fill,
.emit = (nouveau_state_func[]) {
nv10_emit_alpha_func,
nv10_emit_blend_color,
nv10_emit_blend_equation,
nv10_emit_blend_func,
nv20_emit_clip_plane,
nv20_emit_clip_plane,
nv20_emit_clip_plane,
nv20_emit_clip_plane,
nv20_emit_clip_plane,
nv20_emit_clip_plane,
nv10_emit_color_mask,
nv20_emit_color_material,
nv10_emit_cull_face,
nv10_emit_front_face,
nv10_emit_depth,
nv10_emit_dither,
nv20_emit_frag,
nv20_emit_framebuffer,
nv20_emit_fog,
nv10_emit_light_enable,
nv20_emit_light_model,
nv20_emit_light_source,
nv20_emit_light_source,
nv20_emit_light_source,
nv20_emit_light_source,
nv20_emit_light_source,
nv20_emit_light_source,
nv20_emit_light_source,
nv20_emit_light_source,
nv10_emit_line_stipple,
nv10_emit_line_mode,
nv20_emit_logic_opcode,
nv20_emit_material_ambient,
nv20_emit_material_ambient,
nv20_emit_material_diffuse,
nv20_emit_material_diffuse,
nv20_emit_material_specular,
nv20_emit_material_specular,
nv20_emit_material_shininess,
nv20_emit_material_shininess,
nv20_emit_modelview,
nv20_emit_point_mode,
nv10_emit_point_parameter,
nv10_emit_polygon_mode,
nv10_emit_polygon_offset,
nv10_emit_polygon_stipple,
nv20_emit_projection,
nv10_emit_render_mode,
nv10_emit_scissor,
nv10_emit_shade_model,
nv10_emit_stencil_func,
nv10_emit_stencil_mask,
nv10_emit_stencil_op,
nv20_emit_tex_env,
nv20_emit_tex_env,
nv20_emit_tex_env,
nv20_emit_tex_env,
nv20_emit_tex_gen,
nv20_emit_tex_gen,
nv20_emit_tex_gen,
nv20_emit_tex_gen,
nv20_emit_tex_mat,
nv20_emit_tex_mat,
nv20_emit_tex_mat,
nv20_emit_tex_mat,
nv20_emit_tex_obj,
nv20_emit_tex_obj,
nv20_emit_tex_obj,
nv20_emit_tex_obj,
nv20_emit_viewport,
nv20_emit_tex_shader
},
.num_emit = NUM_NV20_STATE,
};

View File

@ -1,122 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __NV20_DRIVER_H__
#define __NV20_DRIVER_H__
enum {
NOUVEAU_STATE_TEX_SHADER = NUM_NOUVEAU_STATE,
NUM_NV20_STATE
};
#define NV20_TEXTURE_UNITS 4
/* nv20_context.c */
extern const struct nouveau_driver nv20_driver;
/* nv20_render.c */
void
nv20_vbo_init(struct gl_context *ctx);
void
nv20_vbo_destroy(struct gl_context *ctx);
void
nv20_swtnl_init(struct gl_context *ctx);
void
nv20_swtnl_destroy(struct gl_context *ctx);
/* nv20_state_fb.c */
void
nv20_emit_framebuffer(struct gl_context *ctx, int emit);
void
nv20_emit_viewport(struct gl_context *ctx, int emit);
/* nv20_state_polygon.c */
void
nv20_emit_point_mode(struct gl_context *ctx, int emit);
/* nv20_state_raster.c */
void
nv20_emit_logic_opcode(struct gl_context *ctx, int emit);
/* nv20_state_frag.c */
void
nv20_emit_tex_env(struct gl_context *ctx, int emit);
void
nv20_emit_frag(struct gl_context *ctx, int emit);
/* nv20_state_tex.c */
void
nv20_emit_tex_gen(struct gl_context *ctx, int emit);
void
nv20_emit_tex_mat(struct gl_context *ctx, int emit);
void
nv20_emit_tex_obj(struct gl_context *ctx, int emit);
void
nv20_emit_tex_shader(struct gl_context *ctx, int emit);
/* nv20_state_tnl.c */
void
nv20_emit_clip_plane(struct gl_context *ctx, int emit);
void
nv20_emit_color_material(struct gl_context *ctx, int emit);
void
nv20_emit_fog(struct gl_context *ctx, int emit);
void
nv20_emit_light_model(struct gl_context *ctx, int emit);
void
nv20_emit_light_source(struct gl_context *ctx, int emit);
void
nv20_emit_material_ambient(struct gl_context *ctx, int emit);
void
nv20_emit_material_diffuse(struct gl_context *ctx, int emit);
void
nv20_emit_material_specular(struct gl_context *ctx, int emit);
void
nv20_emit_material_shininess(struct gl_context *ctx, int emit);
void
nv20_emit_modelview(struct gl_context *ctx, int emit);
void
nv20_emit_projection(struct gl_context *ctx, int emit);
#endif

View File

@ -1,224 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nv20_3d.xml.h"
#include "nv20_driver.h"
#define NUM_VERTEX_ATTRS 16
static void
nv20_emit_material(struct gl_context *ctx, struct nouveau_array *a,
const void *v);
/* Vertex attribute format. */
static struct nouveau_attr_info nv20_vertex_attrs[VERT_ATTRIB_MAX] = {
[VERT_ATTRIB_POS] = {
.vbo_index = 0,
.imm_method = NV20_3D_VERTEX_POS_4F_X,
.imm_fields = 4,
},
[VERT_ATTRIB_NORMAL] = {
.vbo_index = 2,
.imm_method = NV20_3D_VERTEX_NOR_3F_X,
.imm_fields = 3,
},
[VERT_ATTRIB_COLOR0] = {
.vbo_index = 3,
.imm_method = NV20_3D_VERTEX_COL_4F,
.imm_fields = 4,
},
[VERT_ATTRIB_COLOR1] = {
.vbo_index = 4,
.imm_method = NV20_3D_VERTEX_COL2_3F,
.imm_fields = 3,
},
[VERT_ATTRIB_FOG] = {
.vbo_index = 5,
.imm_method = NV20_3D_VERTEX_FOG_1F,
.imm_fields = 1,
},
[VERT_ATTRIB_TEX0] = {
.vbo_index = 9,
.imm_method = NV20_3D_VERTEX_TX0_4F_S,
.imm_fields = 4,
},
[VERT_ATTRIB_TEX1] = {
.vbo_index = 10,
.imm_method = NV20_3D_VERTEX_TX1_4F_S,
.imm_fields = 4,
},
[VERT_ATTRIB_TEX2] = {
.vbo_index = 11,
.imm_method = NV20_3D_VERTEX_TX2_4F_S,
.imm_fields = 4,
},
[VERT_ATTRIB_TEX3] = {
.vbo_index = 12,
.imm_method = NV20_3D_VERTEX_TX3_4F_S,
.imm_fields = 4,
},
[VERT_ATTRIB_MAT(0)] = {
.emit = nv20_emit_material,
},
[VERT_ATTRIB_MAT(1)] = {
.emit = nv20_emit_material,
},
[VERT_ATTRIB_MAT(2)] = {
.emit = nv20_emit_material,
},
[VERT_ATTRIB_MAT(3)] = {
.emit = nv20_emit_material,
},
[VERT_ATTRIB_MAT(4)] = {
.emit = nv20_emit_material,
},
[VERT_ATTRIB_MAT(5)] = {
.emit = nv20_emit_material,
},
[VERT_ATTRIB_MAT(6)] = {
.emit = nv20_emit_material,
},
[VERT_ATTRIB_MAT(7)] = {
.emit = nv20_emit_material,
},
[VERT_ATTRIB_MAT(8)] = {
.emit = nv20_emit_material,
},
[VERT_ATTRIB_MAT(9)] = {
.emit = nv20_emit_material,
},
};
static int
get_hw_format(int type)
{
switch (type) {
case GL_FLOAT:
return NV20_3D_VTXBUF_FMT_TYPE_FLOAT;
case GL_UNSIGNED_SHORT:
return NV20_3D_VTXBUF_FMT_TYPE_USHORT;
case GL_UNSIGNED_BYTE:
return NV20_3D_VTXBUF_FMT_TYPE_UBYTE;
default:
assert(0);
}
}
static void
nv20_render_set_format(struct gl_context *ctx)
{
struct nouveau_render_state *render = to_render_state(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
int i, attr, hw_format;
FOR_EACH_ATTR(render, i, attr) {
if (attr >= 0) {
struct nouveau_array *a = &render->attrs[attr];
hw_format = a->stride << 8 |
a->fields << 4 |
get_hw_format(a->type);
} else {
/* Unused attribute. */
hw_format = NV20_3D_VTXBUF_FMT_TYPE_FLOAT;
}
BEGIN_NV04(push, NV20_3D(VTXBUF_FMT(i)), 1);
PUSH_DATA (push, hw_format);
}
}
static void
nv20_render_bind_vertices(struct gl_context *ctx)
{
struct nouveau_render_state *render = to_render_state(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
int i, attr;
FOR_EACH_BOUND_ATTR(render, i, attr) {
struct nouveau_array *a = &render->attrs[attr];
BEGIN_NV04(push, NV20_3D(VTXBUF_OFFSET(i)), 1);
PUSH_MTHD (push, NV20_3D(VTXBUF_OFFSET(i)), BUFCTX_VTX,
a->bo, a->offset, NOUVEAU_BO_LOW |
NOUVEAU_BO_OR | NOUVEAU_BO_GART |
NOUVEAU_BO_RD, 0,
NV20_3D_VTXBUF_OFFSET_DMA1);
}
}
static void
nv20_render_release_vertices(struct gl_context *ctx)
{
PUSH_RESET(context_push(ctx), BUFCTX_VTX);
}
/* Vertex array rendering defs. */
#define RENDER_LOCALS(ctx)
#define BATCH_VALIDATE() \
BEGIN_NV04(push, NV20_3D(VTXBUF_VALIDATE), 1); \
PUSH_DATA (push, 0)
#define BATCH_BEGIN(prim) \
BEGIN_NV04(push, NV20_3D(VERTEX_BEGIN_END), 1); \
PUSH_DATA (push, prim)
#define BATCH_END() \
BEGIN_NV04(push, NV20_3D(VERTEX_BEGIN_END), 1); \
PUSH_DATA (push, 0)
#define MAX_PACKET 0x400
#define MAX_OUT_L 0x100
#define BATCH_PACKET_L(n) \
BEGIN_NI04(push, NV20_3D(VTXBUF_BATCH), n)
#define BATCH_OUT_L(i, n) \
PUSH_DATA (push, ((n) - 1) << 24 | (i))
#define MAX_OUT_I16 0x2
#define BATCH_PACKET_I16(n) \
BEGIN_NI04(push, NV20_3D(VTXBUF_ELEMENT_U16), n)
#define BATCH_OUT_I16(i0, i1) \
PUSH_DATA (push, (i1) << 16 | (i0))
#define MAX_OUT_I32 0x1
#define BATCH_PACKET_I32(n) \
BEGIN_NI04(push, NV20_3D(VTXBUF_ELEMENT_U32), n)
#define BATCH_OUT_I32(i) \
PUSH_DATA (push, i)
#define IMM_PACKET(m, n) \
BEGIN_NV04(push, SUBC_3D(m), n)
#define IMM_OUT(x) \
PUSH_DATAf(push, x)
#define TAG(x) nv20_##x
#include "nouveau_render_t.c"
#include "nouveau_vbo_t.c"
#include "nouveau_swtnl_t.c"

View File

@ -1,152 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_fbo.h"
#include "nouveau_gldefs.h"
#include "nouveau_util.h"
#include "nv20_3d.xml.h"
#include "nv20_driver.h"
static inline unsigned
get_rt_format(mesa_format format)
{
switch (format) {
case MESA_FORMAT_B8G8R8X8_UNORM:
return NV20_3D_RT_FORMAT_COLOR_X8R8G8B8;
case MESA_FORMAT_B8G8R8A8_UNORM:
return NV20_3D_RT_FORMAT_COLOR_A8R8G8B8;
case MESA_FORMAT_B5G6R5_UNORM:
return NV20_3D_RT_FORMAT_COLOR_R5G6B5;
case MESA_FORMAT_Z_UNORM16:
return NV20_3D_RT_FORMAT_DEPTH_Z16;
case MESA_FORMAT_S8_UINT_Z24_UNORM:
return NV20_3D_RT_FORMAT_DEPTH_Z24S8;
default:
assert(0);
}
}
static void
setup_hierz_buffer(struct gl_context *ctx)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb);
unsigned pitch = align(fb->Width, 128),
height = align(fb->Height, 2),
size = pitch * height;
if (!nfb->hierz.bo || nfb->hierz.bo->size != size) {
nouveau_bo_ref(NULL, &nfb->hierz.bo);
nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_VRAM, 0, size,
NULL, &nfb->hierz.bo);
}
BEGIN_NV04(push, NV25_3D(HIERZ_PITCH), 1);
PUSH_DATA (push, pitch);
BEGIN_NV04(push, NV25_3D(HIERZ_OFFSET), 1);
PUSH_MTHDl(push, NV25_3D(HIERZ_OFFSET), BUFCTX_FB,
nfb->hierz.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
}
void
nv20_emit_framebuffer(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct nouveau_surface *s;
unsigned rt_format = NV20_3D_RT_FORMAT_TYPE_LINEAR;
unsigned rt_pitch = 0, zeta_pitch = 0;
unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR;
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT)
return;
PUSH_RESET(push, BUFCTX_FB);
/* Render target */
if (fb->_ColorDrawBuffers[0]) {
s = &to_nouveau_renderbuffer(
fb->_ColorDrawBuffers[0])->surface;
rt_format |= get_rt_format(s->format);
rt_pitch = s->pitch;
BEGIN_NV04(push, NV20_3D(COLOR_OFFSET), 1);
PUSH_MTHDl(push, NV20_3D(COLOR_OFFSET), BUFCTX_FB,
s->bo, 0, bo_flags);
}
/* depth/stencil */
if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
s = &to_nouveau_renderbuffer(
fb->Attachment[BUFFER_DEPTH].Renderbuffer)->surface;
rt_format |= get_rt_format(s->format);
zeta_pitch = s->pitch;
BEGIN_NV04(push, NV20_3D(ZETA_OFFSET), 1);
PUSH_MTHDl(push, NV20_3D(ZETA_OFFSET), BUFCTX_FB,
s->bo, 0, bo_flags);
if (context_chipset(ctx) >= 0x25)
setup_hierz_buffer(ctx);
} else {
rt_format |= get_rt_format(MESA_FORMAT_S8_UINT_Z24_UNORM);
zeta_pitch = rt_pitch;
}
BEGIN_NV04(push, NV20_3D(RT_FORMAT), 2);
PUSH_DATA (push, rt_format);
PUSH_DATA (push, zeta_pitch << 16 | rt_pitch);
/* Recompute the viewport/scissor state. */
context_dirty(ctx, VIEWPORT);
context_dirty(ctx, SCISSOR);
context_dirty(ctx, DEPTH);
}
void
nv20_emit_viewport(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
float a[4] = {};
get_viewport_translate(ctx, a);
BEGIN_NV04(push, NV20_3D(VIEWPORT_TRANSLATE_X), 4);
PUSH_DATAp(push, a, 4);
BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_HORIZ(0)), 1);
PUSH_DATA (push, (fb->Width - 1) << 16);
BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_VERT(0)), 1);
PUSH_DATA (push, (fb->Height - 1) << 16);
context_dirty(ctx, PROJECTION);
}

View File

@ -1,71 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nv20_3d.xml.h"
#include "nv10_driver.h"
#include "nv20_driver.h"
void
nv20_emit_tex_env(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_TEX_ENV0;
struct nouveau_pushbuf *push = context_push(ctx);
uint32_t a_in, a_out, c_in, c_out, k;
nv10_get_general_combiner(ctx, i, &a_in, &a_out, &c_in, &c_out, &k);
BEGIN_NV04(push, NV20_3D(RC_IN_ALPHA(i)), 1);
PUSH_DATA (push, a_in);
BEGIN_NV04(push, NV20_3D(RC_OUT_ALPHA(i)), 1);
PUSH_DATA (push, a_out);
BEGIN_NV04(push, NV20_3D(RC_IN_RGB(i)), 1);
PUSH_DATA (push, c_in);
BEGIN_NV04(push, NV20_3D(RC_OUT_RGB(i)), 1);
PUSH_DATA (push, c_out);
BEGIN_NV04(push, NV20_3D(RC_CONSTANT_COLOR0(i)), 1);
PUSH_DATA (push, k);
context_dirty(ctx, FRAG);
}
void
nv20_emit_frag(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
uint64_t in;
int n;
nv10_get_final_combiner(ctx, &in, &n);
BEGIN_NV04(push, NV20_3D(RC_FINAL0), 2);
PUSH_DATA (push, in);
PUSH_DATA (push, in >> 32);
BEGIN_NV04(push, NV20_3D(RC_ENABLE), 1);
PUSH_DATA (push, MAX2(1, n));
}

View File

@ -1,43 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_gldefs.h"
#include "nv20_3d.xml.h"
#include "nv20_driver.h"
void
nv20_emit_point_mode(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV20_3D(POINT_SIZE), 1);
if (context_chipset(ctx) >= 0x25)
PUSH_DATAf(push, ctx->Point.Size);
else
PUSH_DATA (push, (uint32_t)(ctx->Point.Size * 8));
}

View File

@ -1,42 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_gldefs.h"
#include "nouveau_util.h"
#include "nv20_3d.xml.h"
#include "nv20_driver.h"
void
nv20_emit_logic_opcode(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV20_3D(COLOR_LOGIC_OP_ENABLE), 2);
PUSH_DATAb(push, ctx->Color.ColorLogicOpEnabled);
PUSH_DATA (push, ctx->Color.LogicOp);
}

View File

@ -1,312 +0,0 @@
/*
* Copyright (C) 2009 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_gldefs.h"
#include "nouveau_texture.h"
#include "nv20_3d.xml.h"
#include "nouveau_util.h"
#include "nv20_driver.h"
#include "main/samplerobj.h"
void
nv20_emit_tex_gen(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_TEX_GEN0;
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_fixedfunc_texture_unit *unit =
&ctx->Texture.FixedFuncUnit[i];
int j;
for (j = 0; j < 4; j++) {
if (nctx->fallback == HWTNL && (unit->TexGenEnabled & 1 << j)) {
struct gl_texgen *coord = get_texgen_coord(unit, j);
float *k = get_texgen_coeff(unit, coord->Mode, j);
if (k) {
BEGIN_NV04(push, NV20_3D(TEX_GEN_COEFF(i, j)), 4);
PUSH_DATAp(push, k, 4);
}
BEGIN_NV04(push, NV20_3D(TEX_GEN_MODE(i, j)), 1);
PUSH_DATA (push, nvgl_texgen_mode(coord->Mode));
} else {
BEGIN_NV04(push, NV20_3D(TEX_GEN_MODE(i, j)), 1);
PUSH_DATA (push, 0);
}
}
}
void
nv20_emit_tex_mat(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_TEX_MAT0;
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
if (nctx->fallback == HWTNL &&
(ctx->Texture._TexMatEnabled & 1 << i)) {
BEGIN_NV04(push, NV20_3D(TEX_MATRIX_ENABLE(i)), 1);
PUSH_DATA (push, 1);
BEGIN_NV04(push, NV20_3D(TEX_MATRIX(i,0)), 16);
PUSH_DATAm(push, ctx->TextureMatrixStack[i].Top->m);
} else {
BEGIN_NV04(push, NV20_3D(TEX_MATRIX_ENABLE(i)), 1);
PUSH_DATA (push, 0);
}
}
static uint32_t
get_tex_format_pot(struct gl_texture_image *ti)
{
switch (ti->TexFormat) {
case MESA_FORMAT_B8G8R8A8_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_A8R8G8B8;
case MESA_FORMAT_B5G5R5A1_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_A1R5G5B5;
case MESA_FORMAT_B4G4R4A4_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_A4R4G4B4;
case MESA_FORMAT_B8G8R8X8_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_X8R8G8B8;
case MESA_FORMAT_B5G6R5_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_R5G6B5;
case MESA_FORMAT_A_UNORM8:
case MESA_FORMAT_I_UNORM8:
return NV20_3D_TEX_FORMAT_FORMAT_I8;
case MESA_FORMAT_L_UNORM8:
return NV20_3D_TEX_FORMAT_FORMAT_L8;
case MESA_FORMAT_RGB_DXT1:
case MESA_FORMAT_RGBA_DXT1:
return NV20_3D_TEX_FORMAT_FORMAT_DXT1;
case MESA_FORMAT_RGBA_DXT3:
return NV20_3D_TEX_FORMAT_FORMAT_DXT3;
case MESA_FORMAT_RGBA_DXT5:
return NV20_3D_TEX_FORMAT_FORMAT_DXT5;
default:
assert(0);
}
}
static uint32_t
get_tex_format_rect(struct gl_texture_image *ti)
{
switch (ti->TexFormat) {
case MESA_FORMAT_B8G8R8A8_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_A8R8G8B8_RECT;
case MESA_FORMAT_B5G5R5A1_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_A1R5G5B5_RECT;
case MESA_FORMAT_B4G4R4A4_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_A4R4G4B4_RECT;
case MESA_FORMAT_B8G8R8X8_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_R8G8B8_RECT;
case MESA_FORMAT_B5G6R5_UNORM:
return NV20_3D_TEX_FORMAT_FORMAT_R5G6B5_RECT;
case MESA_FORMAT_L_UNORM8:
return NV20_3D_TEX_FORMAT_FORMAT_L8_RECT;
case MESA_FORMAT_A_UNORM8:
case MESA_FORMAT_I_UNORM8:
return NV20_3D_TEX_FORMAT_FORMAT_I8_RECT;
default:
assert(0);
}
}
void
nv20_emit_tex_obj(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_TEX_OBJ0;
struct nouveau_pushbuf *push = context_push(ctx);
const int bo_flags = NOUVEAU_BO_RD | NOUVEAU_BO_GART | NOUVEAU_BO_VRAM;
struct gl_texture_object *t;
struct nouveau_surface *s;
struct gl_texture_image *ti;
const struct gl_sampler_object *sa;
uint8_t r, g, b, a;
uint32_t tx_format, tx_filter, tx_wrap, tx_bcolor, tx_enable;
PUSH_RESET(push, BUFCTX_TEX(i));
if (!ctx->Texture.Unit[i]._Current) {
BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1);
PUSH_DATA (push, 0);
context_dirty(ctx, TEX_SHADER);
return;
}
t = ctx->Texture.Unit[i]._Current;
s = &to_nouveau_texture(t)->surfaces[t->Attrib.BaseLevel];
ti = t->Image[0][t->Attrib.BaseLevel];
sa = _mesa_get_samplerobj(ctx, i);
if (!nouveau_texture_validate(ctx, t))
return;
/* Recompute the texturing registers. */
tx_format = ti->DepthLog2 << 28
| ti->HeightLog2 << 24
| ti->WidthLog2 << 20
| NV20_3D_TEX_FORMAT_DIMS_2D
| NV20_3D_TEX_FORMAT_NO_BORDER
| 1 << 16;
switch (t->Target) {
case GL_TEXTURE_1D:
tx_wrap = NV20_3D_TEX_WRAP_R_CLAMP_TO_EDGE
| NV20_3D_TEX_WRAP_T_CLAMP_TO_EDGE
| nvgl_wrap_mode_nv20(sa->Attrib.WrapS) << 0;
break;
default:
tx_wrap = nvgl_wrap_mode_nv20(sa->Attrib.WrapR) << 16
| nvgl_wrap_mode_nv20(sa->Attrib.WrapT) << 8
| nvgl_wrap_mode_nv20(sa->Attrib.WrapS) << 0;
break;
}
tx_filter = nvgl_filter_mode(sa->Attrib.MagFilter) << 24
| nvgl_filter_mode(sa->Attrib.MinFilter) << 16
| 2 << 12;
r = FLOAT_TO_UBYTE(sa->Attrib.state.border_color.f[0]);
g = FLOAT_TO_UBYTE(sa->Attrib.state.border_color.f[1]);
b = FLOAT_TO_UBYTE(sa->Attrib.state.border_color.f[2]);
a = FLOAT_TO_UBYTE(sa->Attrib.state.border_color.f[3]);
switch (ti->_BaseFormat) {
case GL_LUMINANCE:
a = 0xff;
FALLTHROUGH;
case GL_LUMINANCE_ALPHA:
g = b = r;
break;
case GL_RGB:
a = 0xff;
break;
case GL_INTENSITY:
g = b = a = r;
break;
case GL_ALPHA:
r = g = b = 0;
break;
}
tx_bcolor = b << 0 | g << 8 | r << 16 | a << 24;
tx_enable = NV20_3D_TEX_ENABLE_ENABLE
| log2i(sa->Attrib.MaxAnisotropy) << 4;
if (t->Target == GL_TEXTURE_RECTANGLE) {
BEGIN_NV04(push, NV20_3D(TEX_NPOT_PITCH(i)), 1);
PUSH_DATA (push, s->pitch << 16);
BEGIN_NV04(push, NV20_3D(TEX_NPOT_SIZE(i)), 1);
PUSH_DATA (push, s->width << 16 | s->height);
tx_format |= get_tex_format_rect(ti);
} else {
tx_format |= get_tex_format_pot(ti);
}
if (sa->Attrib.MinFilter != GL_NEAREST &&
sa->Attrib.MinFilter != GL_LINEAR) {
int lod_min = sa->Attrib.MinLod;
int lod_max = MIN2(sa->Attrib.MaxLod, t->_MaxLambda);
int lod_bias = sa->Attrib.LodBias
+ ctx->Texture.Unit[i].LodBias;
lod_max = CLAMP(lod_max, 0, 15);
lod_min = CLAMP(lod_min, 0, 15);
lod_bias = CLAMP(lod_bias, 0, 15);
tx_format |= NV20_3D_TEX_FORMAT_MIPMAP;
tx_filter |= lod_bias << 8;
tx_enable |= lod_min << 26
| lod_max << 14;
}
/* Write it to the hardware. */
BEGIN_NV04(push, NV20_3D(TEX_FORMAT(i)), 1);
PUSH_MTHD (push, NV20_3D(TEX_FORMAT(i)), BUFCTX_TEX(i),
s->bo, tx_format, bo_flags | NOUVEAU_BO_OR,
NV20_3D_TEX_FORMAT_DMA0,
NV20_3D_TEX_FORMAT_DMA1);
BEGIN_NV04(push, NV20_3D(TEX_OFFSET(i)), 1);
PUSH_MTHDl(push, NV20_3D(TEX_OFFSET(i)), BUFCTX_TEX(i),
s->bo, s->offset, bo_flags);
BEGIN_NV04(push, NV20_3D(TEX_WRAP(i)), 1);
PUSH_DATA (push, tx_wrap);
BEGIN_NV04(push, NV20_3D(TEX_FILTER(i)), 1);
PUSH_DATA (push, tx_filter);
BEGIN_NV04(push, NV20_3D(TEX_BORDER_COLOR(i)), 1);
PUSH_DATA (push, tx_bcolor);
BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1);
PUSH_DATA (push, tx_enable);
context_dirty(ctx, TEX_SHADER);
}
void
nv20_emit_tex_shader(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
uint32_t tx_shader_op = 0;
int i;
for (i = 0; i < NV20_TEXTURE_UNITS; i++) {
if (!ctx->Texture.Unit[i]._Current)
continue;
tx_shader_op |= NV20_3D_TEX_SHADER_OP_TX0_TEXTURE_2D << 5 * i;
}
BEGIN_NV04(push, NV20_3D(TEX_SHADER_OP), 1);
PUSH_DATA (push, tx_shader_op);
}

View File

@ -1,385 +0,0 @@
/*
* Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_gldefs.h"
#include "nouveau_util.h"
#include "nv20_3d.xml.h"
#include "nv10_driver.h"
#include "nv20_driver.h"
#include "util/bitscan.h"
#define LIGHT_MODEL_AMBIENT_R(side) \
((side) ? NV20_3D_LIGHT_MODEL_BACK_AMBIENT_R : \
NV20_3D_LIGHT_MODEL_FRONT_AMBIENT_R)
#define LIGHT_AMBIENT_R(side, i) \
((side) ? NV20_3D_LIGHT_BACK_AMBIENT_R(i) : \
NV20_3D_LIGHT_FRONT_AMBIENT_R(i))
#define LIGHT_DIFFUSE_R(side, i) \
((side) ? NV20_3D_LIGHT_BACK_DIFFUSE_R(i) : \
NV20_3D_LIGHT_FRONT_DIFFUSE_R(i))
#define LIGHT_SPECULAR_R(side, i) \
((side) ? NV20_3D_LIGHT_BACK_SPECULAR_R(i) : \
NV20_3D_LIGHT_FRONT_SPECULAR_R(i))
#define MATERIAL_FACTOR_R(side) \
((side) ? NV20_3D_MATERIAL_FACTOR_BACK_R : \
NV20_3D_MATERIAL_FACTOR_FRONT_R)
#define MATERIAL_FACTOR_A(side) \
((side) ? NV20_3D_MATERIAL_FACTOR_BACK_A : \
NV20_3D_MATERIAL_FACTOR_FRONT_A)
#define MATERIAL_SHININESS(side) \
((side) ? NV20_3D_BACK_MATERIAL_SHININESS(0) : \
NV20_3D_FRONT_MATERIAL_SHININESS(0))
void
nv20_emit_clip_plane(struct gl_context *ctx, int emit)
{
}
static inline unsigned
get_material_bitmask(unsigned m)
{
unsigned ret = 0;
if (m & MAT_BIT_FRONT_EMISSION)
ret |= NV20_3D_COLOR_MATERIAL_FRONT_EMISSION_COL1;
if (m & MAT_BIT_FRONT_AMBIENT)
ret |= NV20_3D_COLOR_MATERIAL_FRONT_AMBIENT_COL1;
if (m & MAT_BIT_FRONT_DIFFUSE)
ret |= NV20_3D_COLOR_MATERIAL_FRONT_DIFFUSE_COL1;
if (m & MAT_BIT_FRONT_SPECULAR)
ret |= NV20_3D_COLOR_MATERIAL_FRONT_SPECULAR_COL1;
if (m & MAT_BIT_BACK_EMISSION)
ret |= NV20_3D_COLOR_MATERIAL_BACK_EMISSION_COL1;
if (m & MAT_BIT_BACK_AMBIENT)
ret |= NV20_3D_COLOR_MATERIAL_BACK_AMBIENT_COL1;
if (m & MAT_BIT_BACK_DIFFUSE)
ret |= NV20_3D_COLOR_MATERIAL_BACK_DIFFUSE_COL1;
if (m & MAT_BIT_BACK_SPECULAR)
ret |= NV20_3D_COLOR_MATERIAL_BACK_SPECULAR_COL1;
return ret;
}
void
nv20_emit_color_material(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
unsigned mask = get_material_bitmask(ctx->Light._ColorMaterialBitmask);
BEGIN_NV04(push, NV20_3D(COLOR_MATERIAL), 1);
PUSH_DATA (push, ctx->Light.ColorMaterialEnabled ? mask : 0);
}
static unsigned
get_fog_mode_signed(unsigned mode)
{
switch (mode) {
case GL_LINEAR:
return NV20_3D_FOG_MODE_LINEAR_SIGNED;
case GL_EXP:
return NV20_3D_FOG_MODE_EXP_SIGNED;
case GL_EXP2:
return NV20_3D_FOG_MODE_EXP2_SIGNED;
default:
assert(0);
}
}
static unsigned
get_fog_mode_unsigned(unsigned mode)
{
switch (mode) {
case GL_LINEAR:
return NV20_3D_FOG_MODE_LINEAR_UNSIGNED;
case GL_EXP:
return NV20_3D_FOG_MODE_EXP_UNSIGNED;
case GL_EXP2:
return NV20_3D_FOG_MODE_EXP2_UNSIGNED;
default:
assert(0);
}
}
static unsigned
get_fog_source(unsigned source, unsigned distance_mode)
{
switch (source) {
case GL_FOG_COORDINATE_EXT:
return NV20_3D_FOG_COORD_FOG;
case GL_FRAGMENT_DEPTH_EXT:
switch (distance_mode) {
case GL_EYE_PLANE_ABSOLUTE_NV:
return NV20_3D_FOG_COORD_DIST_ORTHOGONAL_ABS;
case GL_EYE_PLANE:
return NV20_3D_FOG_COORD_DIST_ORTHOGONAL;
case GL_EYE_RADIAL_NV:
return NV20_3D_FOG_COORD_DIST_RADIAL;
default:
assert(0);
}
default:
assert(0);
}
}
void
nv20_emit_fog(struct gl_context *ctx, int emit)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_fog_attrib *f = &ctx->Fog;
unsigned source = nctx->fallback == HWTNL ?
f->FogCoordinateSource : GL_FOG_COORDINATE_EXT;
float k[3];
nv10_get_fog_coeff(ctx, k);
BEGIN_NV04(push, NV20_3D(FOG_MODE), 4);
PUSH_DATA (push, ((source == GL_FRAGMENT_DEPTH_EXT &&
f->FogDistanceMode == GL_EYE_PLANE_ABSOLUTE_NV) ?
get_fog_mode_unsigned(f->Mode) :
get_fog_mode_signed(f->Mode)));
PUSH_DATA (push, get_fog_source(source, f->FogDistanceMode));
PUSH_DATAb(push, f->Enabled);
PUSH_DATA (push, pack_rgba_f(MESA_FORMAT_R8G8B8A8_UNORM, f->Color));
BEGIN_NV04(push, NV20_3D(FOG_COEFF(0)), 3);
PUSH_DATAp(push, k, 3);
}
void
nv20_emit_light_model(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_lightmodel *m = &ctx->Light.Model;
BEGIN_NV04(push, NV20_3D(SEPARATE_SPECULAR_ENABLE), 1);
PUSH_DATAb(push, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR);
BEGIN_NV04(push, NV20_3D(LIGHT_MODEL), 1);
PUSH_DATA (push, ((m->LocalViewer ?
NV20_3D_LIGHT_MODEL_VIEWER_LOCAL :
NV20_3D_LIGHT_MODEL_VIEWER_NONLOCAL) |
(_mesa_need_secondary_color(ctx) ?
NV20_3D_LIGHT_MODEL_SEPARATE_SPECULAR :
0)));
BEGIN_NV04(push, NV20_3D(LIGHT_MODEL_TWO_SIDE_ENABLE), 1);
PUSH_DATAb(push, ctx->Light.Model.TwoSide);
}
void
nv20_emit_light_source(struct gl_context *ctx, int emit)
{
const int i = emit - NOUVEAU_STATE_LIGHT_SOURCE0;
struct nouveau_pushbuf *push = context_push(ctx);
struct gl_light *l = &ctx->Light.Light[i];
struct gl_light_uniforms *lu = &ctx->Light.LightSource[i];
if (l->_Flags & LIGHT_POSITIONAL) {
BEGIN_NV04(push, NV20_3D(LIGHT_POSITION_X(i)), 3);
PUSH_DATAp(push, l->_Position, 3);
BEGIN_NV04(push, NV20_3D(LIGHT_ATTENUATION_CONSTANT(i)), 3);
PUSH_DATAf(push, lu->ConstantAttenuation);
PUSH_DATAf(push, lu->LinearAttenuation);
PUSH_DATAf(push, lu->QuadraticAttenuation);
} else {
BEGIN_NV04(push, NV20_3D(LIGHT_DIRECTION_X(i)), 3);
PUSH_DATAp(push, l->_VP_inf_norm, 3);
BEGIN_NV04(push, NV20_3D(LIGHT_HALF_VECTOR_X(i)), 3);
PUSH_DATAp(push, l->_h_inf_norm, 3);
}
if (l->_Flags & LIGHT_SPOT) {
float k[7];
nv10_get_spot_coeff(l, lu, k);
BEGIN_NV04(push, NV20_3D(LIGHT_SPOT_CUTOFF(i, 0)), 7);
PUSH_DATAp(push, k, 7);
}
}
#define USE_COLOR_MATERIAL(attr, side) \
(ctx->Light.ColorMaterialEnabled && \
ctx->Light._ColorMaterialBitmask & (1 << MAT_ATTRIB_##attr(side)))
void
nv20_emit_material_ambient(struct gl_context *ctx, int emit)
{
const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT;
struct nouveau_pushbuf *push = context_push(ctx);
float (*mat)[4] = ctx->Light.Material.Attrib;
float c_scene[3], c_factor[3];
GLbitfield mask;
if (USE_COLOR_MATERIAL(AMBIENT, side)) {
COPY_3V(c_scene, mat[MAT_ATTRIB_EMISSION(side)]);
COPY_3V(c_factor, ctx->Light.Model.Ambient);
} else if (USE_COLOR_MATERIAL(EMISSION, side)) {
SCALE_3V(c_scene, mat[MAT_ATTRIB_AMBIENT(side)],
ctx->Light.Model.Ambient);
ASSIGN_3V(c_factor, 1, 1, 1);
} else {
COPY_3V(c_scene, ctx->Light._BaseColor[side]);
ZERO_3V(c_factor);
}
BEGIN_NV04(push, SUBC_3D(LIGHT_MODEL_AMBIENT_R(side)), 3);
PUSH_DATAp(push, c_scene, 3);
if (ctx->Light.ColorMaterialEnabled) {
BEGIN_NV04(push, SUBC_3D(MATERIAL_FACTOR_R(side)), 3);
PUSH_DATAp(push, c_factor, 3);
}
mask = ctx->Light._EnabledLights;
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *l = &ctx->Light.Light[i];
struct gl_light_uniforms *lu = &ctx->Light.LightSource[i];
float *c_light = (USE_COLOR_MATERIAL(AMBIENT, side) ?
lu->Ambient :
l->_MatAmbient[side]);
BEGIN_NV04(push, SUBC_3D(LIGHT_AMBIENT_R(side, i)), 3);
PUSH_DATAp(push, c_light, 3);
}
}
void
nv20_emit_material_diffuse(struct gl_context *ctx, int emit)
{
const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_DIFFUSE;
struct nouveau_pushbuf *push = context_push(ctx);
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
GLbitfield mask;
BEGIN_NV04(push, SUBC_3D(MATERIAL_FACTOR_A(side)), 1);
PUSH_DATAf(push, mat[MAT_ATTRIB_DIFFUSE(side)][3]);
mask = ctx->Light._EnabledLights;
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *l = &ctx->Light.Light[i];
struct gl_light_uniforms *lu = &ctx->Light.LightSource[i];
float *c_light = (USE_COLOR_MATERIAL(DIFFUSE, side) ?
lu->Diffuse :
l->_MatDiffuse[side]);
BEGIN_NV04(push, SUBC_3D(LIGHT_DIFFUSE_R(side, i)), 3);
PUSH_DATAp(push, c_light, 3);
}
}
void
nv20_emit_material_specular(struct gl_context *ctx, int emit)
{
const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_SPECULAR;
struct nouveau_pushbuf *push = context_push(ctx);
GLbitfield mask;
mask = ctx->Light._EnabledLights;
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *l = &ctx->Light.Light[i];
struct gl_light_uniforms *lu = &ctx->Light.LightSource[i];
float *c_light = (USE_COLOR_MATERIAL(SPECULAR, side) ?
lu->Specular :
l->_MatSpecular[side]);
BEGIN_NV04(push, SUBC_3D(LIGHT_SPECULAR_R(side, i)), 3);
PUSH_DATAp(push, c_light, 3);
}
}
void
nv20_emit_material_shininess(struct gl_context *ctx, int emit)
{
const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_SHININESS;
struct nouveau_pushbuf *push = context_push(ctx);
float (*mat)[4] = ctx->Light.Material.Attrib;
float k[6];
nv10_get_shininess_coeff(
CLAMP(mat[MAT_ATTRIB_SHININESS(side)][0], 0, 1024),
k);
BEGIN_NV04(push, SUBC_3D(MATERIAL_SHININESS(side)), 6);
PUSH_DATAp(push, k, 6);
}
void
nv20_emit_modelview(struct gl_context *ctx, int emit)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
GLmatrix *m = ctx->ModelviewMatrixStack.Top;
if (nctx->fallback != HWTNL)
return;
if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled ||
(ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) {
BEGIN_NV04(push, NV20_3D(MODELVIEW_MATRIX(0, 0)), 16);
PUSH_DATAm(push, m->m);
}
if (ctx->Light.Enabled ||
(ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) {
int i, j;
BEGIN_NV04(push, NV20_3D(INVERSE_MODELVIEW_MATRIX(0, 0)), 12);
for (i = 0; i < 3; i++)
for (j = 0; j < 4; j++)
PUSH_DATAf(push, m->inv[4*i + j]);
}
}
void
nv20_emit_projection(struct gl_context *ctx, int emit)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
GLmatrix m;
_math_matrix_ctr(&m);
get_viewport_scale(ctx, m.m);
if (nctx->fallback == HWTNL)
_math_matrix_mul_matrix(&m, &m, &ctx->_ModelProjectMatrix);
BEGIN_NV04(push, NV20_3D(PROJECTION_MATRIX(0)), 16);
PUSH_DATAm(push, m.m);
}

View File

@ -1,155 +0,0 @@
#ifndef NV_M2MF_XML
#define NV_M2MF_XML
/* Autogenerated file, DO NOT EDIT manually!
This file was generated by the rules-ng-ng headergen tool in this git repository:
http://0x04.net/cgit/index.cgi/rules-ng-ng
git clone git://0x04.net/rules-ng-ng
The rules-ng-ng source files this header was generated from are:
- nv_m2mf.xml ( 2710 bytes, from 2010-11-01 00:28:46)
- copyright.xml ( 6452 bytes, from 2010-11-15 15:10:58)
- nv_object.xml ( 11547 bytes, from 2010-11-13 23:32:57)
- nvchipsets.xml ( 3074 bytes, from 2010-11-13 23:32:57)
- nv_defs.xml ( 4437 bytes, from 2010-11-01 00:28:46)
Copyright (C) 2006-2010 by the following authors:
- Artur Huillet <arthur.huillet@free.fr> (ahuillet)
- Ben Skeggs (darktama, darktama_)
- B. R. <koala_br@users.sourceforge.net> (koala_br)
- Carlos Martin <carlosmn@users.sf.net> (carlosmn)
- Christoph Bumiller <e0425955@student.tuwien.ac.at> (calim, chrisbmr)
- Dawid Gajownik <gajownik@users.sf.net> (gajownik)
- Dmitry Baryshkov
- Dmitry Eremin-Solenikov <lumag@users.sf.net> (lumag)
- EdB <edb_@users.sf.net> (edb_)
- Erik Waling <erikwailing@users.sf.net> (erikwaling)
- Francisco Jerez <currojerez@riseup.net> (curro)
- imirkin <imirkin@users.sf.net> (imirkin)
- jb17bsome <jb17bsome@bellsouth.net> (jb17bsome)
- Jeremy Kolb <kjeremy@users.sf.net> (kjeremy)
- Laurent Carlier <lordheavym@gmail.com> (lordheavy)
- Luca Barbieri <luca@luca-barbieri.com> (lb, lb1)
- Maarten Maathuis <madman2003@gmail.com> (stillunknown)
- Marcin Kościelnicki <koriakin@0x04.net> (mwk, koriakin)
- Mark Carey <mark.carey@gmail.com> (careym)
- Matthieu Castet <matthieu.castet@parrot.com> (mat-c)
- nvidiaman <nvidiaman@users.sf.net> (nvidiaman)
- Patrice Mandin <patmandin@gmail.com> (pmandin, pmdata)
- Pekka Paalanen <pq@iki.fi> (pq, ppaalanen)
- Peter Popov <ironpeter@users.sf.net> (ironpeter)
- Richard Hughes <hughsient@users.sf.net> (hughsient)
- Rudi Cilibrasi <cilibrar@users.sf.net> (cilibrar)
- Serge Martin
- Simon Raffeiner
- Stephane Loeuillet <leroutier@users.sf.net> (leroutier)
- Stephane Marchesin <stephane.marchesin@gmail.com> (marcheu)
- sturmflut <sturmflut@users.sf.net> (sturmflut)
- Sylvain Munaut <tnt@246tNt.com>
- Victor Stinner <victor.stinner@haypocalc.com> (haypo)
- Wladmir van der Laan <laanwj@gmail.com> (miathan6)
- Younes Manton <younes.m@gmail.com> (ymanton)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define NV04_M2MF_DMA_NOTIFY 0x00000180
#define NV04_M2MF_DMA_BUFFER_IN 0x00000184
#define NV04_M2MF_DMA_BUFFER_OUT 0x00000188
#define NV50_M2MF_LINEAR_IN 0x00000200
#define NV50_M2MF_TILING_MODE_IN 0x00000204
#define NV50_M2MF_TILING_PITCH_IN 0x00000208
#define NV50_M2MF_TILING_HEIGHT_IN 0x0000020c
#define NV50_M2MF_TILING_DEPTH_IN 0x00000210
#define NV50_M2MF_TILING_POSITION_IN_Z 0x00000214
#define NV50_M2MF_TILING_POSITION_IN 0x00000218
#define NV50_M2MF_TILING_POSITION_IN_X__MASK 0x0000ffff
#define NV50_M2MF_TILING_POSITION_IN_X__SHIFT 0
#define NV50_M2MF_TILING_POSITION_IN_Y__MASK 0xffff0000
#define NV50_M2MF_TILING_POSITION_IN_Y__SHIFT 16
#define NV50_M2MF_LINEAR_OUT 0x0000021c
#define NV50_M2MF_TILING_MODE_OUT 0x00000220
#define NV50_M2MF_TILING_PITCH_OUT 0x00000224
#define NV50_M2MF_TILING_HEIGHT_OUT 0x00000228
#define NV50_M2MF_TILING_DEPTH_OUT 0x0000022c
#define NV50_M2MF_TILING_POSITION_OUT_Z 0x00000230
#define NV50_M2MF_TILING_POSITION_OUT 0x00000234
#define NV50_M2MF_TILING_POSITION_OUT_X__MASK 0x0000ffff
#define NV50_M2MF_TILING_POSITION_OUT_X__SHIFT 0
#define NV50_M2MF_TILING_POSITION_OUT_Y__MASK 0xffff0000
#define NV50_M2MF_TILING_POSITION_OUT_Y__SHIFT 16
#define NV50_M2MF_OFFSET_IN_HIGH 0x00000238
#define NV50_M2MF_OFFSET_OUT_HIGH 0x0000023c
#define NV04_M2MF_OFFSET_IN 0x0000030c
#define NV04_M2MF_OFFSET_OUT 0x00000310
#define NV04_M2MF_PITCH_IN 0x00000314
#define NV04_M2MF_PITCH_OUT 0x00000318
#define NV04_M2MF_LINE_LENGTH_IN 0x0000031c
#define NV04_M2MF_LINE_COUNT 0x00000320
#define NV04_M2MF_FORMAT 0x00000324
#define NV04_M2MF_FORMAT_INPUT_INC__MASK 0x000000ff
#define NV04_M2MF_FORMAT_INPUT_INC__SHIFT 0
#define NV04_M2MF_FORMAT_INPUT_INC_1 0x00000001
#define NV04_M2MF_FORMAT_INPUT_INC_2 0x00000002
#define NV04_M2MF_FORMAT_INPUT_INC_4 0x00000004
#define NV50_M2MF_FORMAT_INPUT_INC_8 0x00000008
#define NV50_M2MF_FORMAT_INPUT_INC_16 0x00000010
#define NV04_M2MF_FORMAT_OUTPUT_INC__MASK 0x0000ff00
#define NV04_M2MF_FORMAT_OUTPUT_INC__SHIFT 8
#define NV04_M2MF_FORMAT_OUTPUT_INC_1 0x00000100
#define NV04_M2MF_FORMAT_OUTPUT_INC_2 0x00000200
#define NV04_M2MF_FORMAT_OUTPUT_INC_4 0x00000400
#define NV50_M2MF_FORMAT_OUTPUT_INC_8 0x00000800
#define NV50_M2MF_FORMAT_OUTPUT_INC_16 0x00001000
#define NV04_M2MF_BUF_NOTIFY 0x00000328
#endif /* NV_M2MF_XML */

View File

@ -1,301 +0,0 @@
#ifndef _HOME_SKEGGSB_GIT_ENVYTOOLS_RNNDB_NV_OBJECT_XML
#define _HOME_SKEGGSB_GIT_ENVYTOOLS_RNNDB_NV_OBJECT_XML
/* WARNING ABOUT NOT EDITING AUTOGENERATED FILE IGNORED, _CLASS SUFFIX HAS
* BEEN ADDED TO ALL THE OBJECT CLASS DEFINITIONS TO AVOID CONFLICTS WITH
* THE RING MACROS WE WANT TO USE
*/
/* Autogenerated file, DO NOT EDIT manually!
This file was generated by the rules-ng-ng headergen tool in this git repository:
http://0x04.net/cgit/index.cgi/rules-ng-ng
git clone git://0x04.net/rules-ng-ng
The rules-ng-ng source files this header was generated from are:
- /home/skeggsb/git/envytools/rnndb/nv_object.xml ( 12672 bytes, from 2011-10-22 08:01:09)
- /home/skeggsb/git/envytools/rnndb/copyright.xml ( 6452 bytes, from 2011-10-22 08:01:09)
- /home/skeggsb/git/envytools/rnndb/nvchipsets.xml ( 3617 bytes, from 2011-10-22 08:01:09)
- /home/skeggsb/git/envytools/rnndb/nv_defs.xml ( 4437 bytes, from 2011-10-22 08:01:09)
- /home/skeggsb/git/envytools/rnndb/nv50_defs.xml ( 5468 bytes, from 2011-10-22 08:01:09)
Copyright (C) 2006-2011 by the following authors:
- Artur Huillet <arthur.huillet@free.fr> (ahuillet)
- Ben Skeggs (darktama, darktama_)
- B. R. <koala_br@users.sourceforge.net> (koala_br)
- Carlos Martin <carlosmn@users.sf.net> (carlosmn)
- Christoph Bumiller <e0425955@student.tuwien.ac.at> (calim, chrisbmr)
- Dawid Gajownik <gajownik@users.sf.net> (gajownik)
- Dmitry Baryshkov
- Dmitry Eremin-Solenikov <lumag@users.sf.net> (lumag)
- EdB <edb_@users.sf.net> (edb_)
- Erik Waling <erikwailing@users.sf.net> (erikwaling)
- Francisco Jerez <currojerez@riseup.net> (curro)
- imirkin <imirkin@users.sf.net> (imirkin)
- jb17bsome <jb17bsome@bellsouth.net> (jb17bsome)
- Jeremy Kolb <kjeremy@users.sf.net> (kjeremy)
- Laurent Carlier <lordheavym@gmail.com> (lordheavy)
- Luca Barbieri <luca@luca-barbieri.com> (lb, lb1)
- Maarten Maathuis <madman2003@gmail.com> (stillunknown)
- Marcin Kościelnicki <koriakin@0x04.net> (mwk, koriakin)
- Mark Carey <mark.carey@gmail.com> (careym)
- Matthieu Castet <matthieu.castet@parrot.com> (mat-c)
- nvidiaman <nvidiaman@users.sf.net> (nvidiaman)
- Patrice Mandin <patmandin@gmail.com> (pmandin, pmdata)
- Pekka Paalanen <pq@iki.fi> (pq, ppaalanen)
- Peter Popov <ironpeter@users.sf.net> (ironpeter)
- Richard Hughes <hughsient@users.sf.net> (hughsient)
- Rudi Cilibrasi <cilibrar@users.sf.net> (cilibrar)
- Serge Martin
- Simon Raffeiner
- Stephane Loeuillet <leroutier@users.sf.net> (leroutier)
- Stephane Marchesin <stephane.marchesin@gmail.com> (marcheu)
- sturmflut <sturmflut@users.sf.net> (sturmflut)
- Sylvain Munaut <tnt@246tNt.com>
- Victor Stinner <victor.stinner@haypocalc.com> (haypo)
- Wladmir van der Laan <laanwj@gmail.com> (miathan6)
- Younes Manton <younes.m@gmail.com> (ymanton)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define NV01_DMA_FROM_MEMORY_CLASS 0x00000002
#define NV01_DMA_TO_MEMORY_CLASS 0x00000003
#define NV01_NULL_CLASS 0x00000030
#define NV03_DMA_IN_MEMORY_CLASS 0x0000003d
#define NV01_OP_CLIP_CLASS 0x00000010
#define NV01_OP_BLEND_AND_CLASS 0x00000011
#define NV01_BETA_CLASS 0x00000012
#define NV04_BETA4_CLASS 0x00000072
#define NV01_OP_ROP_AND_CLASS 0x00000013
#define NV01_ROP_CLASS 0x00000014
#define NV03_ROP_CLASS 0x00000043
#define NV01_OP_CHROMA_CLASS 0x00000015
#define NV01_OP_PLANE_SWITCH_CLASS 0x00000016
#define NV01_CHROMA_CLASS 0x00000017
#define NV04_CHROMA_CLASS 0x00000057
#define NV01_PATTERN_CLASS 0x00000018
#define NV04_PATTERN_CLASS 0x00000044
#define NV01_CLIP_CLASS 0x00000019
#define NV01_OP_SRCCOPY_AND_CLASS 0x00000064
#define NV03_OP_SRCCOPY_CLASS 0x00000065
#define NV04_OP_SRCCOPY_PREMULT_CLASS 0x00000066
#define NV04_OP_BLEND_PREMULT_CLASS 0x00000067
#define NV01_POINT_CLASS 0x0000001a
#define NV01_LINE_CLASS 0x0000001b
#define NV01_LIN_CLASS 0x0000001c
#define NV04_LIN_CLASS 0x0000005c
#define NV30_LIN_CLASS 0x0000035c
#define NV40_LIN_CLASS 0x0000305c
#define NV01_TRI_CLASS 0x0000001d
#define NV04_TRI_CLASS 0x0000005d
#define NV01_RECT_CLASS 0x0000001e
#define NV04_RECT_CLASS 0x0000005e
#define NV01_BLIT_CLASS 0x0000001f
#define NV04_BLIT_CLASS 0x0000005f
#define NV15_BLIT_CLASS 0x0000009f
#define NV01_IFROMMEM_CLASS 0x00000020
#define NV01_IFC_CLASS 0x00000021
#define NV04_IFC_CLASS 0x00000061
#define NV05_IFC_CLASS 0x00000065
#define NV10_IFC_CLASS 0x0000008a
#define NV30_IFC_CLASS 0x0000038a
#define NV40_IFC_CLASS 0x0000308a
#define NV01_BITMAP_CLASS 0x00000022
#define NV01_ITOMEM_CLASS 0x00000025
#define NV03_SIFC_CLASS 0x00000036
#define NV04_SIFC_CLASS 0x00000076
#define NV05_SIFC_CLASS 0x00000066
#define NV30_SIFC_CLASS 0x00000366
#define NV40_SIFC_CLASS 0x00003066
#define NV03_SIFM_CLASS 0x00000037
#define NV04_SIFM_CLASS 0x00000077
#define NV05_SIFM_CLASS 0x00000063
#define NV10_SIFM_CLASS 0x00000089
#define NV30_SIFM_CLASS 0x00000389
#define NV40_SIFM_CLASS 0x00003089
#define NV50_SIFM_CLASS 0x00005089
#define NV03_SYFM_CLASS 0x00000038
#define NV03_GDI_CLASS 0x0000004b
#define NV04_GDI_CLASS 0x0000004a
#define NV04_SURFACE_SWZ_CLASS 0x00000052
#define NV20_SURFACE_SWZ_CLASS 0x0000009e
#define NV30_SURFACE_SWZ_CLASS 0x0000039e
#define NV40_SURFACE_SWZ_CLASS 0x0000309e
#define NV03_SURFACE_DST_CLASS 0x00000058
#define NV03_SURFACE_SRC_CLASS 0x00000059
#define NV04_SURFACE_2D_CLASS 0x00000042
#define NV10_SURFACE_2D_CLASS 0x00000062
#define NV30_SURFACE_2D_CLASS 0x00000362
#define NV40_SURFACE_2D_CLASS 0x00003062
#define NV50_SURFACE_2D_CLASS 0x00005062
#define NV04_INDEX_CLASS 0x00000060
#define NV05_INDEX_CLASS 0x00000064
#define NV30_INDEX_CLASS 0x00000364
#define NV40_INDEX_CLASS 0x00003064
#define NV10_TEXUPLOAD_CLASS 0x0000007b
#define NV30_TEXUPLOAD_CLASS 0x0000037b
#define NV40_TEXUPLOAD_CLASS 0x0000307b
#define NV04_DVD_SUBPICTURE_CLASS 0x00000038
#define NV10_DVD_SUBPICTURE_CLASS 0x00000088
#define NV03_M2MF_CLASS 0x00000039
#define NV50_M2MF_CLASS 0x00005039
#define NVC0_M2MF_CLASS 0x00009039
#define NV03_SURFACE_COLOR_CLASS 0x0000005a
#define NV03_SURFACE_ZETA_CLASS 0x0000005b
#define NV03_TEXTURED_TRIANGLE_CLASS 0x00000048
#define NV04_TEXTURED_TRIANGLE_CLASS 0x00000054
#define NV10_TEXTURED_TRIANGLE_CLASS 0x00000094
#define NV04_SURFACE_3D_CLASS 0x00000053
#define NV10_SURFACE_3D_CLASS 0x00000093
#define NV04_MULTITEX_TRIANGLE_CLASS 0x00000055
#define NV10_MULTITEX_TRIANGLE_CLASS 0x00000095
#define NV10_3D_CLASS 0x00000056
#define NV15_3D_CLASS 0x00000096
#define NV11_3D_CLASS 0x00000098
#define NV17_3D_CLASS 0x00000099
#define NV20_3D_CLASS 0x00000097
#define NV25_3D_CLASS 0x00000597
#define NV30_3D_CLASS 0x00000397
#define NV35_3D_CLASS 0x00000497
#define NV34_3D_CLASS 0x00000697
#define NV40_3D_CLASS 0x00004097
#define NV44_3D_CLASS 0x00004497
#define NV50_3D_CLASS 0x00005097
#define NV84_3D_CLASS 0x00008297
#define NVA0_3D_CLASS 0x00008397
#define NVA3_3D_CLASS 0x00008597
#define NVAF_3D_CLASS 0x00008697
#define NVC0_3D_CLASS 0x00009097
#define NVC1_3D_CLASS 0x00009197
#define NVC8_3D_CLASS 0x00009297
#define NV50_2D_CLASS 0x0000502d
#define NVC0_2D_CLASS 0x0000902d
#define NV50_COMPUTE_CLASS 0x000050c0
#define NVA3_COMPUTE_CLASS 0x000085c0
#define NVC0_COMPUTE_CLASS 0x000090c0
#define NVC8_COMPUTE_CLASS 0x000092c0
#define NV84_CRYPT_CLASS 0x000074c1
#define BLOB_NVC0_PCOPY1_CLASS 0x000090b8
#define BLOB_NVC0_PCOPY0_CLASS 0x000090b5
#define NV31_MPEG_CLASS 0x00003174
#define NV84_MPEG_CLASS 0x00008274
#define NV01_SUBCHAN__SIZE 0x00008000
#define NV01_SUBCHAN 0x00000000
#define NV01_SUBCHAN_OBJECT 0x00000000
#define NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH 0x00000010
#define NV84_SUBCHAN_SEMAPHORE_ADDRESS_LOW 0x00000014
#define NV84_SUBCHAN_SEMAPHORE_SEQUENCE 0x00000018
#define NV84_SUBCHAN_SEMAPHORE_TRIGGER 0x0000001c
#define NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL 0x00000001
#define NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG 0x00000002
#define NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_GEQUAL 0x00000004
#define NV84_SUBCHAN_NOTIFY_INTR 0x00000020
#define NV84_SUBCHAN_WRCACHE_FLUSH 0x00000024
#define NV10_SUBCHAN_REF_CNT 0x00000050
#define NV11_SUBCHAN_DMA_SEMAPHORE 0x00000060
#define NV11_SUBCHAN_SEMAPHORE_OFFSET 0x00000064
#define NV11_SUBCHAN_SEMAPHORE_ACQUIRE 0x00000068
#define NV11_SUBCHAN_SEMAPHORE_RELEASE 0x0000006c
#define NV40_SUBCHAN_YIELD 0x00000080
#define NV01_GRAPH 0x00000000
#define NV04_GRAPH_NOP 0x00000100
#define NV04_GRAPH_NOTIFY 0x00000104
#define NV04_GRAPH_NOTIFY_WRITE 0x00000000
#define NV04_GRAPH_NOTIFY_WRITE_AND_AWAKEN 0x00000001
#define NVC0_GRAPH_NOTIFY_ADDRESS_HIGH 0x00000104
#define NVC0_GRAPH_NOTIFY_ADDRESS_LOW 0x00000108
#define NVC0_GRAPH_NOTIFY 0x0000010c
#define NVC0_GRAPH_NOTIFY_WRITE 0x00000000
#define NVC0_GRAPH_NOTIFY_WRITE_AND_AWAKEN 0x00000001
#define NV50_GRAPH_SERIALIZE 0x00000110
#define NVC0_GRAPH_MACRO_UPLOAD_POS 0x00000114
#define NVC0_GRAPH_MACRO_UPLOAD_DATA 0x00000118
#define NVC0_GRAPH_MACRO_ID 0x0000011c
#define NVC0_GRAPH_MACRO_POS 0x00000120
#define NVA3_GRAPH_UNK0120 0x00000120
#define NVA3_GRAPH_UNK0124 0x00000124
#define NVC0_GRAPH_UNK0124 0x00000124
#define NVC0_GRAPH_COND_ADDRESS_HIGH 0x00000130
#define NVC0_GRAPH_COND_ADDRESS_LOW 0x00000134
#define NVC0_GRAPH_COND_MODE 0x00000138
#define NVC0_GRAPH_COND_MODE_NEVER 0x00000000
#define NVC0_GRAPH_COND_MODE_ALWAYS 0x00000001
#define NVC0_GRAPH_COND_MODE_RES_NON_ZERO 0x00000002
#define NVC0_GRAPH_COND_MODE_EQUAL 0x00000003
#define NVC0_GRAPH_COND_MODE_NOT_EQUAL 0x00000004
#define NVC0_GRAPH_UNK013C 0x0000013c
#define NV40_GRAPH_PM_TRIGGER 0x00000140
#define NVC0_GRAPH_UNK0150 0x00000150
#define NVC0_GRAPH_UNK0154 0x00000154
#define NVC0_GRAPH_SCRATCH(i0) (0x00003400 + 0x4*(i0))
#define NVC0_GRAPH_SCRATCH__ESIZE 0x00000004
#define NVC0_GRAPH_SCRATCH__LEN 0x00000080
#define NVC0_GRAPH_MACRO(i0) (0x00003800 + 0x8*(i0))
#define NVC0_GRAPH_MACRO__ESIZE 0x00000008
#define NVC0_GRAPH_MACRO__LEN 0x00000080
#define NVC0_GRAPH_MACRO_PARAM(i0) (0x00003804 + 0x8*(i0))
#define NVC0_GRAPH_MACRO_PARAM__ESIZE 0x00000008
#define NVC0_GRAPH_MACRO_PARAM__LEN 0x00000080
#endif /* _HOME_SKEGGSB_GIT_ENVYTOOLS_RNNDB_NV_OBJECT_XML */