Drop fb, ffb and gamma dri drivers
This commit is contained in:
13
configure.ac
13
configure.ac
@@ -720,10 +720,9 @@ if test "$mesa_driver" = dri; then
|
||||
|
||||
case "$host_cpu" in
|
||||
x86_64)
|
||||
# ffb, gamma, and sis are missing because they have not be
|
||||
# converted to use the new interface. i810 are missing
|
||||
# because there is no x86-64 system where they could *ever*
|
||||
# be used.
|
||||
# sis is missing because they have not be converted to use
|
||||
# the new interface. i810 are missing because there is no
|
||||
# x86-64 system where they could *ever* be used.
|
||||
if test "x$DRI_DIRS" = "xyes"; then
|
||||
DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 r600 radeon \
|
||||
savage tdfx unichrome swrast"
|
||||
@@ -739,7 +738,7 @@ if test "$mesa_driver" = dri; then
|
||||
sparc*)
|
||||
# Build only the drivers for cards that exist on sparc`
|
||||
if test "x$DRI_DIRS" = "xyes"; then
|
||||
DRI_DIRS="mach64 r128 r200 r300 r600 radeon ffb swrast"
|
||||
DRI_DIRS="mach64 r128 r200 r300 r600 radeon swrast"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -755,8 +754,6 @@ if test "$mesa_driver" = dri; then
|
||||
CXXFLAGS="$CXXFLAGS -ansi -pedantic"
|
||||
fi
|
||||
|
||||
# ffb and gamma are missing because they have not been converted
|
||||
# to use the new interface.
|
||||
if test "x$DRI_DIRS" = "xyes"; then
|
||||
DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon tdfx \
|
||||
unichrome savage sis swrast"
|
||||
@@ -778,7 +775,7 @@ if test "$mesa_driver" = dri; then
|
||||
# default drivers
|
||||
if test "x$DRI_DIRS" = "xyes"; then
|
||||
DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
|
||||
savage sis tdfx unichrome ffb swrast"
|
||||
savage sis tdfx unichrome swrast"
|
||||
fi
|
||||
|
||||
DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
# Doxyfile 1.3.2-Gideon
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# General configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = fb
|
||||
PROJECT_NUMBER = $VERSION$
|
||||
OUTPUT_DIRECTORY =
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
SHORT_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
TAB_SIZE = 8
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ALIASES =
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SHOW_USED_FILES = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = /home/temp/Mesa/src/drv/fb
|
||||
FILE_PATTERNS = *.c \
|
||||
*.cc \
|
||||
*.cxx \
|
||||
*.cpp \
|
||||
*.c++ \
|
||||
*.java \
|
||||
*.ii \
|
||||
*.ixx \
|
||||
*.ipp \
|
||||
*.i++ \
|
||||
*.inl \
|
||||
*.h \
|
||||
*.hh \
|
||||
*.hxx \
|
||||
*.hpp \
|
||||
*.h++ \
|
||||
*.idl \
|
||||
*.odl \
|
||||
*.cs \
|
||||
*.C \
|
||||
*.H \
|
||||
*.tlh \
|
||||
*.diff \
|
||||
*.patch \
|
||||
*.moc \
|
||||
*.xpm
|
||||
RECURSIVE = yes
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = YES
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = yes
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
CGI_NAME = search.cgi
|
||||
CGI_URL =
|
||||
DOC_URL =
|
||||
DOC_ABSPATH =
|
||||
BIN_ABSPATH = /usr/local/bin/
|
||||
EXT_DOC_PATHS =
|
||||
@@ -1,24 +0,0 @@
|
||||
# src/mesa/drivers/dri/fb/Makefile
|
||||
|
||||
TOP = ../../../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
LIBNAME = fb_dri.so
|
||||
|
||||
|
||||
DRIVER_SOURCES = \
|
||||
fb_dri.c \
|
||||
$(EGL_SOURCES)
|
||||
|
||||
|
||||
C_SOURCES = \
|
||||
$(COMMON_SOURCES) \
|
||||
$(DRIVER_SOURCES)
|
||||
|
||||
ASM_SOURCES =
|
||||
|
||||
# XXX not 100% sure this is right
|
||||
#WINDOW_SYSTEM = solo
|
||||
|
||||
include ../Makefile.template
|
||||
|
||||
@@ -1,792 +0,0 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.3
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul 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 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
|
||||
* BRIAN PAUL 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.
|
||||
*/
|
||||
|
||||
/* Minimal swrast-based dri loadable driver.
|
||||
*
|
||||
* Todo:
|
||||
* -- Use malloced (rather than framebuffer) memory for backbuffer
|
||||
* -- 32bpp is hardwared -- fix
|
||||
*
|
||||
* NOTES:
|
||||
* -- No mechanism for cliprects or resize notification --
|
||||
* assumes this is a fullscreen device.
|
||||
* -- No locking -- assumes this is the only driver accessing this
|
||||
* device.
|
||||
* -- Doesn't (yet) make use of any acceleration or other interfaces
|
||||
* provided by fb. Would be entirely happy working against any
|
||||
* fullscreen interface.
|
||||
* -- HOWEVER: only a small number of pixelformats are supported, and
|
||||
* the mechanism for choosing between them makes some assumptions
|
||||
* that may not be valid everywhere.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
#include "drm.h"
|
||||
#include "utils.h"
|
||||
#include "drirenderbuffer.h"
|
||||
|
||||
#include "buffers.h"
|
||||
#include "main/extensions.h"
|
||||
#include "main/framebuffer.h"
|
||||
#include "main/renderbuffer.h"
|
||||
#include "vbo/vbo.h"
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/tcontext.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
|
||||
void fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis);
|
||||
|
||||
typedef struct {
|
||||
GLcontext *glCtx; /* Mesa context */
|
||||
|
||||
struct {
|
||||
__DRIcontext *context;
|
||||
__DRIscreen *screen;
|
||||
__DRIdrawable *drawable; /* drawable bound to this ctx */
|
||||
} dri;
|
||||
|
||||
} fbContext, *fbContextPtr;
|
||||
|
||||
#define FB_CONTEXT(ctx) ((fbContextPtr)(ctx->DriverCtx))
|
||||
|
||||
|
||||
static const GLubyte *
|
||||
get_string(GLcontext *ctx, GLenum pname)
|
||||
{
|
||||
(void) ctx;
|
||||
switch (pname) {
|
||||
case GL_RENDERER:
|
||||
return (const GLubyte *) "Mesa dumb framebuffer";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
update_state( GLcontext *ctx, GLuint new_state )
|
||||
{
|
||||
/* not much to do here - pass it on */
|
||||
_swrast_InvalidateState( ctx, new_state );
|
||||
_swsetup_InvalidateState( ctx, new_state );
|
||||
_vbo_InvalidateState( ctx, new_state );
|
||||
_tnl_InvalidateState( ctx, new_state );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by ctx->Driver.GetBufferSize from in core Mesa to query the
|
||||
* current framebuffer size.
|
||||
*/
|
||||
static void
|
||||
get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
fbContextPtr fbmesa = FB_CONTEXT(ctx);
|
||||
|
||||
*width = fbmesa->dri.drawable->w;
|
||||
*height = fbmesa->dri.drawable->h;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
updateFramebufferSize(GLcontext *ctx)
|
||||
{
|
||||
fbContextPtr fbmesa = FB_CONTEXT(ctx);
|
||||
struct gl_framebuffer *fb = ctx->WinSysDrawBuffer;
|
||||
if (fbmesa->dri.drawable->w != fb->Width ||
|
||||
fbmesa->dri.drawable->h != fb->Height) {
|
||||
driUpdateFramebufferSize(ctx, fbmesa->dri.drawable);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
|
||||
{
|
||||
/* XXX this should be called after we acquire the DRI lock, not here */
|
||||
updateFramebufferSize(ctx);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init_core_functions( struct dd_function_table *functions )
|
||||
{
|
||||
functions->GetString = get_string;
|
||||
functions->UpdateState = update_state;
|
||||
functions->GetBufferSize = get_buffer_size;
|
||||
functions->Viewport = viewport;
|
||||
|
||||
functions->Clear = _swrast_Clear; /* could accelerate with blits */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Generate code for span functions.
|
||||
*/
|
||||
|
||||
/* 24-bit BGR */
|
||||
#define NAME(PREFIX) PREFIX##_B8G8R8
|
||||
#define FORMAT GL_RGBA8
|
||||
#define SPAN_VARS \
|
||||
driRenderbuffer *drb = (driRenderbuffer *) rb;
|
||||
#define INIT_PIXEL_PTR(P, X, Y) \
|
||||
GLubyte *P = (GLubyte *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 3;
|
||||
#define INC_PIXEL_PTR(P) P += 3
|
||||
#define STORE_PIXEL(DST, X, Y, VALUE) \
|
||||
DST[0] = VALUE[BCOMP]; \
|
||||
DST[1] = VALUE[GCOMP]; \
|
||||
DST[2] = VALUE[RCOMP]
|
||||
#define FETCH_PIXEL(DST, SRC) \
|
||||
DST[RCOMP] = SRC[2]; \
|
||||
DST[GCOMP] = SRC[1]; \
|
||||
DST[BCOMP] = SRC[0]; \
|
||||
DST[ACOMP] = 0xff
|
||||
|
||||
#include "swrast/s_spantemp.h"
|
||||
|
||||
|
||||
/* 32-bit BGRA */
|
||||
#define NAME(PREFIX) PREFIX##_B8G8R8A8
|
||||
#define FORMAT GL_RGBA8
|
||||
#define SPAN_VARS \
|
||||
driRenderbuffer *drb = (driRenderbuffer *) rb;
|
||||
#define INIT_PIXEL_PTR(P, X, Y) \
|
||||
GLubyte *P = (GLubyte *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 4;
|
||||
#define INC_PIXEL_PTR(P) P += 4
|
||||
#define STORE_PIXEL(DST, X, Y, VALUE) \
|
||||
DST[0] = VALUE[BCOMP]; \
|
||||
DST[1] = VALUE[GCOMP]; \
|
||||
DST[2] = VALUE[RCOMP]; \
|
||||
DST[3] = VALUE[ACOMP]
|
||||
#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
|
||||
DST[0] = VALUE[BCOMP]; \
|
||||
DST[1] = VALUE[GCOMP]; \
|
||||
DST[2] = VALUE[RCOMP]; \
|
||||
DST[3] = 0xff
|
||||
#define FETCH_PIXEL(DST, SRC) \
|
||||
DST[RCOMP] = SRC[2]; \
|
||||
DST[GCOMP] = SRC[1]; \
|
||||
DST[BCOMP] = SRC[0]; \
|
||||
DST[ACOMP] = SRC[3]
|
||||
|
||||
#include "swrast/s_spantemp.h"
|
||||
|
||||
|
||||
/* 16-bit BGR (XXX implement dithering someday) */
|
||||
#define NAME(PREFIX) PREFIX##_B5G6R5
|
||||
#define FORMAT GL_RGBA8
|
||||
#define SPAN_VARS \
|
||||
driRenderbuffer *drb = (driRenderbuffer *) rb;
|
||||
#define INIT_PIXEL_PTR(P, X, Y) \
|
||||
GLushort *P = (GLushort *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 2;
|
||||
#define INC_PIXEL_PTR(P) P += 1
|
||||
#define STORE_PIXEL(DST, X, Y, VALUE) \
|
||||
DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 8) | (((VALUE[GCOMP]) & 0xfc) << 3) | ((VALUE[BCOMP]) >> 3) )
|
||||
#define FETCH_PIXEL(DST, SRC) \
|
||||
DST[RCOMP] = ( (((SRC[0]) >> 8) & 0xf8) | (((SRC[0]) >> 11) & 0x7) ); \
|
||||
DST[GCOMP] = ( (((SRC[0]) >> 3) & 0xfc) | (((SRC[0]) >> 5) & 0x3) ); \
|
||||
DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \
|
||||
DST[ACOMP] = 0xff
|
||||
|
||||
#include "swrast/s_spantemp.h"
|
||||
|
||||
|
||||
/* 15-bit BGR (XXX implement dithering someday) */
|
||||
#define NAME(PREFIX) PREFIX##_B5G5R5
|
||||
#define FORMAT GL_RGBA8
|
||||
#define SPAN_VARS \
|
||||
driRenderbuffer *drb = (driRenderbuffer *) rb;
|
||||
#define INIT_PIXEL_PTR(P, X, Y) \
|
||||
GLushort *P = (GLushort *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 2;
|
||||
#define INC_PIXEL_PTR(P) P += 1
|
||||
#define STORE_PIXEL(DST, X, Y, VALUE) \
|
||||
DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 7) | (((VALUE[GCOMP]) & 0xf8) << 2) | ((VALUE[BCOMP]) >> 3) )
|
||||
#define FETCH_PIXEL(DST, SRC) \
|
||||
DST[RCOMP] = ( (((SRC[0]) >> 7) & 0xf8) | (((SRC[0]) >> 10) & 0x7) ); \
|
||||
DST[GCOMP] = ( (((SRC[0]) >> 2) & 0xf8) | (((SRC[0]) >> 5) & 0x7) ); \
|
||||
DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \
|
||||
DST[ACOMP] = 0xff
|
||||
|
||||
#include "swrast/s_spantemp.h"
|
||||
|
||||
|
||||
/* 8-bit color index */
|
||||
#define NAME(PREFIX) PREFIX##_CI8
|
||||
#define FORMAT GL_COLOR_INDEX8_EXT
|
||||
#define SPAN_VARS \
|
||||
driRenderbuffer *drb = (driRenderbuffer *) rb;
|
||||
#define INIT_PIXEL_PTR(P, X, Y) \
|
||||
GLubyte *P = (GLubyte *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X);
|
||||
#define INC_PIXEL_PTR(P) P += 1
|
||||
#define STORE_PIXEL(DST, X, Y, VALUE) \
|
||||
*DST = VALUE[0]
|
||||
#define FETCH_PIXEL(DST, SRC) \
|
||||
DST = SRC[0]
|
||||
|
||||
#include "swrast/s_spantemp.h"
|
||||
|
||||
|
||||
|
||||
void
|
||||
fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
|
||||
{
|
||||
ASSERT(drb->Base.InternalFormat == GL_RGBA);
|
||||
if (drb->Base.InternalFormat == GL_RGBA) {
|
||||
if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
|
||||
drb->Base.GetRow = get_row_B5G6R5;
|
||||
drb->Base.GetValues = get_values_B5G6R5;
|
||||
drb->Base.PutRow = put_row_B5G6R5;
|
||||
drb->Base.PutMonoRow = put_mono_row_B5G6R5;
|
||||
drb->Base.PutRowRGB = put_row_rgb_B5G6R5;
|
||||
drb->Base.PutValues = put_values_B5G6R5;
|
||||
drb->Base.PutMonoValues = put_mono_values_B5G6R5;
|
||||
}
|
||||
else if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) {
|
||||
drb->Base.GetRow = get_row_B5G5R5;
|
||||
drb->Base.GetValues = get_values_B5G5R5;
|
||||
drb->Base.PutRow = put_row_B5G5R5;
|
||||
drb->Base.PutMonoRow = put_mono_row_B5G5R5;
|
||||
drb->Base.PutRowRGB = put_row_rgb_B5G5R5;
|
||||
drb->Base.PutValues = put_values_B5G5R5;
|
||||
drb->Base.PutMonoValues = put_mono_values_B5G5R5;
|
||||
}
|
||||
else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8
|
||||
&& vis->alphaBits == 8) {
|
||||
drb->Base.GetRow = get_row_B8G8R8A8;
|
||||
drb->Base.GetValues = get_values_B8G8R8A8;
|
||||
drb->Base.PutRow = put_row_B8G8R8A8;
|
||||
drb->Base.PutMonoRow = put_mono_row_B8G8R8A8;
|
||||
drb->Base.PutRowRGB = put_row_rgb_B8G8R8A8;
|
||||
drb->Base.PutValues = put_values_B8G8R8A8;
|
||||
drb->Base.PutMonoValues = put_mono_values_B8G8R8A8;
|
||||
}
|
||||
else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8
|
||||
&& vis->alphaBits == 0) {
|
||||
drb->Base.GetRow = get_row_B8G8R8;
|
||||
drb->Base.GetValues = get_values_B8G8R8;
|
||||
drb->Base.PutRow = put_row_B8G8R8;
|
||||
drb->Base.PutMonoRow = put_mono_row_B8G8R8;
|
||||
drb->Base.PutRowRGB = put_row_rgb_B8G8R8;
|
||||
drb->Base.PutValues = put_values_B8G8R8;
|
||||
drb->Base.PutMonoValues = put_mono_values_B8G8R8;
|
||||
}
|
||||
else if (vis->indexBits == 8) {
|
||||
drb->Base.GetRow = get_row_CI8;
|
||||
drb->Base.GetValues = get_values_CI8;
|
||||
drb->Base.PutRow = put_row_CI8;
|
||||
drb->Base.PutMonoRow = put_mono_row_CI8;
|
||||
drb->Base.PutValues = put_values_CI8;
|
||||
drb->Base.PutMonoValues = put_mono_values_CI8;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* hardware z/stencil/etc someday */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Initialize the driver specific screen private data.
|
||||
*/
|
||||
static GLboolean
|
||||
fbInitDriver( __DRIscreen *sPriv )
|
||||
{
|
||||
sPriv->private = NULL;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
fbDestroyScreen( __DRIscreen *sPriv )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* Create the device specific context.
|
||||
*/
|
||||
static GLboolean
|
||||
fbCreateContext( const __GLcontextModes *glVisual,
|
||||
__DRIcontext *driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
{
|
||||
fbContextPtr fbmesa;
|
||||
GLcontext *ctx, *shareCtx;
|
||||
struct dd_function_table functions;
|
||||
|
||||
assert(glVisual);
|
||||
assert(driContextPriv);
|
||||
|
||||
/* Allocate the Fb context */
|
||||
fbmesa = (fbContextPtr) calloc(1, sizeof(*fbmesa) );
|
||||
if ( !fbmesa )
|
||||
return GL_FALSE;
|
||||
|
||||
/* Init default driver functions then plug in our FBdev-specific functions
|
||||
*/
|
||||
_mesa_init_driver_functions(&functions);
|
||||
init_core_functions(&functions);
|
||||
|
||||
/* Allocate the Mesa context */
|
||||
if (sharedContextPrivate)
|
||||
shareCtx = ((fbContextPtr) sharedContextPrivate)->glCtx;
|
||||
else
|
||||
shareCtx = NULL;
|
||||
|
||||
ctx = fbmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
|
||||
&functions, (void *) fbmesa);
|
||||
if (!fbmesa->glCtx) {
|
||||
free(fbmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
driContextPriv->driverPrivate = fbmesa;
|
||||
|
||||
/* Create module contexts */
|
||||
_swrast_CreateContext( ctx );
|
||||
_vbo_CreateContext( ctx );
|
||||
_tnl_CreateContext( ctx );
|
||||
_swsetup_CreateContext( ctx );
|
||||
_swsetup_Wakeup( ctx );
|
||||
|
||||
|
||||
/* use default TCL pipeline */
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.RunPipeline = _tnl_run_pipeline;
|
||||
}
|
||||
|
||||
_mesa_enable_sw_extensions(ctx);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fbDestroyContext( __DRIcontext *driContextPriv )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
fbContextPtr fbmesa = (fbContextPtr) driContextPriv->driverPrivate;
|
||||
fbContextPtr current = ctx ? FB_CONTEXT(ctx) : NULL;
|
||||
|
||||
/* check if we're deleting the currently bound context */
|
||||
if (fbmesa == current) {
|
||||
_mesa_make_current(NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Free fb context resources */
|
||||
if ( fbmesa ) {
|
||||
_swsetup_DestroyContext( fbmesa->glCtx );
|
||||
_tnl_DestroyContext( fbmesa->glCtx );
|
||||
_vbo_DestroyContext( fbmesa->glCtx );
|
||||
_swrast_DestroyContext( fbmesa->glCtx );
|
||||
|
||||
/* free the Mesa context */
|
||||
fbmesa->glCtx->DriverCtx = NULL;
|
||||
_mesa_destroy_context( fbmesa->glCtx );
|
||||
|
||||
free( fbmesa );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Create and initialize the Mesa and driver specific pixmap buffer
|
||||
* data.
|
||||
*/
|
||||
static GLboolean
|
||||
fbCreateBuffer( __DRIscreen *driScrnPriv,
|
||||
__DRIdrawable *driDrawPriv,
|
||||
const __GLcontextModes *mesaVis,
|
||||
GLboolean isPixmap )
|
||||
{
|
||||
struct gl_framebuffer *mesa_framebuffer;
|
||||
|
||||
if (isPixmap) {
|
||||
return GL_FALSE; /* not implemented */
|
||||
}
|
||||
else {
|
||||
const GLboolean swDepth = mesaVis->depthBits > 0;
|
||||
const GLboolean swAlpha = mesaVis->alphaBits > 0;
|
||||
const GLboolean swAccum = mesaVis->accumRedBits > 0;
|
||||
const GLboolean swStencil = mesaVis->stencilBits > 0;
|
||||
|
||||
mesa_framebuffer = _mesa_create_framebuffer(mesaVis);
|
||||
if (!mesa_framebuffer)
|
||||
return 0;
|
||||
|
||||
/* XXX double-check these parameters (bpp vs cpp, etc) */
|
||||
{
|
||||
driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
|
||||
driScrnPriv->pFB,
|
||||
driScrnPriv->fbBPP / 8,
|
||||
driScrnPriv->fbOrigin,
|
||||
driScrnPriv->fbStride,
|
||||
driDrawPriv);
|
||||
fbSetSpanFunctions(drb, mesaVis);
|
||||
_mesa_add_renderbuffer(mesa_framebuffer,
|
||||
BUFFER_FRONT_LEFT, &drb->Base);
|
||||
}
|
||||
if (mesaVis->doubleBufferMode) {
|
||||
/* XXX what are the correct origin/stride values? */
|
||||
GLvoid *backBuf = malloc(driScrnPriv->fbStride
|
||||
* driScrnPriv->fbHeight);
|
||||
driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
|
||||
backBuf,
|
||||
driScrnPriv->fbBPP /8,
|
||||
driScrnPriv->fbOrigin,
|
||||
driScrnPriv->fbStride,
|
||||
driDrawPriv);
|
||||
fbSetSpanFunctions(drb, mesaVis);
|
||||
_mesa_add_renderbuffer(mesa_framebuffer,
|
||||
BUFFER_BACK_LEFT, &drb->Base);
|
||||
}
|
||||
|
||||
_mesa_add_soft_renderbuffers(mesa_framebuffer,
|
||||
GL_FALSE, /* color */
|
||||
swDepth,
|
||||
swStencil,
|
||||
swAccum,
|
||||
swAlpha, /* or always zero? */
|
||||
GL_FALSE /* aux */);
|
||||
|
||||
driDrawPriv->driverPrivate = mesa_framebuffer;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fbDestroyBuffer(__DRIdrawable *driDrawPriv)
|
||||
{
|
||||
_mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* If the backbuffer is on a videocard, this is extraordinarily slow!
|
||||
*/
|
||||
static void
|
||||
fbSwapBuffers( __DRIdrawable *dPriv )
|
||||
{
|
||||
struct gl_framebuffer *mesa_framebuffer = (struct gl_framebuffer *)dPriv->driverPrivate;
|
||||
struct gl_renderbuffer * front_renderbuffer = mesa_framebuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
|
||||
void *frontBuffer = front_renderbuffer->Data;
|
||||
int currentPitch = ((driRenderbuffer *)front_renderbuffer)->pitch;
|
||||
void *backBuffer = mesa_framebuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer->Data;
|
||||
|
||||
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
|
||||
fbContextPtr fbmesa = (fbContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
GLcontext *ctx = fbmesa->glCtx;
|
||||
|
||||
if (ctx->Visual.doubleBufferMode) {
|
||||
int i;
|
||||
int offset = 0;
|
||||
char *tmp = malloc(currentPitch);
|
||||
|
||||
_mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
|
||||
|
||||
ASSERT(frontBuffer);
|
||||
ASSERT(backBuffer);
|
||||
|
||||
for (i = 0; i < dPriv->h; i++) {
|
||||
memcpy(tmp, (char *) backBuffer + offset, currentPitch);
|
||||
memcpy((char *) frontBuffer + offset, tmp, currentPitch);
|
||||
offset += currentPitch;
|
||||
}
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* XXX this shouldn't be an error but we can't handle it for now */
|
||||
_mesa_problem(NULL, "fbSwapBuffers: drawable has no context!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Force the context `c' to be the current context and associate with it
|
||||
* buffer `b'.
|
||||
*/
|
||||
static GLboolean
|
||||
fbMakeCurrent( __DRIcontext *driContextPriv,
|
||||
__DRIdrawable *driDrawPriv,
|
||||
__DRIdrawable *driReadPriv )
|
||||
{
|
||||
if ( driContextPriv ) {
|
||||
fbContextPtr newFbCtx =
|
||||
(fbContextPtr) driContextPriv->driverPrivate;
|
||||
|
||||
newFbCtx->dri.drawable = driDrawPriv;
|
||||
|
||||
_mesa_make_current( newFbCtx->glCtx,
|
||||
driDrawPriv->driverPrivate,
|
||||
driReadPriv->driverPrivate);
|
||||
} else {
|
||||
_mesa_make_current( NULL, NULL, NULL );
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Force the context `c' to be unbound from its buffer.
|
||||
*/
|
||||
static GLboolean
|
||||
fbUnbindContext( __DRIcontext *driContextPriv )
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static struct __DriverAPIRec fbAPI = {
|
||||
.InitDriver = fbInitDriver,
|
||||
.DestroyScreen = fbDestroyScreen,
|
||||
.CreateContext = fbCreateContext,
|
||||
.DestroyContext = fbDestroyContext,
|
||||
.CreateBuffer = fbCreateBuffer,
|
||||
.DestroyBuffer = fbDestroyBuffer,
|
||||
.SwapBuffers = fbSwapBuffers,
|
||||
.MakeCurrent = fbMakeCurrent,
|
||||
.UnbindContext = fbUnbindContext,
|
||||
};
|
||||
|
||||
|
||||
|
||||
static int
|
||||
__driValidateMode(const DRIDriverContext *ctx )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
__driInitFBDev( struct DRIDriverContextRec *ctx )
|
||||
{
|
||||
/* Note that drmOpen will try to load the kernel module, if needed. */
|
||||
/* we need a fbdev drm driver - it will only track maps */
|
||||
ctx->drmFD = drmOpen("radeon", NULL );
|
||||
if (ctx->drmFD < 0) {
|
||||
fprintf(stderr, "[drm] drmOpen failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx->shared.SAREASize = SAREA_MAX;
|
||||
|
||||
if (drmAddMap( ctx->drmFD,
|
||||
0,
|
||||
ctx->shared.SAREASize,
|
||||
DRM_SHM,
|
||||
DRM_CONTAINS_LOCK,
|
||||
&ctx->shared.hSAREA) < 0)
|
||||
{
|
||||
fprintf(stderr, "[drm] drmAddMap failed\n");
|
||||
return 0;
|
||||
}
|
||||
fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n",
|
||||
ctx->shared.SAREASize,
|
||||
(unsigned long) ctx->shared.hSAREA);
|
||||
|
||||
if (drmMap( ctx->drmFD,
|
||||
ctx->shared.hSAREA,
|
||||
ctx->shared.SAREASize,
|
||||
(drmAddressPtr)(&ctx->pSAREA)) < 0)
|
||||
{
|
||||
fprintf(stderr, "[drm] drmMap failed\n");
|
||||
return 0;
|
||||
}
|
||||
memset(ctx->pSAREA, 0, ctx->shared.SAREASize);
|
||||
fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n",
|
||||
(unsigned long) ctx->shared.hSAREA, ctx->pSAREA,
|
||||
ctx->shared.SAREASize);
|
||||
|
||||
/* Need to AddMap the framebuffer and mmio regions here:
|
||||
*/
|
||||
if (drmAddMap( ctx->drmFD,
|
||||
(drm_handle_t)ctx->FBStart,
|
||||
ctx->FBSize,
|
||||
DRM_FRAME_BUFFER,
|
||||
#ifndef _EMBEDDED
|
||||
0,
|
||||
#else
|
||||
DRM_READ_ONLY,
|
||||
#endif
|
||||
&ctx->shared.hFrameBuffer) < 0)
|
||||
{
|
||||
fprintf(stderr, "[drm] drmAddMap framebuffer failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n",
|
||||
(unsigned long) ctx->shared.hFrameBuffer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
__driHaltFBDev( struct DRIDriverContextRec *ctx )
|
||||
{
|
||||
}
|
||||
|
||||
struct DRIDriverRec __driDriver = {
|
||||
__driValidateMode,
|
||||
__driValidateMode,
|
||||
__driInitFBDev,
|
||||
__driHaltFBDev
|
||||
};
|
||||
|
||||
static __GLcontextModes *
|
||||
fbFillInModes( __DRIscreen *psp,
|
||||
unsigned pixel_bits, unsigned depth_bits,
|
||||
unsigned stencil_bits, GLboolean have_back_buffer )
|
||||
{
|
||||
__GLcontextModes * modes;
|
||||
__GLcontextModes * m;
|
||||
unsigned num_modes;
|
||||
unsigned depth_buffer_factor;
|
||||
unsigned back_buffer_factor;
|
||||
GLenum fb_format;
|
||||
GLenum fb_type;
|
||||
|
||||
/* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
|
||||
* enough to add support. Basically, if a context is created with an
|
||||
* fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
|
||||
* will never be used.
|
||||
*/
|
||||
static const GLenum back_buffer_modes[] = {
|
||||
GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
|
||||
};
|
||||
|
||||
uint8_t depth_bits_array[2];
|
||||
uint8_t stencil_bits_array[2];
|
||||
|
||||
|
||||
depth_bits_array[0] = depth_bits;
|
||||
depth_bits_array[1] = depth_bits;
|
||||
|
||||
/* Just like with the accumulation buffer, always provide some modes
|
||||
* with a stencil buffer. It will be a sw fallback, but some apps won't
|
||||
* care about that.
|
||||
*/
|
||||
stencil_bits_array[0] = 0;
|
||||
stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
|
||||
|
||||
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
|
||||
back_buffer_factor = (have_back_buffer) ? 2 : 1;
|
||||
|
||||
num_modes = depth_buffer_factor * back_buffer_factor * 4;
|
||||
|
||||
if ( pixel_bits == 16 ) {
|
||||
fb_format = GL_RGB;
|
||||
fb_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
}
|
||||
else {
|
||||
fb_format = GL_RGBA;
|
||||
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
modes = (*psp->contextModes->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
|
||||
m = modes;
|
||||
if ( ! driFillInModes( & m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array, depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_TRUE_COLOR ) ) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( ! driFillInModes( & m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array, depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_DIRECT_COLOR ) ) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for ( m = modes ; m != NULL ; m = m->next ) {
|
||||
if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the bootstrap function for the driver. libGL supplies all of the
|
||||
* requisite information about the system, and the driver initializes itself.
|
||||
* This routine also fills in the linked list pointed to by \c driver_modes
|
||||
* with the \c __GLcontextModes that the driver can support for windows or
|
||||
* pbuffers.
|
||||
*
|
||||
* \return A pointer to a \c __DRIscreen on success, or \c NULL on
|
||||
* failure.
|
||||
*/
|
||||
PUBLIC
|
||||
void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
|
||||
const __GLcontextModes * modes,
|
||||
const __DRIversion * ddx_version,
|
||||
const __DRIversion * dri_version,
|
||||
const __DRIversion * drm_version,
|
||||
const __DRIframebuffer * frame_buffer,
|
||||
drmAddress pSAREA, int fd,
|
||||
int internal_api_version,
|
||||
__GLcontextModes ** driver_modes )
|
||||
{
|
||||
__DRIscreen *psp;
|
||||
static const __DRIversion ddx_expected = { 4, 0, 0 };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
static const __DRIversion drm_expected = { 1, 5, 0 };
|
||||
|
||||
|
||||
if ( ! driCheckDriDdxDrmVersions2( "fb",
|
||||
dri_version, & dri_expected,
|
||||
ddx_version, & ddx_expected,
|
||||
drm_version, & drm_expected ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
|
||||
ddx_version, dri_version, drm_version,
|
||||
frame_buffer, pSAREA, fd,
|
||||
internal_api_version, &fbAPI);
|
||||
if ( psp != NULL ) {
|
||||
*driver_modes = fbFillInModes( psp, psp->fbBPP,
|
||||
(psp->fbBPP == 16) ? 16 : 24,
|
||||
(psp->fbBPP == 16) ? 0 : 8,
|
||||
1);
|
||||
}
|
||||
|
||||
return (void *) psp;
|
||||
}
|
||||
|
||||
/* This is the table of extensions that the loader will dlsym() for. */
|
||||
PUBLIC const __DRIextension *__driDriverExtensions[] = {
|
||||
&driCoreExtension.base,
|
||||
&driLegacyExtension.base,
|
||||
NULL
|
||||
};
|
||||
@@ -1,35 +0,0 @@
|
||||
# src/mesa/drivers/dri/ffb/Makefile
|
||||
|
||||
TOP = ../../../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
LIBNAME = ffb_dri.so
|
||||
|
||||
# not yet
|
||||
# MINIGLX_SOURCES = server/ffb_dri.c
|
||||
|
||||
DRIVER_SOURCES = \
|
||||
ffb_bitmap.c \
|
||||
ffb_clear.c \
|
||||
ffb_dd.c \
|
||||
ffb_depth.c \
|
||||
ffb_fog.c \
|
||||
ffb_lines.c \
|
||||
ffb_points.c \
|
||||
ffb_span.c \
|
||||
ffb_state.c \
|
||||
ffb_stencil.c \
|
||||
ffb_tex.c \
|
||||
ffb_tris.c \
|
||||
ffb_vb.c \
|
||||
ffb_xmesa.c
|
||||
|
||||
C_SOURCES = \
|
||||
$(COMMON_SOURCES) \
|
||||
$(DRIVER_SOURCES)
|
||||
|
||||
|
||||
ASM_SOURCES =
|
||||
|
||||
include ../Makefile.template
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_state.h"
|
||||
#include "ffb_lock.h"
|
||||
#include "ffb_bitmap.h"
|
||||
#include "swrast/swrast.h"
|
||||
#include "main/macros.h"
|
||||
|
||||
/* Compute ceiling of integer quotient of A divided by B: */
|
||||
#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
|
||||
|
||||
#undef FFB_BITMAP_TRACE
|
||||
|
||||
static void
|
||||
ffb_bitmap(GLcontext *ctx, GLint px, GLint py,
|
||||
GLsizei width, GLsizei height,
|
||||
const struct gl_pixelstore_attrib *unpack,
|
||||
const GLubyte *bitmap)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
ffb_fbcPtr ffb = fmesa->regs;
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
unsigned int ppc, pixel;
|
||||
GLint row, col, row_stride;
|
||||
const GLubyte *src;
|
||||
char *buf;
|
||||
|
||||
if (fmesa->bad_fragment_attrs != 0)
|
||||
_swrast_Bitmap(ctx, px, py, width,
|
||||
height, unpack, bitmap);
|
||||
|
||||
pixel = (((((GLuint)(ctx->Current.RasterColor[0] * 255.0f)) & 0xff) << 0) |
|
||||
((((GLuint)(ctx->Current.RasterColor[1] * 255.0f)) & 0xff) << 8) |
|
||||
((((GLuint)(ctx->Current.RasterColor[2] * 255.0f)) & 0xff) << 16) |
|
||||
((((GLuint)(ctx->Current.RasterColor[3] * 255.0f)) & 0xff) << 24));
|
||||
|
||||
#ifdef FFB_BITMAP_TRACE
|
||||
fprintf(stderr, "ffb_bitmap: ppc(%08x) fbc(%08x) cmp(%08x) pixel(%08x)\n",
|
||||
fmesa->ppc, fmesa->fbc, fmesa->cmp, pixel);
|
||||
#endif
|
||||
|
||||
LOCK_HARDWARE(fmesa);
|
||||
fmesa->hw_locked = 1;
|
||||
|
||||
if (fmesa->state_dirty)
|
||||
ffbSyncHardware(fmesa);
|
||||
|
||||
ppc = fmesa->ppc;
|
||||
|
||||
FFBFifo(fmesa, 4);
|
||||
ffb->ppc = ((ppc &
|
||||
~(FFB_PPC_TBE_MASK | FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK))
|
||||
| (FFB_PPC_TBE_TRANSPARENT | FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST |
|
||||
(ctx->Color.BlendEnabled ? FFB_PPC_XS_CONST : FFB_PPC_XS_WID)));
|
||||
ffb->constz = ((GLuint) (ctx->Current.RasterPos[2] * 0x0fffffff));
|
||||
ffb->fg = pixel;
|
||||
ffb->fontinc = (0 << 16) | 32;
|
||||
|
||||
buf = (char *)(fmesa->sfb32 + (dPriv->x << 2) + (dPriv->y << 13));
|
||||
|
||||
row_stride = (unpack->Alignment * CEILING(width, 8 * unpack->Alignment));
|
||||
src = (const GLubyte *) (bitmap +
|
||||
(unpack->SkipRows * row_stride) +
|
||||
(unpack->SkipPixels / 8));
|
||||
if (unpack->LsbFirst == GL_TRUE) {
|
||||
for (row = 0; row < height; row++, src += row_stride) {
|
||||
const GLubyte *row_src = src;
|
||||
GLuint base_x, base_y;
|
||||
|
||||
base_x = dPriv->x + px;
|
||||
base_y = dPriv->y + (dPriv->h - (py + row));
|
||||
|
||||
FFBFifo(fmesa, 1);
|
||||
ffb->fontxy = (base_y << 16) | base_x;
|
||||
|
||||
for (col = 0; col < width; col += 32, row_src += 4) {
|
||||
GLint bitnum, font_w = (width - col);
|
||||
GLuint font_data;
|
||||
|
||||
if (font_w > 32)
|
||||
font_w = 32;
|
||||
font_data = 0;
|
||||
for (bitnum = 0; bitnum < 32; bitnum++) {
|
||||
const GLubyte val = row_src[bitnum >> 3];
|
||||
|
||||
if (val & (1 << (bitnum & (8 - 1))))
|
||||
font_data |= (1 << (31 - bitnum));
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 2);
|
||||
ffb->fontw = font_w;
|
||||
ffb->font = font_data;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (row = 0; row < height; row++, src += row_stride) {
|
||||
const GLubyte *row_src = src;
|
||||
GLuint base_x, base_y;
|
||||
|
||||
base_x = dPriv->x + px;
|
||||
base_y = dPriv->y + (dPriv->h - (py + row));
|
||||
|
||||
FFBFifo(fmesa, 1);
|
||||
ffb->fontxy = (base_y << 16) | base_x;
|
||||
|
||||
for (col = 0; col < width; col += 32, row_src += 4) {
|
||||
GLint font_w = (width - col);
|
||||
|
||||
if (font_w > 32)
|
||||
font_w = 32;
|
||||
FFBFifo(fmesa, 2);
|
||||
ffb->fontw = font_w;
|
||||
ffb->font = (((unsigned int)row_src[0]) << 24 |
|
||||
((unsigned int)row_src[1]) << 16 |
|
||||
((unsigned int)row_src[2]) << 8 |
|
||||
((unsigned int)row_src[3]) << 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 1);
|
||||
ffb->ppc = ppc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
fmesa->hw_locked = 0;
|
||||
}
|
||||
|
||||
void ffbDDInitBitmapFuncs(GLcontext *ctx)
|
||||
{
|
||||
ctx->Driver.Bitmap = ffb_bitmap;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
#ifndef _FFB_BITMAP_H
|
||||
#define _FFB_BITMAP_H
|
||||
|
||||
extern void ffbDDInitBitmapFuncs(GLcontext *);
|
||||
|
||||
#endif /* !(_FFB_BITMAP_H) */
|
||||
@@ -1,335 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/mtypes.h"
|
||||
|
||||
#include "main/mm.h"
|
||||
#include "ffb_dd.h"
|
||||
#include "ffb_span.h"
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_vb.h"
|
||||
#include "ffb_clear.h"
|
||||
#include "ffb_lock.h"
|
||||
|
||||
#undef CLEAR_TRACE
|
||||
|
||||
#define BOX_AREA(__w, __h) ((int)(__w) * (int)(__h))
|
||||
|
||||
/* Compute the page aligned box for a page mode fast fill.
|
||||
* In 'ework' this returns greater than zero if there are some odd
|
||||
* edges to take care of which are outside of the page aligned area.
|
||||
* It will place less than zero there if the box is too small,
|
||||
* indicating that a different method must be used to fill it.
|
||||
*/
|
||||
#define CreatorPageFillParms(ffp, x, y, w, h, px, py, pw, ph, ework) \
|
||||
do { int xdiff, ydiff; \
|
||||
int pf_bh = ffp->pagefill_height; \
|
||||
int pf_bw = ffp->pagefill_width; \
|
||||
py = ((y + (pf_bh - 1)) & ~(pf_bh - 1)); \
|
||||
ydiff = py - y; \
|
||||
px = ffp->Pf_AlignTab[x + (pf_bw - 1)]; \
|
||||
xdiff = px - x; \
|
||||
ph = ((h - ydiff) & ~(pf_bh - 1)); \
|
||||
if(ph <= 0) \
|
||||
ework = -1; \
|
||||
else { \
|
||||
pw = ffp->Pf_AlignTab[w - xdiff]; \
|
||||
if(pw <= 0) { \
|
||||
ework = -1; \
|
||||
} else { \
|
||||
ework = (((xdiff > 0) || \
|
||||
(ydiff > 0) || \
|
||||
((w - pw) > 0) || \
|
||||
((h - ph) > 0))) ? 1 : 0; \
|
||||
} \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
struct ff_fixups {
|
||||
int x, y, width, height;
|
||||
};
|
||||
|
||||
/* Compute fixups of non-page aligned areas after a page fill.
|
||||
* Return the number of fixups needed.
|
||||
*/
|
||||
static INLINE int
|
||||
CreatorComputePageFillFixups(struct ff_fixups *fixups,
|
||||
int x, int y, int w, int h,
|
||||
int paligned_x, int paligned_y,
|
||||
int paligned_w, int paligned_h)
|
||||
{
|
||||
int nfixups = 0;
|
||||
|
||||
/* FastFill Left */
|
||||
if(paligned_x != x) {
|
||||
fixups[nfixups].x = x;
|
||||
fixups[nfixups].y = paligned_y;
|
||||
fixups[nfixups].width = paligned_x - x;
|
||||
fixups[nfixups].height = paligned_h;
|
||||
nfixups++;
|
||||
}
|
||||
/* FastFill Top */
|
||||
if(paligned_y != y) {
|
||||
fixups[nfixups].x = x;
|
||||
fixups[nfixups].y = y;
|
||||
fixups[nfixups].width = w;
|
||||
fixups[nfixups].height = paligned_y - y;
|
||||
nfixups++;
|
||||
}
|
||||
/* FastFill Right */
|
||||
if((x+w) != (paligned_x+paligned_w)) {
|
||||
fixups[nfixups].x = (paligned_x+paligned_w);
|
||||
fixups[nfixups].y = paligned_y;
|
||||
fixups[nfixups].width = (x+w) - fixups[nfixups].x;
|
||||
fixups[nfixups].height = paligned_h;
|
||||
nfixups++;
|
||||
}
|
||||
/* FastFill Bottom */
|
||||
if((y+h) != (paligned_y+paligned_h)) {
|
||||
fixups[nfixups].x = x;
|
||||
fixups[nfixups].y = (paligned_y+paligned_h);
|
||||
fixups[nfixups].width = w;
|
||||
fixups[nfixups].height = (y+h) - fixups[nfixups].y;
|
||||
nfixups++;
|
||||
}
|
||||
return nfixups;
|
||||
}
|
||||
|
||||
static void
|
||||
ffb_do_clear(GLcontext *ctx, __DRIdrawable *dPriv)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
FFBDRIPtr gDRIPriv = (FFBDRIPtr) fmesa->driScreen->pDevPriv;
|
||||
ffb_fbcPtr ffb = fmesa->regs;
|
||||
drm_clip_rect_t *box = dPriv->pClipRects;
|
||||
int nc = dPriv->numClipRects;
|
||||
GLint cx, cy, cw, ch;
|
||||
|
||||
/* compute region after locking: */
|
||||
cx = ctx->DrawBuffer->_Xmin;
|
||||
cy = ctx->DrawBuffer->_Ymin;
|
||||
cw = ctx->DrawBuffer->_Xmax - cx;
|
||||
ch = ctx->DrawBuffer->_Ymax - cy;
|
||||
|
||||
cy = dPriv->h - cy - ch;
|
||||
cx += dPriv->x;
|
||||
cy += dPriv->y;
|
||||
|
||||
while (nc--) {
|
||||
GLint x = box[nc].x1;
|
||||
GLint y = box[nc].y1;
|
||||
GLint width = box[nc].x2 - x;
|
||||
GLint height = box[nc].y2 - y;
|
||||
int paligned_y, paligned_x;
|
||||
int paligned_h, paligned_w = 0;
|
||||
int extra_work;
|
||||
|
||||
if (BOX_AREA(width, height) < gDRIPriv->fastfill_small_area) {
|
||||
FFBFifo(fmesa, 5);
|
||||
ffb->drawop = FFB_DRAWOP_RECTANGLE;
|
||||
ffb->by = y;
|
||||
ffb->bx = x;
|
||||
ffb->bh = height;
|
||||
ffb->bw = width;
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 1);
|
||||
ffb->drawop = FFB_DRAWOP_FASTFILL;
|
||||
|
||||
if (gDRIPriv->disable_pagefill ||
|
||||
(width < (gDRIPriv->pagefill_width<<1)) ||
|
||||
(height < (gDRIPriv->pagefill_height<<1)))
|
||||
goto do_fastfill;
|
||||
|
||||
CreatorPageFillParms(gDRIPriv,
|
||||
x, y, width, height,
|
||||
paligned_x, paligned_y,
|
||||
paligned_w, paligned_h, extra_work);
|
||||
|
||||
if (extra_work < 0 ||
|
||||
BOX_AREA(paligned_w, paligned_h) < gDRIPriv->pagefill_small_area) {
|
||||
do_fastfill:
|
||||
FFBFifo(fmesa, 10);
|
||||
ffb->by = FFB_FASTFILL_COLOR_BLK;
|
||||
ffb->dy = 0;
|
||||
ffb->dx = 0;
|
||||
ffb->bh = gDRIPriv->fastfill_height;
|
||||
ffb->bw = (gDRIPriv->fastfill_width * 4);
|
||||
ffb->by = FFB_FASTFILL_BLOCK;
|
||||
ffb->dy = y;
|
||||
ffb->dx = x;
|
||||
ffb->bh = (height + (y & (gDRIPriv->fastfill_height - 1)));
|
||||
ffb->bx = (width + (x & (gDRIPriv->fastfill_width - 1)));
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Ok, page fill is possible and worth it. */
|
||||
FFBFifo(fmesa, 15);
|
||||
ffb->by = FFB_FASTFILL_COLOR_BLK;
|
||||
ffb->dy = 0;
|
||||
ffb->dx = 0;
|
||||
ffb->bh = gDRIPriv->fastfill_height;
|
||||
ffb->bw = gDRIPriv->fastfill_width * 4;
|
||||
ffb->by = FFB_FASTFILL_BLOCK_X;
|
||||
ffb->dy = 0;
|
||||
ffb->dx = 0;
|
||||
ffb->bh = gDRIPriv->pagefill_height;
|
||||
ffb->bw = gDRIPriv->pagefill_width * 4;
|
||||
ffb->by = FFB_FASTFILL_PAGE;
|
||||
ffb->dy = paligned_y;
|
||||
ffb->dx = paligned_x;
|
||||
ffb->bh = paligned_h;
|
||||
ffb->bx = paligned_w;
|
||||
|
||||
if (extra_work) {
|
||||
struct ff_fixups local_fixups[4];
|
||||
int nfixups;
|
||||
|
||||
nfixups = CreatorComputePageFillFixups(local_fixups,
|
||||
x, y, width, height,
|
||||
paligned_x, paligned_y,
|
||||
paligned_w, paligned_h);
|
||||
FFBFifo(fmesa, 5 + (nfixups * 5));
|
||||
ffb->by = FFB_FASTFILL_COLOR_BLK;
|
||||
ffb->dy = 0;
|
||||
ffb->dx = 0;
|
||||
ffb->bh = gDRIPriv->fastfill_height;
|
||||
ffb->bw = gDRIPriv->fastfill_width * 4;
|
||||
|
||||
while (--nfixups >= 0) {
|
||||
int xx, yy, ww, hh;
|
||||
|
||||
xx = local_fixups[nfixups].x;
|
||||
yy = local_fixups[nfixups].y;
|
||||
ffb->dy = yy;
|
||||
ffb->dx = xx;
|
||||
ww = (local_fixups[nfixups].width +
|
||||
(xx & (gDRIPriv->fastfill_width - 1)));
|
||||
hh = (local_fixups[nfixups].height +
|
||||
(yy & (gDRIPriv->fastfill_height - 1)));
|
||||
if (nfixups != 0) {
|
||||
ffb->by = FFB_FASTFILL_BLOCK;
|
||||
ffb->bh = hh;
|
||||
ffb->bw = ww;
|
||||
} else {
|
||||
ffb->bh = hh;
|
||||
ffb->by = FFB_FASTFILL_BLOCK;
|
||||
ffb->bx = ww;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ffbDDClear(GLcontext *ctx, GLbitfield mask)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
unsigned int stcmask = BUFFER_BIT_STENCIL;
|
||||
|
||||
#ifdef CLEAR_TRACE
|
||||
fprintf(stderr, "ffbDDClear: mask(%08x) \n", mask);
|
||||
#endif
|
||||
if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS))
|
||||
stcmask = 0;
|
||||
|
||||
if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH | stcmask)) {
|
||||
ffb_fbcPtr ffb = fmesa->regs;
|
||||
unsigned int fbc, ppc;
|
||||
|
||||
fbc = (FFB_FBC_XE_ON);
|
||||
ppc = (FFB_PPC_ACE_DISABLE | FFB_PPC_DCE_DISABLE |
|
||||
FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_DISABLE |
|
||||
FFB_PPC_APE_DISABLE | FFB_PPC_XS_WID |
|
||||
FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
|
||||
|
||||
/* Y/X enables must be both on or both off. */
|
||||
if (mask & (BUFFER_BIT_DEPTH | stcmask)) {
|
||||
fbc |= (FFB_FBC_ZE_ON | FFB_FBC_YE_ON | FFB_FBC_WB_C);
|
||||
} else
|
||||
fbc |= FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF;
|
||||
|
||||
/* All RGB enables must be both on or both off. */
|
||||
if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) {
|
||||
if (mask & BUFFER_BIT_FRONT_LEFT) {
|
||||
if (fmesa->back_buffer == 0)
|
||||
fbc |= FFB_FBC_WB_B;
|
||||
else
|
||||
fbc |= FFB_FBC_WB_A;
|
||||
}
|
||||
if (mask & BUFFER_BIT_BACK_LEFT) {
|
||||
if (fmesa->back_buffer == 0)
|
||||
fbc |= FFB_FBC_WB_A;
|
||||
else
|
||||
fbc |= FFB_FBC_WB_B;
|
||||
}
|
||||
fbc |= FFB_FBC_RGBE_ON;
|
||||
} else
|
||||
fbc |= FFB_FBC_RGBE_OFF;
|
||||
|
||||
LOCK_HARDWARE(fmesa);
|
||||
|
||||
if (dPriv->numClipRects) {
|
||||
FFBFifo(fmesa, 8);
|
||||
ffb->fbc = fbc;
|
||||
ffb->ppc = ppc;
|
||||
ffb->xclip = FFB_XCLIP_TEST_ALWAYS;
|
||||
ffb->cmp = 0x80808080;
|
||||
ffb->rop = FFB_ROP_NEW;
|
||||
|
||||
if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT))
|
||||
ffb->fg = fmesa->clear_pixel;
|
||||
if (mask & BUFFER_BIT_DEPTH)
|
||||
ffb->constz = fmesa->clear_depth;
|
||||
if (mask & stcmask)
|
||||
ffb->consty = fmesa->clear_stencil;
|
||||
|
||||
ffb_do_clear(ctx, dPriv);
|
||||
|
||||
FFBFifo(fmesa, 6);
|
||||
ffb->ppc = fmesa->ppc;
|
||||
ffb->fbc = fmesa->fbc;
|
||||
ffb->xclip = fmesa->xclip;
|
||||
ffb->cmp = fmesa->cmp;
|
||||
ffb->rop = fmesa->rop;
|
||||
ffb->drawop = fmesa->drawop;
|
||||
if (mask & stcmask)
|
||||
ffb->consty = fmesa->consty;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
|
||||
mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT |
|
||||
BUFFER_BIT_DEPTH | stcmask);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
_swrast_Clear(ctx, mask);
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef _FFB_CLEAR_H
|
||||
#define _FFB_CLEAR_H
|
||||
|
||||
extern void ffbDDClear(GLcontext *ctx, GLbitfield mask);
|
||||
|
||||
#endif /* !(_FFB_CLEAR_H) */
|
||||
@@ -1,305 +0,0 @@
|
||||
|
||||
#ifndef _FFB_CONTEXT_H
|
||||
#define _FFB_CONTEXT_H
|
||||
|
||||
#include "dri_util.h"
|
||||
#include "drm.h"
|
||||
|
||||
#include "main/mtypes.h"
|
||||
|
||||
#include "ffb_xmesa.h"
|
||||
|
||||
typedef struct {
|
||||
GLfloat alpha;
|
||||
GLfloat red;
|
||||
GLfloat green;
|
||||
GLfloat blue;
|
||||
} ffb_color;
|
||||
|
||||
#define FFB_GET_ALPHA(VTX) \
|
||||
FFB_COLOR_FROM_FLOAT((VTX)->color[0].alpha)
|
||||
#define FFB_GET_RED(VTX) \
|
||||
FFB_COLOR_FROM_FLOAT((VTX)->color[0].red)
|
||||
#define FFB_GET_GREEN(VTX) \
|
||||
FFB_COLOR_FROM_FLOAT((VTX)->color[0].green)
|
||||
#define FFB_GET_BLUE(VTX) \
|
||||
FFB_COLOR_FROM_FLOAT((VTX)->color[0].blue)
|
||||
|
||||
typedef struct {
|
||||
GLfloat x, y, z;
|
||||
ffb_color color[2];
|
||||
} ffb_vertex;
|
||||
|
||||
#define FFB_DELAYED_VIEWPORT_VARS \
|
||||
GLfloat VP_SX = fmesa->hw_viewport[MAT_SX]; \
|
||||
GLfloat VP_TX = fmesa->hw_viewport[MAT_TX]; \
|
||||
GLfloat VP_SY = fmesa->hw_viewport[MAT_SY]; \
|
||||
GLfloat VP_TY = fmesa->hw_viewport[MAT_TY]; \
|
||||
GLfloat VP_SZ = fmesa->hw_viewport[MAT_SZ]; \
|
||||
GLfloat VP_TZ = fmesa->hw_viewport[MAT_TZ]; \
|
||||
(void) VP_SX; (void) VP_SY; (void) VP_SZ; \
|
||||
(void) VP_TX; (void) VP_TY; (void) VP_TZ
|
||||
|
||||
#define FFB_GET_Z(VTX) \
|
||||
FFB_Z_FROM_FLOAT(VP_SZ * (VTX)->z + VP_TZ)
|
||||
#define FFB_GET_Y(VTX) \
|
||||
FFB_XY_FROM_FLOAT(VP_SY * (VTX)->y + VP_TY)
|
||||
#define FFB_GET_X(VTX) \
|
||||
FFB_XY_FROM_FLOAT(VP_SX * (VTX)->x + VP_TX)
|
||||
|
||||
typedef void (*ffb_point_func)(GLcontext *, ffb_vertex *);
|
||||
typedef void (*ffb_line_func)(GLcontext *, ffb_vertex *, ffb_vertex *);
|
||||
typedef void (*ffb_tri_func)(GLcontext *, ffb_vertex *, ffb_vertex *,
|
||||
ffb_vertex *);
|
||||
typedef void (*ffb_quad_func)(GLcontext *, ffb_vertex *, ffb_vertex *,
|
||||
ffb_vertex *, ffb_vertex *);
|
||||
|
||||
/* Immediate mode fast-path support. */
|
||||
typedef struct {
|
||||
GLfloat obj[4];
|
||||
GLfloat normal[4];
|
||||
GLfloat clip[4];
|
||||
GLuint mask;
|
||||
GLfloat color[4];
|
||||
GLfloat win[4];
|
||||
GLfloat eye[4];
|
||||
} ffbTnlVertex, *ffbTnlVertexPtr;
|
||||
|
||||
typedef void (*ffb_interp_func)(GLfloat t,
|
||||
ffbTnlVertex *O,
|
||||
const ffbTnlVertex *I,
|
||||
const ffbTnlVertex *J);
|
||||
|
||||
struct ffb_current_state {
|
||||
GLfloat color[4];
|
||||
GLfloat normal[4];
|
||||
GLfloat specular[4];
|
||||
};
|
||||
|
||||
struct ffb_light_state {
|
||||
GLfloat base_color[3];
|
||||
GLfloat base_alpha;
|
||||
};
|
||||
|
||||
struct ffb_vertex_state {
|
||||
struct ffb_current_state current;
|
||||
struct ffb_light_state light;
|
||||
};
|
||||
|
||||
struct ffb_imm_vertex {
|
||||
ffbTnlVertex vertices[8];
|
||||
ffbTnlVertex *v0;
|
||||
ffbTnlVertex *v1;
|
||||
ffbTnlVertex *v2;
|
||||
ffbTnlVertex *v3;
|
||||
|
||||
void (*save_vertex)(GLcontext *ctx, ffbTnlVertex *v);
|
||||
void (*flush_vertex)(GLcontext *ctx, ffbTnlVertex *v);
|
||||
|
||||
ffb_interp_func interp;
|
||||
|
||||
GLuint prim, format;
|
||||
|
||||
GLvertexformat vtxfmt;
|
||||
};
|
||||
|
||||
typedef struct ffb_context_t {
|
||||
GLcontext *glCtx;
|
||||
GLframebuffer *glBuffer;
|
||||
|
||||
ffb_fbcPtr regs;
|
||||
volatile char *sfb32;
|
||||
|
||||
int hw_locked;
|
||||
|
||||
int back_buffer; /* 0 = bufferA, 1 = bufferB */
|
||||
|
||||
/* Viewport matrix. */
|
||||
GLfloat hw_viewport[16];
|
||||
#define SUBPIXEL_X (-0.5F)
|
||||
#define SUBPIXEL_Y (-0.5F + 0.125)
|
||||
|
||||
/* Vertices in driver format. */
|
||||
ffb_vertex *verts;
|
||||
|
||||
/* Rasterization functions. */
|
||||
ffb_point_func draw_point;
|
||||
ffb_line_func draw_line;
|
||||
ffb_tri_func draw_tri;
|
||||
ffb_quad_func draw_quad;
|
||||
|
||||
GLenum raster_primitive;
|
||||
GLenum render_primitive;
|
||||
|
||||
GLfloat backface_sign;
|
||||
GLfloat depth_scale;
|
||||
|
||||
GLfloat ffb_2_30_fixed_scale;
|
||||
GLfloat ffb_one_over_2_30_fixed_scale;
|
||||
GLfloat ffb_16_16_fixed_scale;
|
||||
GLfloat ffb_one_over_16_16_fixed_scale;
|
||||
GLfloat ffb_ubyte_color_scale;
|
||||
GLfloat ffb_zero;
|
||||
|
||||
/* Immediate mode state. */
|
||||
struct ffb_vertex_state vtx_state;
|
||||
struct ffb_imm_vertex imm;
|
||||
|
||||
/* Debugging knobs. */
|
||||
GLboolean debugFallbacks;
|
||||
|
||||
/* This records state bits when a per-fragment attribute has
|
||||
* been set which prevents us from rendering in hardware.
|
||||
*
|
||||
* As attributes change, some of these bits may clear as
|
||||
* we move back within the chips capabilities. If they
|
||||
* all clear, we return to full hw rendering.
|
||||
*/
|
||||
unsigned int bad_fragment_attrs;
|
||||
#define FFB_BADATTR_FOG 0x00000001 /* Bad fog possible only when < FFB2 */
|
||||
#define FFB_BADATTR_BLENDFUNC 0x00000002 /* Any non-const func based upon dst alpha */
|
||||
#define FFB_BADATTR_BLENDROP 0x00000004 /* Blend enabled and LogicOP != GL_COPY */
|
||||
#define FFB_BADATTR_BLENDEQN 0x00000008 /* Blend equation other than ADD */
|
||||
#define FFB_BADATTR_STENCIL 0x00000010 /* Stencil enabled when < FFB2+ */
|
||||
#define FFB_BADATTR_TEXTURE 0x00000020 /* Texture enabled */
|
||||
#define FFB_BADATTR_SWONLY 0x00000040 /* Environment var set */
|
||||
|
||||
unsigned int state_dirty;
|
||||
unsigned int state_fifo_ents;
|
||||
#define FFB_STATE_FBC 0x00000001
|
||||
#define FFB_STATE_PPC 0x00000002
|
||||
#define FFB_STATE_DRAWOP 0x00000004
|
||||
#define FFB_STATE_ROP 0x00000008
|
||||
#define FFB_STATE_LPAT 0x00000010
|
||||
#define FFB_STATE_PMASK 0x00000020
|
||||
#define FFB_STATE_XPMASK 0x00000040
|
||||
#define FFB_STATE_YPMASK 0x00000080
|
||||
#define FFB_STATE_ZPMASK 0x00000100
|
||||
#define FFB_STATE_XCLIP 0x00000200
|
||||
#define FFB_STATE_CMP 0x00000400
|
||||
#define FFB_STATE_MATCHAB 0x00000800
|
||||
#define FFB_STATE_MAGNAB 0x00001000
|
||||
#define FFB_STATE_MATCHC 0x00002000
|
||||
#define FFB_STATE_MAGNC 0x00004000
|
||||
#define FFB_STATE_DCUE 0x00008000
|
||||
#define FFB_STATE_BLEND 0x00010000
|
||||
#define FFB_STATE_CLIP 0x00020000
|
||||
#define FFB_STATE_STENCIL 0x00040000
|
||||
#define FFB_STATE_APAT 0x00080000
|
||||
#define FFB_STATE_WID 0x00100000
|
||||
#define FFB_STATE_ALL 0x001fffff
|
||||
|
||||
unsigned int state_all_fifo_ents;
|
||||
|
||||
#define FFB_MAKE_DIRTY(FMESA, STATE_MASK, FIFO_ENTS) \
|
||||
do { if ((STATE_MASK) & ~((FMESA)->state_dirty)) { \
|
||||
(FMESA)->state_dirty |= (STATE_MASK); \
|
||||
(FMESA)->state_fifo_ents += FIFO_ENTS; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* General hw reg state. */
|
||||
unsigned int fbc;
|
||||
unsigned int ppc;
|
||||
unsigned int drawop;
|
||||
unsigned int rop;
|
||||
|
||||
unsigned int lpat;
|
||||
#define FFB_LPAT_BAD 0xffffffff
|
||||
|
||||
unsigned int wid;
|
||||
unsigned int pmask;
|
||||
unsigned int xpmask;
|
||||
unsigned int ypmask;
|
||||
unsigned int zpmask;
|
||||
unsigned int xclip;
|
||||
unsigned int cmp;
|
||||
unsigned int matchab;
|
||||
unsigned int magnab;
|
||||
unsigned int matchc;
|
||||
unsigned int magnc;
|
||||
|
||||
/* Depth cue unit hw reg state. */
|
||||
unsigned int dcss; /* All FFB */
|
||||
unsigned int dcsf; /* All FFB */
|
||||
unsigned int dcsb; /* All FFB */
|
||||
unsigned int dczf; /* All FFB */
|
||||
unsigned int dczb; /* All FFB */
|
||||
unsigned int dcss1; /* >=FFB2 only */
|
||||
unsigned int dcss2; /* >=FFB2 only */
|
||||
unsigned int dcss3; /* >=FFB2 only */
|
||||
unsigned int dcs2; /* >=FFB2 only */
|
||||
unsigned int dcs3; /* >=FFB2 only */
|
||||
unsigned int dcs4; /* >=FFB2 only */
|
||||
unsigned int dcd2; /* >=FFB2 only */
|
||||
unsigned int dcd3; /* >=FFB2 only */
|
||||
unsigned int dcd4; /* >=FFB2 only */
|
||||
|
||||
/* Blend unit hw reg state. */
|
||||
unsigned int blendc;
|
||||
unsigned int blendc1;
|
||||
unsigned int blendc2;
|
||||
|
||||
/* ViewPort clipping hw reg state. */
|
||||
unsigned int vclipmin;
|
||||
unsigned int vclipmax;
|
||||
unsigned int vclipzmin;
|
||||
unsigned int vclipzmax;
|
||||
struct {
|
||||
unsigned int min;
|
||||
unsigned int max;
|
||||
} aux_clips[4];
|
||||
|
||||
/* Stencil control hw reg state. >=FFB2+ only. */
|
||||
unsigned int stencil;
|
||||
unsigned int stencilctl;
|
||||
unsigned int consty; /* Stencil Ref */
|
||||
|
||||
/* Area pattern (used for polygon stipples). */
|
||||
unsigned int pattern[32];
|
||||
|
||||
/* Fog state. */
|
||||
float Znear, Zfar;
|
||||
|
||||
drm_context_t hHWContext;
|
||||
drm_hw_lock_t *driHwLock;
|
||||
int driFd;
|
||||
|
||||
unsigned int clear_pixel;
|
||||
unsigned int clear_depth;
|
||||
unsigned int clear_stencil;
|
||||
|
||||
unsigned int setupindex;
|
||||
unsigned int setupnewinputs;
|
||||
unsigned int new_gl_state;
|
||||
|
||||
__DRIdrawable *driDrawable;
|
||||
__DRIscreen *driScreen;
|
||||
ffbScreenPrivate *ffbScreen;
|
||||
ffb_dri_state_t *ffb_sarea;
|
||||
} ffbContextRec, *ffbContextPtr;
|
||||
|
||||
#define FFB_CONTEXT(ctx) ((ffbContextPtr)((ctx)->DriverCtx))
|
||||
|
||||
/* We want the depth values written during software rendering
|
||||
* to match what the hardware is going to put there when we
|
||||
* hw render.
|
||||
*
|
||||
* The Z buffer is 28 bits deep. Smooth shaded primitives
|
||||
* specify a 2:30 signed fixed point Z value in the range 0.0
|
||||
* to 1.0 inclusive.
|
||||
*
|
||||
* So for example, when hw rendering, the largest Z value of
|
||||
* 1.0 would produce a value of 0x0fffffff in the actual Z
|
||||
* buffer, which is the maximum value.
|
||||
*
|
||||
* Mesa's depth type is a 32-bit uint, so we use the following macro
|
||||
* to convert to/from FFB hw Z values. Note we also have to clear
|
||||
* out the top bits as that is where the Y (stencil) buffer is stored
|
||||
* and during hw Z buffer reads it is always there. (During writes
|
||||
* we tell the hw to discard those top 4 bits).
|
||||
*/
|
||||
#define Z_TO_MESA(VAL) ((GLuint)(((VAL) & 0x0fffffff) << (32 - 28)))
|
||||
#define Z_FROM_MESA(VAL) (((GLuint)((GLdouble)(VAL))) >> (32 - 28))
|
||||
|
||||
#endif /* !(_FFB_CONTEXT_H) */
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000, 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/mtypes.h"
|
||||
#include "main/mm.h"
|
||||
#include "ffb_dd.h"
|
||||
#include "ffb_span.h"
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_clear.h"
|
||||
#include "ffb_lock.h"
|
||||
|
||||
#define FFB_DATE "20021125"
|
||||
|
||||
PUBLIC const char __driConfigOptions[] = { 0 };
|
||||
const GLuint __driNConfigOptions = 0;
|
||||
|
||||
/* Mesa's Driver Functions */
|
||||
|
||||
static const GLubyte *ffbDDGetString(GLcontext *ctx, GLenum name)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
static char buffer[128];
|
||||
|
||||
switch (name) {
|
||||
case GL_VENDOR:
|
||||
return (GLubyte *) "David S. Miller";
|
||||
|
||||
case GL_RENDERER:
|
||||
sprintf(buffer, "Mesa DRI FFB " FFB_DATE);
|
||||
|
||||
if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2)
|
||||
strncat(buffer, " FFB2", 5);
|
||||
if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)
|
||||
strncat(buffer, " FFB2PLUS", 9);
|
||||
if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1)
|
||||
strncat(buffer, " PAC1", 5);
|
||||
if (fmesa->ffb_sarea->flags & FFB_DRI_PAC2)
|
||||
strncat(buffer, " PAC2", 5);
|
||||
|
||||
#ifdef USE_SPARC_ASM
|
||||
strncat(buffer, " Sparc", 6);
|
||||
#endif
|
||||
|
||||
return (GLubyte *) buffer;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
static void ffbBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
LOCK_HARDWARE(fmesa);
|
||||
*width = fmesa->driDrawable->w;
|
||||
*height = fmesa->driDrawable->h;
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
|
||||
void ffbDDExtensionsInit(GLcontext *ctx)
|
||||
{
|
||||
/* Nothing for now until we start to add
|
||||
* real acceleration. -DaveM
|
||||
*/
|
||||
|
||||
/* XXX Need to turn off GL_EXT_blend_func_separate for one.
|
||||
* XXX Also BlendEquation should be turned off too, what
|
||||
* XXX EXT is that assosciated with?
|
||||
*/
|
||||
}
|
||||
|
||||
static void ffbDDFinish(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
LOCK_HARDWARE(fmesa);
|
||||
FFBWait(fmesa, fmesa->regs);
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
|
||||
void ffbDDInitDriverFuncs(GLcontext *ctx)
|
||||
{
|
||||
ctx->Driver.GetBufferSize = ffbBufferSize;
|
||||
ctx->Driver.GetString = ffbDDGetString;
|
||||
ctx->Driver.Clear = ffbDDClear;
|
||||
|
||||
ctx->Driver.Finish = ffbDDFinish;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D.
|
||||
* Copyright (C) 2000 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef _FFB_DD_H
|
||||
#define _FFB_DD_H
|
||||
|
||||
#include "main/context.h"
|
||||
|
||||
void ffbDDInitDriverFuncs(GLcontext *ctx);
|
||||
void ffbDDExtensionsInit(GLcontext *ctx);
|
||||
|
||||
#endif /* !(_FFB_DD_H) */
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/mtypes.h"
|
||||
#include "ffb_dd.h"
|
||||
#include "ffb_span.h"
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_depth.h"
|
||||
#include "ffb_lock.h"
|
||||
|
||||
|
||||
#undef DEPTH_TRACE
|
||||
|
||||
static void FFBWriteDepthSpan( GLcontext *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y,
|
||||
const void *values,
|
||||
const GLubyte mask[] )
|
||||
{
|
||||
const GLuint *depth = (const GLuint *) values;
|
||||
#ifdef DEPTH_TRACE
|
||||
fprintf(stderr, "FFBWriteDepthSpan: n(%d) x(%d) y(%d)\n",
|
||||
(int) n, x, y);
|
||||
#endif
|
||||
if (ctx->Depth.Mask) {
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
GLuint *zptr;
|
||||
GLuint i;
|
||||
|
||||
if (!fmesa->hw_locked)
|
||||
LOCK_HARDWARE(fmesa);
|
||||
FFBFifo(fmesa, 2);
|
||||
fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_ON |
|
||||
FFB_FBC_YE_OFF | FFB_FBC_RGBE_OFF);
|
||||
fmesa->regs->ppc = FFB_PPC_ZS_VAR;
|
||||
FFBWait(fmesa, fmesa->regs);
|
||||
|
||||
y = (dPriv->h - y);
|
||||
zptr = (GLuint *)
|
||||
((char *)fmesa->sfb32 +
|
||||
((dPriv->x + x) << 2) +
|
||||
((dPriv->y + y) << 13));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (mask[i]) {
|
||||
*zptr = Z_FROM_MESA(depth[i]);
|
||||
}
|
||||
zptr++;
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 2);
|
||||
fmesa->regs->fbc = fmesa->fbc;
|
||||
fmesa->regs->ppc = fmesa->ppc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
if (!fmesa->hw_locked)
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
}
|
||||
|
||||
static void FFBWriteMonoDepthSpan( GLcontext *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y,
|
||||
const void *value, const GLubyte mask[] )
|
||||
{
|
||||
const GLuint depthVal = *((GLuint *) value);
|
||||
GLuint depths[MAX_WIDTH];
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++)
|
||||
depths[i] = depthVal;
|
||||
FFBWriteDepthSpan(ctx, rb, n, x, y, depths, mask);
|
||||
}
|
||||
|
||||
static void FFBWriteDepthPixels( GLcontext *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n,
|
||||
const GLint x[],
|
||||
const GLint y[],
|
||||
const void *values,
|
||||
const GLubyte mask[] )
|
||||
{
|
||||
const GLuint *depth = (const GLuint *) values;
|
||||
#ifdef DEPTH_TRACE
|
||||
fprintf(stderr, "FFBWriteDepthPixels: n(%d)\n", (int) n);
|
||||
#endif
|
||||
if (ctx->Depth.Mask) {
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
char *zbase;
|
||||
GLuint i;
|
||||
|
||||
if (!fmesa->hw_locked)
|
||||
LOCK_HARDWARE(fmesa);
|
||||
FFBFifo(fmesa, 2);
|
||||
fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_ON |
|
||||
FFB_FBC_YE_OFF | FFB_FBC_RGBE_OFF);
|
||||
fmesa->regs->ppc = FFB_PPC_ZS_VAR;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
FFBWait(fmesa, fmesa->regs);
|
||||
|
||||
zbase = ((char *)fmesa->sfb32 +
|
||||
(dPriv->x << 2) + (dPriv->y << 13));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
GLint y1 = (dPriv->h - y[i]);
|
||||
GLint x1 = x[i];
|
||||
GLuint *zptr;
|
||||
|
||||
zptr = (GLuint *)
|
||||
(zbase + (x1 << 2) + (y1 << 13));
|
||||
if (mask[i])
|
||||
*zptr = Z_FROM_MESA(depth[i]);
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 2);
|
||||
fmesa->regs->fbc = fmesa->fbc;
|
||||
fmesa->regs->ppc = fmesa->ppc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
if (!fmesa->hw_locked)
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
}
|
||||
|
||||
static void FFBReadDepthSpan( GLcontext *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y,
|
||||
void *values )
|
||||
{
|
||||
GLuint *depth = (GLuint *) values;
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
GLuint *zptr;
|
||||
GLuint i;
|
||||
|
||||
#ifdef DEPTH_TRACE
|
||||
fprintf(stderr, "FFBReadDepthSpan: n(%d) x(%d) y(%d)\n",
|
||||
(int) n, x, y);
|
||||
#endif
|
||||
if (!fmesa->hw_locked)
|
||||
LOCK_HARDWARE(fmesa);
|
||||
FFBFifo(fmesa, 1);
|
||||
fmesa->regs->fbc = FFB_FBC_RB_C;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
FFBWait(fmesa, fmesa->regs);
|
||||
|
||||
y = (dPriv->h - y);
|
||||
zptr = (GLuint *)
|
||||
((char *)fmesa->sfb32 +
|
||||
((dPriv->x + x) << 2) +
|
||||
((dPriv->y + y) << 13));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
depth[i] = Z_TO_MESA(*zptr);
|
||||
zptr++;
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 1);
|
||||
fmesa->regs->fbc = fmesa->fbc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
if (!fmesa->hw_locked)
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
|
||||
static void FFBReadDepthPixels( GLcontext *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
void *values )
|
||||
{
|
||||
GLuint *depth = (GLuint *) values;
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
char *zbase;
|
||||
GLuint i;
|
||||
|
||||
#ifdef DEPTH_TRACE
|
||||
fprintf(stderr, "FFBReadDepthPixels: n(%d)\n", (int) n);
|
||||
#endif
|
||||
if (!fmesa->hw_locked)
|
||||
LOCK_HARDWARE(fmesa);
|
||||
FFBFifo(fmesa, 1);
|
||||
fmesa->regs->fbc = FFB_FBC_RB_C;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
FFBWait(fmesa, fmesa->regs);
|
||||
|
||||
zbase = ((char *)fmesa->sfb32 +
|
||||
(dPriv->x << 2) + (dPriv->y << 13));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
GLint y1 = (dPriv->h - y[i]);
|
||||
GLint x1 = x[i];
|
||||
GLuint *zptr;
|
||||
|
||||
zptr = (GLuint *)
|
||||
(zbase + (x1 << 2) + (y1 << 13));
|
||||
depth[i] = Z_TO_MESA(*zptr);
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 1);
|
||||
fmesa->regs->fbc = fmesa->fbc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
if (!fmesa->hw_locked)
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plug in the Get/Put routines for the given driRenderbuffer.
|
||||
*/
|
||||
void
|
||||
ffbSetDepthFunctions(driRenderbuffer *drb, const GLvisual *vis)
|
||||
{
|
||||
assert(drb->Base.InternalFormat == GL_DEPTH_COMPONENT16);
|
||||
drb->Base.GetRow = FFBReadDepthSpan;
|
||||
drb->Base.GetValues = FFBReadDepthPixels;
|
||||
drb->Base.PutRow = FFBWriteDepthSpan;
|
||||
drb->Base.PutMonoRow = FFBWriteMonoDepthSpan;
|
||||
drb->Base.PutValues = FFBWriteDepthPixels;
|
||||
drb->Base.PutMonoValues = NULL;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
#ifndef _FFB_DEPTH_H
|
||||
#define _FFB_DEPTH_H
|
||||
|
||||
void ffbSetDepthFunctions(driRenderbuffer *drb, const GLvisual *vis);
|
||||
|
||||
#endif /* !(_FFB_DEPTH_H) */
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
#ifndef _FFB_FIFO_H
|
||||
#define _FFB_FIFO_H
|
||||
|
||||
#define FFBFifo(__fmesa, __n) \
|
||||
do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \
|
||||
int __cur_slots = __fScrn->fifo_cache; \
|
||||
if ((__cur_slots - (__n)) < 0) { \
|
||||
ffb_fbcPtr __ffb = __fmesa->regs; \
|
||||
do { __cur_slots = (((int)__ffb->ucsr & FFB_UCSR_FIFO_MASK) - 4); \
|
||||
} while ((__cur_slots - (__n)) < 0); \
|
||||
} (__fScrn)->fifo_cache = (__cur_slots - (__n)); \
|
||||
} while(0)
|
||||
|
||||
#define FFBWait(__fmesa, __ffb) \
|
||||
do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \
|
||||
if (__fScrn->rp_active) { \
|
||||
unsigned int __regval = (__ffb)->ucsr; \
|
||||
while((__regval & FFB_UCSR_ALL_BUSY) != 0) { \
|
||||
__regval = (__ffb)->ucsr; \
|
||||
} \
|
||||
__fScrn->fifo_cache = ((int)(__regval & FFB_UCSR_FIFO_MASK)) - 4; \
|
||||
__fScrn->rp_active = 0; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#endif /* !(_FFB_FIFO_H) */
|
||||
@@ -1,73 +0,0 @@
|
||||
|
||||
/* FFB fog support:
|
||||
*
|
||||
* There are two levels of support for FOG in the Creator3D series.
|
||||
* Both involve a depth cue unit and 1 or 4 slope factors and scales
|
||||
* for varying the pixel intensity.
|
||||
*
|
||||
* Chips prior to FFB2 only have a single set of such settings, FFB2
|
||||
* and later have 4 settings.
|
||||
*
|
||||
* The basic depth cueing equation is:
|
||||
*
|
||||
* C_final = dcsf(z) * C_orig + (1 - dcsf(z)) * C_fog
|
||||
*
|
||||
* C_final -- The final color passed to blend unit or frame
|
||||
* buffer (if blending is disabled).
|
||||
*
|
||||
* C_orig -- The color we start with, which comes either from
|
||||
* the raster processor or cpu writes to the smart
|
||||
* framebuffer aperture.
|
||||
*
|
||||
* C_fog -- This is the "fog" color, ie. the desired color
|
||||
* at the deepest Z.
|
||||
*
|
||||
* dcsf(z) -- The depth cue scale as a function of Z.
|
||||
*
|
||||
* With pre-FFB2 chips there are four parameters to control the depth
|
||||
* cue scaling. Here is a diagram:
|
||||
*
|
||||
* 1.0 -------------
|
||||
* | | | |
|
||||
* | | | |
|
||||
* Sfront XXXXX---+---+
|
||||
* | |X | |
|
||||
* dcsf(z) | | X | |
|
||||
* | | X| |
|
||||
* Sback +---+---XXXXX
|
||||
* | | | |
|
||||
* 0.0 -------------
|
||||
* 0.0 Zf Zb 1.0
|
||||
*
|
||||
* z
|
||||
* Therefore:
|
||||
*
|
||||
* for Zf < z < Zb
|
||||
*
|
||||
* dcsf(z) = Sback + ((Sfront - Sback) / (Zf - Zb)) * (Zb - z)
|
||||
*
|
||||
* for z <= Zf
|
||||
*
|
||||
* dcsf(z) = Sfront
|
||||
*
|
||||
* for z >= Zb
|
||||
*
|
||||
* dcsf(z) = Sback
|
||||
*
|
||||
* With FFB2 and later, 3 more slope regions are provided, the first of
|
||||
* them starts at the end of the region defined above and ends at a
|
||||
* specified depth value, the next slop region starts there and ends
|
||||
* at the next specified depth value, and so on. Each of the 3 slope
|
||||
* regions also have scale and slope settings of their own.
|
||||
*
|
||||
* The C_fog color is programmed into the alpha blending unit color1
|
||||
* and color2 registers as follows:
|
||||
*
|
||||
* color1: -(C_fog)
|
||||
* color2: C_fog - bg
|
||||
*
|
||||
* If alpha blending is disabled, the bg factor is zero. Note that
|
||||
* the alpha blending color registers specify each of the RGB values
|
||||
* as 9 bit 1:8 signed numbers in the range -1.00 to 0.ff inclusive.
|
||||
* (ie. 0x100 == -1.00 and 0x0ff == +0.ff)
|
||||
*/
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000, 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/mtypes.h"
|
||||
#include "main/mm.h"
|
||||
#include "ffb_dd.h"
|
||||
#include "ffb_span.h"
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_vb.h"
|
||||
#include "ffb_lines.h"
|
||||
|
||||
#undef FFB_LINE_TRACE
|
||||
|
||||
#define FFB_LINE_FLAT_BIT 0x01
|
||||
#define FFB_LINE_ALPHA_BIT 0x02
|
||||
#define MAX_FFB_LINE_FUNCS 0x04
|
||||
|
||||
static ffb_line_func ffb_line_tab[MAX_FFB_LINE_FUNCS];
|
||||
|
||||
/* If the line is not wide, we can support all of the line
|
||||
* patterning and smooth shading features of OpenGL fully.
|
||||
*/
|
||||
|
||||
#define IND (0)
|
||||
#define TAG(x) x
|
||||
#include "ffb_linetmp.h"
|
||||
|
||||
#define IND (FFB_LINE_FLAT_BIT)
|
||||
#define TAG(x) x##_flat
|
||||
#include "ffb_linetmp.h"
|
||||
|
||||
#define IND (FFB_LINE_ALPHA_BIT)
|
||||
#define TAG(x) x##_alpha
|
||||
#include "ffb_linetmp.h"
|
||||
|
||||
#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_FLAT_BIT)
|
||||
#define TAG(x) x##_alpha_flat
|
||||
#include "ffb_linetmp.h"
|
||||
|
||||
void ffbDDLinefuncInit(void)
|
||||
{
|
||||
init();
|
||||
init_flat();
|
||||
init_alpha();
|
||||
init_alpha_flat();
|
||||
}
|
||||
|
||||
static void ffb_dd_line( GLcontext *ctx, GLuint e0, GLuint e1 )
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
ffb_vertex *v0 = &fmesa->verts[e0];
|
||||
ffb_vertex *v1 = &fmesa->verts[e1];
|
||||
fmesa->draw_line( ctx, v0, v1 );
|
||||
}
|
||||
|
||||
void ffbChooseLineState(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
GLuint ind = 0;
|
||||
|
||||
tnl->Driver.Render.Line = ffb_dd_line;
|
||||
|
||||
if (flags & DD_FLATSHADE)
|
||||
ind |= FFB_LINE_FLAT_BIT;
|
||||
|
||||
if ((flags & DD_LINE_STIPPLE) != 0 &&
|
||||
fmesa->lpat == FFB_LPAT_BAD) {
|
||||
fmesa->draw_line = ffb_fallback_line;
|
||||
return;
|
||||
}
|
||||
|
||||
/* If blending or the alpha test is enabled we need to
|
||||
* provide alpha components to the chip, else we can
|
||||
* do without it and thus feed vertex data to the chip
|
||||
* more efficiently.
|
||||
*/
|
||||
if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
|
||||
ind |= FFB_LINE_ALPHA_BIT;
|
||||
|
||||
fmesa->draw_line = ffb_line_tab[ind];
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
#ifndef _FFB_LINES_H
|
||||
#define _FFB_LINES_H
|
||||
|
||||
#include "ffb_context.h"
|
||||
|
||||
#define _FFB_NEW_LINE (_DD_NEW_FLATSHADE | \
|
||||
_DD_NEW_LINE_WIDTH | \
|
||||
_DD_NEW_LINE_STIPPLE | \
|
||||
_DD_NEW_LINE_SMOOTH | \
|
||||
_NEW_COLOR)
|
||||
|
||||
extern void ffbDDLinefuncInit(void);
|
||||
extern void ffbChooseLineState(GLcontext *);
|
||||
extern void ffb_fallback_line( GLcontext *ctx, ffb_vertex *v0, ffb_vertex *v1 );
|
||||
|
||||
#endif /* !(_FFB_LINES_H) */
|
||||
@@ -1,80 +0,0 @@
|
||||
|
||||
static INLINE void TAG(ffb_line)(GLcontext *ctx, ffb_vertex *v0,
|
||||
ffb_vertex *v1 )
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
ffb_fbcPtr ffb = fmesa->regs;
|
||||
#if (IND & FFB_LINE_FLAT_BIT)
|
||||
const GLuint const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v1->color[0] );
|
||||
#endif
|
||||
FFB_DELAYED_VIEWPORT_VARS;
|
||||
|
||||
#ifdef FFB_LINE_TRACE
|
||||
fprintf(stderr, "FFB: ffb_line ["
|
||||
#if (IND & FFB_LINE_FLAT_BIT)
|
||||
" FLAT"
|
||||
#endif
|
||||
#if (IND & FFB_LINE_ALPHA_BIT)
|
||||
" ALPHA"
|
||||
#endif
|
||||
" ]\n");
|
||||
#endif
|
||||
|
||||
#if (IND & FFB_LINE_FLAT_BIT)
|
||||
FFBFifo(fmesa, 1);
|
||||
ffb->fg = const_fg;
|
||||
#ifdef FFB_LINE_TRACE
|
||||
fprintf(stderr, "FFB: ffb_line confg_fg[%08x]\n", const_fg);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & FFB_LINE_FLAT_BIT)
|
||||
/* (2 * 3) + 1 */
|
||||
FFBFifo(fmesa, 7);
|
||||
#else
|
||||
#if (IND & FFB_LINE_ALPHA_BIT)
|
||||
/* (2 * 7) + 1 */
|
||||
FFBFifo(fmesa, 15);
|
||||
#else
|
||||
/* (2 * 6) + 1 */
|
||||
FFBFifo(fmesa, 13);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Using DDLINE or AALINE, init the line pattern state. */
|
||||
ffb->lpat = fmesa->lpat;
|
||||
|
||||
#if !(IND & FFB_LINE_FLAT_BIT)
|
||||
#if (IND & FFB_LINE_ALPHA_BIT)
|
||||
ffb->alpha = FFB_GET_ALPHA(v0);
|
||||
#endif
|
||||
ffb->red = FFB_GET_RED(v0);
|
||||
ffb->green = FFB_GET_GREEN(v0);
|
||||
ffb->blue = FFB_GET_BLUE(v0);
|
||||
#endif
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
#if !(IND & FFB_LINE_FLAT_BIT)
|
||||
#if (IND & FFB_LINE_ALPHA_BIT)
|
||||
ffb->alpha = FFB_GET_ALPHA(v1);
|
||||
#endif
|
||||
ffb->red = FFB_GET_RED(v1);
|
||||
ffb->green = FFB_GET_GREEN(v1);
|
||||
ffb->blue = FFB_GET_BLUE(v1);
|
||||
#endif
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void TAG(init)(void)
|
||||
{
|
||||
ffb_line_tab[IND] = TAG(ffb_line);
|
||||
}
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
||||
@@ -1,36 +0,0 @@
|
||||
|
||||
#ifndef _FFB_LOCK_H
|
||||
#define _FFB_LOCK_H
|
||||
|
||||
#include "ffb_context.h"
|
||||
|
||||
extern void ffbXMesaUpdateState(ffbContextPtr fmesa);
|
||||
#define FFB_UPDATE_STATE(fmesa) ffbXMesaUpdateState(fmesa)
|
||||
|
||||
/* Lock the hardware and validate our state. This hardware can only ever
|
||||
* exist on SPARC platforms. Don't bother building the real LOCK_HARDWARE and
|
||||
* UNLOCK_HARDWARE code on non-SPARC platforms. The only reason the driver
|
||||
* gets built on non-SPARC is to catch build breakages earlier.
|
||||
*/
|
||||
#if !defined(__sparc__)
|
||||
#define LOCK_HARDWARE(fmesa)
|
||||
#define UNLOCK_HARDWARE(fmesa)
|
||||
#else
|
||||
#define LOCK_HARDWARE(fmesa) \
|
||||
do { \
|
||||
DRM_CAS_RESULT(__ret); \
|
||||
DRM_CAS(fmesa->driHwLock, fmesa->hHWContext, \
|
||||
(DRM_LOCK_HELD | fmesa->hHWContext), __ret);\
|
||||
if (__ret) { \
|
||||
drmGetLock(fmesa->driFd, fmesa->hHWContext, 0); \
|
||||
FFB_UPDATE_STATE(fmesa); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Unlock the hardware. */
|
||||
#define UNLOCK_HARDWARE(fmesa) \
|
||||
DRM_UNLOCK(fmesa->driFd, fmesa->driHwLock, fmesa->hHWContext);
|
||||
#endif
|
||||
|
||||
#endif /* !(_FFB_LOCK_H) */
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000, 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/mtypes.h"
|
||||
#include "ffb_dd.h"
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_vb.h"
|
||||
#include "ffb_points.h"
|
||||
|
||||
|
||||
#undef FFB_POINT_TRACE
|
||||
|
||||
#define FFB_POINT_AA_BIT 0x01
|
||||
|
||||
static ffb_point_func ffb_point_tab[0x08];
|
||||
|
||||
#define IND (0)
|
||||
#define TAG(x) x
|
||||
#include "ffb_pointtmp.h"
|
||||
|
||||
#define IND (FFB_POINT_AA_BIT)
|
||||
#define TAG(x) x##_aa
|
||||
#include "ffb_pointtmp.h"
|
||||
|
||||
void ffbDDPointfuncInit(void)
|
||||
{
|
||||
init();
|
||||
init_aa();
|
||||
}
|
||||
|
||||
static void ffb_dd_points( GLcontext *ctx, GLuint first, GLuint last )
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
ffb_vertex *fverts = fmesa->verts;
|
||||
int i;
|
||||
|
||||
if (VB->Elts == 0) {
|
||||
for ( i = first ; i < last ; i++ ) {
|
||||
if ( VB->ClipMask[i] == 0 ) {
|
||||
fmesa->draw_point( ctx, &fverts[i] );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ( i = first ; i < last ; i++ ) {
|
||||
GLuint e = VB->Elts[i];
|
||||
if ( VB->ClipMask[e] == 0 ) {
|
||||
fmesa->draw_point( ctx, &fverts[e] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ffbChoosePointState(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
GLuint ind = 0;
|
||||
|
||||
tnl->Driver.Render.Points = ffb_dd_points;
|
||||
|
||||
if (flags & DD_POINT_SMOOTH)
|
||||
ind |= FFB_POINT_AA_BIT;
|
||||
|
||||
fmesa->draw_point = ffb_point_tab[ind];
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
#ifndef _FFB_POINTS_H
|
||||
#define _FFB_POINTS_H
|
||||
|
||||
extern void ffbDDPointfuncInit(void);
|
||||
|
||||
#define _FFB_NEW_POINT (_DD_NEW_POINT_SIZE | \
|
||||
_DD_NEW_POINT_SMOOTH | \
|
||||
_NEW_COLOR)
|
||||
|
||||
extern void ffbChoosePointState(GLcontext *);
|
||||
extern void ffb_fallback_point( GLcontext *ctx, ffb_vertex *v0 );
|
||||
|
||||
#endif /* !(_FFB_POINTS_H) */
|
||||
@@ -1,54 +0,0 @@
|
||||
|
||||
static INLINE void TAG(ffb_draw_point)(GLcontext *ctx, ffb_vertex *tmp )
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
ffb_fbcPtr ffb = fmesa->regs;
|
||||
FFB_DELAYED_VIEWPORT_VARS;
|
||||
|
||||
#ifdef FFB_POINT_TRACE
|
||||
fprintf(stderr, "FFB: ffb_point ["
|
||||
#if (IND & FFB_POINT_AA_BIT)
|
||||
"AA"
|
||||
#endif
|
||||
"] X(%f) Y(%f) Z(%f)\n",
|
||||
tmp->x, tmp->y, tmp->z);
|
||||
#endif
|
||||
|
||||
#if (IND & FFB_POINT_AA_BIT)
|
||||
FFBFifo(fmesa, 4);
|
||||
|
||||
ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( tmp->color[0] );
|
||||
ffb->z = FFB_GET_Z(tmp);
|
||||
ffb->y = FFB_GET_Y(tmp) + 0x8000 /* FIX ME */;
|
||||
ffb->x = FFB_GET_X(tmp) + 0x8000 /* FIX ME */;
|
||||
#else
|
||||
{
|
||||
unsigned int const_fg, const_z, h, w;
|
||||
|
||||
const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( tmp->color[0] );
|
||||
const_z = Z_FROM_MESA(FFB_Z_TO_FLOAT(FFB_GET_Z(tmp)));
|
||||
h = FFB_GET_Y(tmp) >> 16;
|
||||
w = FFB_GET_X(tmp) >> 16;
|
||||
#ifdef FFB_POINT_TRACE
|
||||
fprintf(stderr, "FFB: ffb_point fg(%08x) z(%08x) h(%08x) w(%08x)\n",
|
||||
const_fg, const_z, h, w);
|
||||
#endif
|
||||
FFBFifo(fmesa, 4);
|
||||
ffb->fg = const_fg;
|
||||
ffb->constz = const_z;
|
||||
ffb->bh = h;
|
||||
ffb->bw = w;
|
||||
}
|
||||
#endif
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
|
||||
static void TAG(init)(void)
|
||||
{
|
||||
ffb_point_tab[IND] = TAG(ffb_draw_point);
|
||||
}
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
||||
@@ -1,645 +0,0 @@
|
||||
|
||||
#define IMPL_LOCAL_VARS \
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
|
||||
ffb_fbcPtr ffb = fmesa->regs; \
|
||||
const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
|
||||
FFB_DELAYED_VIEWPORT_VARS; \
|
||||
(void) fmesa; (void) ffb; (void) elt
|
||||
|
||||
#if (IND & FFB_FLAT_BIT)
|
||||
#define FFB_DECLARE_CACHED_COLOR(NAME) \
|
||||
unsigned int NAME;
|
||||
#define FFB_COMPUTE_CACHED_COLOR(NAME, VTX) \
|
||||
NAME = FFB_PACK_CONST_UBYTE_ARGB_COLOR((VTX)->color[0])
|
||||
#define FFB_CACHED_COLOR_SAME(NAME1, NAME2) \
|
||||
((NAME1) == (NAME2))
|
||||
#define FFB_CACHED_COLOR_SET(NAME) \
|
||||
ffb->fg = (NAME)
|
||||
#define FFB_CACHED_COLOR_UPDATE(NAME1, NAME2) \
|
||||
ffb->fg = (NAME1) = (NAME2)
|
||||
#define FFB_SET_PRIM_COLOR(COLOR_VERTEX) \
|
||||
ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR((COLOR_VERTEX)->color[0])
|
||||
#define FFB_PRIM_COLOR_COST 1
|
||||
#define FFB_SET_VERTEX_COLOR(VTX) /**/
|
||||
#define FFB_VERTEX_COLOR_COST 0
|
||||
#else
|
||||
#define FFB_DECLARE_CACHED_COLOR(NAME) /**/
|
||||
#define FFB_COMPUTE_CACHED_COLOR(NAME, VTX) /**/
|
||||
#define FFB_CACHED_COLOR_SAME(NAME1, NAME2) 0
|
||||
#define FFB_CACHED_COLOR_SET(NAME1) /**/
|
||||
#define FFB_CACHED_COLOR_UPDATE(NAME1, NAME2) /**/
|
||||
#define FFB_SET_PRIM_COLOR(COLOR_VERTEX) /**/
|
||||
#define FFB_PRIM_COLOR_COST 0
|
||||
#if (IND & FFB_ALPHA_BIT)
|
||||
#define FFB_SET_VERTEX_COLOR(VTX) \
|
||||
ffb->alpha = FFB_GET_ALPHA(VTX); \
|
||||
ffb->red = FFB_GET_RED(VTX); \
|
||||
ffb->green = FFB_GET_GREEN(VTX); \
|
||||
ffb->blue = FFB_GET_BLUE(VTX)
|
||||
#define FFB_VERTEX_COLOR_COST 4
|
||||
#else
|
||||
#define FFB_SET_VERTEX_COLOR(VTX) \
|
||||
ffb->red = FFB_GET_RED(VTX); \
|
||||
ffb->green = FFB_GET_GREEN(VTX); \
|
||||
ffb->blue = FFB_GET_BLUE(VTX)
|
||||
#define FFB_VERTEX_COLOR_COST 3
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define RESET_STIPPLE ffb->lpat = fmesa->lpat;
|
||||
|
||||
#if !(IND & (FFB_TRI_CULL_BIT))
|
||||
static void TAG(ffb_vb_points)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_POINTS);
|
||||
if (ctx->_TriangleCaps & DD_POINT_SMOOTH) {
|
||||
for (i = start; i < count; i++) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(i)];
|
||||
|
||||
FFBFifo(fmesa, 4);
|
||||
ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR(v0->color[0]);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->y = FFB_GET_Y(v0) + 0x8000 /* FIX ME */;
|
||||
ffb->x = FFB_GET_X(v0) + 0x8000 /* FIX ME */;
|
||||
}
|
||||
} else {
|
||||
for (i = start; i < count; i++) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(i)];
|
||||
FFBFifo(fmesa, 4);
|
||||
ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR(v0->color[0]);
|
||||
ffb->constz = Z_FROM_MESA(FFB_Z_TO_FLOAT(FFB_GET_Z(v0)));
|
||||
ffb->bh = FFB_GET_Y(v0) >> 16;
|
||||
ffb->bw = FFB_GET_X(v0) >> 16;
|
||||
}
|
||||
}
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void TAG(ffb_vb_lines)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_LINES);
|
||||
for (i = start + 1; i < count; i += 2) {
|
||||
ffb_vertex *v0 = &fmesa->verts[i - 1];
|
||||
ffb_vertex *v1 = &fmesa->verts[i - 0];
|
||||
|
||||
FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 2) + 6));
|
||||
|
||||
RESET_STIPPLE;
|
||||
|
||||
FFB_SET_PRIM_COLOR(v1);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
}
|
||||
}
|
||||
|
||||
static void TAG(ffb_vb_line_loop)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_LINE_LOOP);
|
||||
if ((flags & PRIM_BEGIN) != 0) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(start + 0)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(start + 1)];
|
||||
|
||||
FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST +
|
||||
((FFB_VERTEX_COLOR_COST * 2) + (3 * 2))));
|
||||
|
||||
RESET_STIPPLE;
|
||||
|
||||
FFB_SET_PRIM_COLOR(v1);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
}
|
||||
for (i = start + 2; i < count; i++) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(i)];
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST + 3)));
|
||||
|
||||
FFB_SET_PRIM_COLOR(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->y = FFB_GET_Y(v0);
|
||||
ffb->x = FFB_GET_X(v0);
|
||||
}
|
||||
if ((flags & PRIM_END) != 0) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(start)];
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST + 3)));
|
||||
|
||||
FFB_SET_PRIM_COLOR(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->y = FFB_GET_Y(v0);
|
||||
ffb->x = FFB_GET_X(v0);
|
||||
}
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void TAG(ffb_vb_line_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
FFB_DECLARE_CACHED_COLOR(cached_fg)
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_LINE_STRIP);
|
||||
FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST +
|
||||
((FFB_VERTEX_COLOR_COST * 2) + (3 * 2))));
|
||||
|
||||
RESET_STIPPLE;
|
||||
|
||||
{
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(start + 0)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(start + 1)];
|
||||
|
||||
FFB_COMPUTE_CACHED_COLOR(cached_fg, v0);
|
||||
FFB_CACHED_COLOR_SET(cached_fg);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
}
|
||||
|
||||
for (i = start + 2; i < count; i++) {
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(i - 0)];
|
||||
FFB_DECLARE_CACHED_COLOR(new_fg)
|
||||
|
||||
FFB_COMPUTE_CACHED_COLOR(new_fg, v1);
|
||||
if (FFB_CACHED_COLOR_SAME(cached_fg, new_fg)) {
|
||||
FFBFifo(fmesa, ((FFB_VERTEX_COLOR_COST * 1) + (3 * 1)));
|
||||
} else {
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 1) + (3 * 1)));
|
||||
FFB_CACHED_COLOR_UPDATE(cached_fg, new_fg);
|
||||
}
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
}
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
#endif /* !(IND & (FFB_TRI_CULL_BIT)) */
|
||||
|
||||
/* OK, now things start getting fun :-) */
|
||||
#if (IND & (FFB_TRI_CULL_BIT))
|
||||
#define FFB_AREA_DECLARE GLfloat cc, ex, ey, fx, fy;
|
||||
#define FFB_COMPUTE_AREA_TRI(V0, V1, V2) \
|
||||
{ ex = (V1)->x - (V0)->x; \
|
||||
ey = (V1)->y - (V0)->y; \
|
||||
fx = (V2)->x - (V0)->x; \
|
||||
fy = (V2)->y - (V0)->y; \
|
||||
cc = ex*fy-ey*fx; \
|
||||
}
|
||||
#define FFB_COMPUTE_AREA_QUAD(V0, V1, V2, V3) \
|
||||
{ ex = (V2)->x - (V0)->x; \
|
||||
ey = (V2)->y - (V0)->y; \
|
||||
fx = (V3)->x - (V1)->x; \
|
||||
fy = (V3)->y - (V1)->y; \
|
||||
cc = ex*fy-ey*fx; \
|
||||
}
|
||||
#else
|
||||
#define FFB_AREA_DECLARE /**/
|
||||
#define FFB_COMPUTE_AREA_TRI(V0, V1, V2) do { } while(0)
|
||||
#define FFB_COMPUTE_AREA_QUAD(V0, V1, V2, V3) do { } while(0)
|
||||
#endif
|
||||
|
||||
#if (IND & FFB_TRI_CULL_BIT)
|
||||
#define FFB_CULL_TRI(CULL_ACTION) \
|
||||
if (cc * fmesa->backface_sign > fmesa->ffb_zero) { \
|
||||
CULL_ACTION \
|
||||
}
|
||||
#define FFB_CULL_QUAD(CULL_ACTION) \
|
||||
if (cc * fmesa->backface_sign > fmesa->ffb_zero) { \
|
||||
CULL_ACTION \
|
||||
}
|
||||
#else
|
||||
#define FFB_CULL_TRI(CULL_ACTION) do { } while (0)
|
||||
#define FFB_CULL_QUAD(CULL_ACTION) do { } while (0)
|
||||
#endif
|
||||
|
||||
static void TAG(ffb_vb_triangles)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_TRIANGLES);
|
||||
for (i = start + 2; i < count; i += 3) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(i - 2)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)];
|
||||
ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
|
||||
FFB_AREA_DECLARE
|
||||
|
||||
FFB_COMPUTE_AREA_TRI(v0, v1, v2);
|
||||
FFB_CULL_TRI(continue;);
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 3) + 9));
|
||||
FFB_SET_PRIM_COLOR(v2);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v2);
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->y = FFB_GET_Y(v2);
|
||||
ffb->x = FFB_GET_X(v2);
|
||||
}
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void TAG(ffb_vb_tri_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
GLint parity = 0;
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_TRIANGLE_STRIP);
|
||||
|
||||
i = start + 2;
|
||||
goto something_clipped;
|
||||
|
||||
something_clipped:
|
||||
for (; i < count; i++, parity ^= 1) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(i - 2 + parity)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(i - 1 - parity)];
|
||||
ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
|
||||
FFB_AREA_DECLARE
|
||||
|
||||
FFB_COMPUTE_AREA_TRI(v0, v1, v2);
|
||||
FFB_CULL_TRI(continue;);
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 3) + 9));
|
||||
FFB_SET_PRIM_COLOR(v2);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v2);
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->y = FFB_GET_Y(v2);
|
||||
ffb->x = FFB_GET_X(v2);
|
||||
|
||||
i++;
|
||||
parity ^= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
for (; i < count; i++, parity ^= 1) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(i - 2 + parity)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(i - 1 - parity)];
|
||||
ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
|
||||
FFB_AREA_DECLARE
|
||||
(void) v0; (void) v1;
|
||||
|
||||
FFB_COMPUTE_AREA_TRI(v0, v1, v2);
|
||||
FFB_CULL_TRI(i++; parity^=1; goto something_clipped;);
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 1) + 3));
|
||||
FFB_SET_PRIM_COLOR(v2);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v2);
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->y = FFB_GET_Y(v2);
|
||||
ffb->x = FFB_GET_X(v2);
|
||||
}
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void TAG(ffb_vb_tri_fan)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_TRIANGLE_FAN);
|
||||
|
||||
i = start + 2;
|
||||
goto something_clipped;
|
||||
|
||||
something_clipped:
|
||||
for ( ; i < count; i++) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(start)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)];
|
||||
ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
|
||||
FFB_AREA_DECLARE
|
||||
|
||||
FFB_COMPUTE_AREA_TRI(v0, v1, v2);
|
||||
FFB_CULL_TRI(continue;);
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 3) + 9));
|
||||
FFB_SET_PRIM_COLOR(v2);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v2);
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->y = FFB_GET_Y(v2);
|
||||
ffb->x = FFB_GET_X(v2);
|
||||
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
|
||||
for (; i < count; i++) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(start)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)];
|
||||
ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
|
||||
FFB_AREA_DECLARE
|
||||
(void) v0; (void) v1;
|
||||
|
||||
FFB_COMPUTE_AREA_TRI(v0, v1, v2);
|
||||
FFB_CULL_TRI(i++; goto something_clipped;);
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 1) + 3));
|
||||
FFB_SET_PRIM_COLOR(v2);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v2);
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->dmyf = FFB_GET_Y(v2);
|
||||
ffb->dmxf = FFB_GET_X(v2);
|
||||
}
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void TAG(ffb_vb_poly)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_POLYGON);
|
||||
|
||||
/* XXX Optimize XXX */
|
||||
for (i = start + 2; i < count; i++) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(i - 1)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(i)];
|
||||
ffb_vertex *v2 = &fmesa->verts[ELT(start)];
|
||||
FFB_AREA_DECLARE
|
||||
|
||||
FFB_COMPUTE_AREA_TRI(v0, v1, v2);
|
||||
FFB_CULL_TRI(continue;);
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 3) + 9));
|
||||
FFB_SET_PRIM_COLOR(v2);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v2);
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->y = FFB_GET_Y(v2);
|
||||
ffb->x = FFB_GET_X(v2);
|
||||
}
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void TAG(ffb_vb_quads)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_QUADS);
|
||||
|
||||
for (i = start + 3; i < count; i += 4) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(i - 3)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(i - 2)];
|
||||
ffb_vertex *v2 = &fmesa->verts[ELT(i - 1)];
|
||||
ffb_vertex *v3 = &fmesa->verts[ELT(i - 0)];
|
||||
FFB_AREA_DECLARE
|
||||
|
||||
FFB_COMPUTE_AREA_QUAD(v0, v1, v2, v3);
|
||||
FFB_CULL_QUAD(continue;);
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 4) + 12));
|
||||
FFB_SET_PRIM_COLOR(v3);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v2);
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->y = FFB_GET_Y(v2);
|
||||
ffb->x = FFB_GET_X(v2);
|
||||
|
||||
FFB_SET_VERTEX_COLOR(v3);
|
||||
ffb->z = FFB_GET_Z(v3);
|
||||
ffb->dmyf = FFB_GET_Y(v3);
|
||||
ffb->dmxf = FFB_GET_X(v3);
|
||||
}
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void TAG(ffb_vb_quad_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
GLint i;
|
||||
IMPL_LOCAL_VARS;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
|
||||
__FUNCTION__, start, count, flags);
|
||||
#endif
|
||||
ffbRenderPrimitive(ctx, GL_QUAD_STRIP);
|
||||
|
||||
/* XXX Optimize XXX */
|
||||
for (i = start + 3; i < count; i += 2) {
|
||||
ffb_vertex *v0 = &fmesa->verts[ELT(i - 1)];
|
||||
ffb_vertex *v1 = &fmesa->verts[ELT(i - 3)];
|
||||
ffb_vertex *v2 = &fmesa->verts[ELT(i - 2)];
|
||||
ffb_vertex *v3 = &fmesa->verts[ELT(i - 0)];
|
||||
FFB_AREA_DECLARE
|
||||
|
||||
FFB_COMPUTE_AREA_QUAD(v0, v1, v2, v3);
|
||||
FFB_CULL_QUAD(continue;);
|
||||
|
||||
FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
|
||||
(FFB_VERTEX_COLOR_COST * 4) + 12));
|
||||
FFB_SET_PRIM_COLOR(v3);
|
||||
|
||||
FFB_DUMP_VERTEX(v0);
|
||||
FFB_SET_VERTEX_COLOR(v0);
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_DUMP_VERTEX(v1);
|
||||
FFB_SET_VERTEX_COLOR(v1);
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
|
||||
FFB_DUMP_VERTEX(v2);
|
||||
FFB_SET_VERTEX_COLOR(v2);
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->y = FFB_GET_Y(v2);
|
||||
ffb->x = FFB_GET_X(v2);
|
||||
|
||||
FFB_DUMP_VERTEX(v3);
|
||||
FFB_SET_VERTEX_COLOR(v3);
|
||||
ffb->z = FFB_GET_Z(v3);
|
||||
ffb->dmyf = FFB_GET_Y(v3);
|
||||
ffb->dmxf = FFB_GET_X(v3);
|
||||
}
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void (*TAG(render_tab)[GL_POLYGON + 2])(GLcontext *, GLuint, GLuint, GLuint) =
|
||||
{
|
||||
#if !(IND & (FFB_TRI_CULL_BIT))
|
||||
TAG(ffb_vb_points),
|
||||
TAG(ffb_vb_lines),
|
||||
TAG(ffb_vb_line_loop),
|
||||
TAG(ffb_vb_line_strip),
|
||||
#else
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
TAG(ffb_vb_triangles),
|
||||
TAG(ffb_vb_tri_strip),
|
||||
TAG(ffb_vb_tri_fan),
|
||||
TAG(ffb_vb_quads),
|
||||
TAG(ffb_vb_quad_strip),
|
||||
TAG(ffb_vb_poly),
|
||||
ffb_vb_noop,
|
||||
};
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
||||
|
||||
#undef IMPL_LOCAL_VARS
|
||||
#undef FFB_DECLARE_CACHED_COLOR
|
||||
#undef FFB_COMPUTE_CACHED_COLOR
|
||||
#undef FFB_CACHED_COLOR_SAME
|
||||
#undef FFB_CACHED_COLOR_SET
|
||||
#undef FFB_CACHED_COLOR_UPDATE
|
||||
#undef FFB_SET_PRIM_COLOR
|
||||
#undef FFB_PRIM_COLOR_COST
|
||||
#undef FFB_SET_VERTEX_COLOR
|
||||
#undef FFB_VERTEX_COLOR_COST
|
||||
#undef RESET_STIPPLE
|
||||
#undef FFB_AREA_DECLARE
|
||||
#undef FFB_COMPUTE_AREA_TRI
|
||||
#undef FFB_COMPUTE_AREA_QUAD
|
||||
#undef FFB_CULL_TRI
|
||||
#undef FFB_CULL_QUAD
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/mtypes.h"
|
||||
#include "ffb_dd.h"
|
||||
#include "ffb_span.h"
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_lock.h"
|
||||
|
||||
#define DBG 0
|
||||
|
||||
#define HW_LOCK() \
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
|
||||
if (!fmesa->hw_locked) \
|
||||
LOCK_HARDWARE(fmesa);
|
||||
|
||||
#define HW_UNLOCK() \
|
||||
if (!fmesa->hw_locked) \
|
||||
UNLOCK_HARDWARE(fmesa); \
|
||||
|
||||
#define LOCAL_VARS \
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable; \
|
||||
GLuint height = dPriv->h; \
|
||||
GLuint p; \
|
||||
char *buf; \
|
||||
(void) p
|
||||
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = ((color[0] << 0) | \
|
||||
(color[1] << 8) | \
|
||||
(color[2] << 16))
|
||||
|
||||
/* We use WID clipping, so this test always passes. */
|
||||
#define CLIPPIXEL(__x, __y) (1)
|
||||
|
||||
/* And also, due to WID clipping, we need not do anything
|
||||
* special here.
|
||||
*/
|
||||
#define CLIPSPAN(__x,__y,__n,__x1,__n1,__i) \
|
||||
__n1 = __n; \
|
||||
__x1 = __x; \
|
||||
|
||||
#define HW_CLIPLOOP() \
|
||||
do { unsigned int fbc, ppc, cmp; \
|
||||
FFBWait(fmesa, fmesa->regs); \
|
||||
fbc = fmesa->regs->fbc; ppc = fmesa->regs->ppc; cmp = fmesa->regs->cmp; \
|
||||
fmesa->regs->fbc = ((fbc & \
|
||||
~(FFB_FBC_WB_C | FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK)) \
|
||||
| (FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK)); \
|
||||
fmesa->regs->ppc = ((ppc & \
|
||||
~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK | FFB_PPC_DCE_MASK | \
|
||||
FFB_PPC_APE_MASK | FFB_PPC_CS_MASK)) \
|
||||
| (FFB_PPC_XS_WID | FFB_PPC_ABE_DISABLE | \
|
||||
FFB_PPC_DCE_DISABLE | FFB_PPC_APE_DISABLE | \
|
||||
FFB_PPC_CS_VAR)); \
|
||||
fmesa->regs->cmp = ((cmp & ~(0xff << 16)) | (0x80 << 16)); \
|
||||
fmesa->ffbScreen->rp_active = 1; \
|
||||
FFBWait(fmesa, fmesa->regs); \
|
||||
buf = (char *)(fmesa->sfb32 + (dPriv->x << 2) + (dPriv->y << 13));\
|
||||
if (dPriv->numClipRects) {
|
||||
|
||||
#define HW_ENDCLIPLOOP() \
|
||||
} \
|
||||
fmesa->regs->fbc = fbc; \
|
||||
fmesa->regs->ppc = ppc; \
|
||||
fmesa->regs->cmp = cmp; \
|
||||
fmesa->ffbScreen->rp_active = 1; \
|
||||
} while(0)
|
||||
|
||||
#define Y_FLIP(__y) (height - __y - 1)
|
||||
|
||||
#define READ_RGBA(rgba,__x,__y) \
|
||||
do { GLuint p = *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)); \
|
||||
rgba[0] = (p >> 0) & 0xff; \
|
||||
rgba[1] = (p >> 8) & 0xff; \
|
||||
rgba[2] = (p >> 16) & 0xff; \
|
||||
rgba[3] = 0xff; \
|
||||
} while(0)
|
||||
|
||||
#define WRITE_RGBA(__x, __y, __r, __g, __b, __a) \
|
||||
*(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = \
|
||||
((((__r) & 0xff) << 0) | \
|
||||
(((__g) & 0xff) << 8) | \
|
||||
(((__b) & 0xff) << 16))
|
||||
|
||||
#define WRITE_PIXEL(__x, __y, __p) \
|
||||
*(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = (__p)
|
||||
|
||||
#define TAG(x) ffb##x##_888
|
||||
|
||||
#include "spantmp.h"
|
||||
|
||||
/**
|
||||
* Plug in the Get/Put routines for the given driRenderbuffer.
|
||||
*/
|
||||
void
|
||||
ffbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
|
||||
{
|
||||
assert(vis->redBits == 8);
|
||||
assert(vis->greenBits == 8);
|
||||
assert(vis->blueBits == 8);
|
||||
ffbInitPointers_888(&drb->Base);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
#ifndef _FFB_SPAN_H
|
||||
#define _FFB_SPAN_H
|
||||
|
||||
#include "drirenderbuffer.h"
|
||||
|
||||
void ffbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis);
|
||||
|
||||
#endif /* !(_FFB_SPAN_H) */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
|
||||
#ifndef _FFB_STATE_H
|
||||
#define _FFB_STATE_H
|
||||
|
||||
extern void ffbDDInitStateFuncs(GLcontext *);
|
||||
extern void ffbDDInitContextHwState(GLcontext *);
|
||||
|
||||
extern void ffbCalcViewport(GLcontext *);
|
||||
extern void ffbXformAreaPattern(ffbContextPtr, const GLubyte *);
|
||||
extern void ffbSyncHardware(ffbContextPtr fmesa);
|
||||
|
||||
#endif /* !(_FFB_STATE_H) */
|
||||
@@ -1,224 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/mtypes.h"
|
||||
#include "ffb_dd.h"
|
||||
#include "ffb_span.h"
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_stencil.h"
|
||||
#include "ffb_lock.h"
|
||||
|
||||
#undef STENCIL_TRACE
|
||||
|
||||
static void FFBWriteStencilSpan( GLcontext *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y,
|
||||
const void *values, const GLubyte mask[] )
|
||||
{
|
||||
const GLubyte *stencil = (const GLubyte *) values;
|
||||
#ifdef STENCIL_TRACE
|
||||
fprintf(stderr, "FFBWriteStencilSpan: n(%d) x(%d) y(%d)\n",
|
||||
(int) n, x, y);
|
||||
#endif
|
||||
if (ctx->Depth.Mask) {
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
GLuint *zptr;
|
||||
GLuint i;
|
||||
|
||||
if (!fmesa->hw_locked)
|
||||
LOCK_HARDWARE(fmesa);
|
||||
FFBFifo(fmesa, 2);
|
||||
fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_OFF |
|
||||
FFB_FBC_YE_ON | FFB_FBC_RGBE_OFF);
|
||||
fmesa->regs->ppc = FFB_PPC_YS_VAR;
|
||||
FFBWait(fmesa, fmesa->regs);
|
||||
|
||||
y = (dPriv->h - y);
|
||||
zptr = (GLuint *)
|
||||
((char *)fmesa->sfb32 +
|
||||
((dPriv->x + x) << 2) +
|
||||
((dPriv->y + y) << 13));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (mask[i])
|
||||
*zptr = (stencil[i] & 0xf) << 28;
|
||||
zptr++;
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 2);
|
||||
fmesa->regs->fbc = fmesa->fbc;
|
||||
fmesa->regs->ppc = fmesa->ppc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
if (!fmesa->hw_locked)
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
}
|
||||
|
||||
static void FFBWriteStencilPixels( GLcontext *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
const void *values, const GLubyte mask[] )
|
||||
{
|
||||
const GLubyte *stencil = (const GLubyte *) values;
|
||||
#ifdef STENCIL_TRACE
|
||||
fprintf(stderr, "FFBWriteStencilPixels: n(%d)\n", (int) n);
|
||||
#endif
|
||||
if (ctx->Depth.Mask) {
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
char *zbase;
|
||||
GLuint i;
|
||||
|
||||
if (!fmesa->hw_locked)
|
||||
LOCK_HARDWARE(fmesa);
|
||||
FFBFifo(fmesa, 2);
|
||||
fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_OFF |
|
||||
FFB_FBC_YE_ON | FFB_FBC_RGBE_OFF);
|
||||
fmesa->regs->ppc = FFB_PPC_YS_VAR;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
FFBWait(fmesa, fmesa->regs);
|
||||
|
||||
zbase = ((char *)fmesa->sfb32 +
|
||||
(dPriv->x << 2) + (dPriv->y << 13));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
GLint y1 = (dPriv->h - y[i]);
|
||||
GLint x1 = x[i];
|
||||
GLuint *zptr;
|
||||
|
||||
zptr = (GLuint *)
|
||||
(zbase + (x1 << 2) + (y1 << 13));
|
||||
if (mask[i])
|
||||
*zptr = (stencil[i] & 0xf) << 28;
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 2);
|
||||
fmesa->regs->fbc = fmesa->fbc;
|
||||
fmesa->regs->ppc = fmesa->ppc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
if (!fmesa->hw_locked)
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
}
|
||||
|
||||
static void FFBReadStencilSpan( GLcontext *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y,
|
||||
void *values)
|
||||
{
|
||||
GLubyte *stencil = (GLubyte *) values;
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
GLuint *zptr;
|
||||
GLuint i;
|
||||
|
||||
#ifdef STENCIL_TRACE
|
||||
fprintf(stderr, "FFBReadStencilSpan: n(%d) x(%d) y(%d)\n",
|
||||
(int) n, x, y);
|
||||
#endif
|
||||
if (!fmesa->hw_locked)
|
||||
LOCK_HARDWARE(fmesa);
|
||||
FFBFifo(fmesa, 1);
|
||||
fmesa->regs->fbc = FFB_FBC_RB_C;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
FFBWait(fmesa, fmesa->regs);
|
||||
|
||||
y = (dPriv->h - y);
|
||||
zptr = (GLuint *)
|
||||
((char *)fmesa->sfb32 +
|
||||
((dPriv->x + x) << 2) +
|
||||
((dPriv->y + y) << 13));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
stencil[i] = (*zptr >> 28) & 0xf;
|
||||
zptr++;
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 1);
|
||||
fmesa->regs->fbc = fmesa->fbc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
if (!fmesa->hw_locked)
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
|
||||
static void FFBReadStencilPixels( GLcontext *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
void *values )
|
||||
{
|
||||
GLubyte *stencil = (GLubyte *) values;
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
char *zbase;
|
||||
GLuint i;
|
||||
|
||||
#ifdef STENCIL_TRACE
|
||||
fprintf(stderr, "FFBReadStencilPixels: n(%d)\n", (int) n);
|
||||
#endif
|
||||
if (!fmesa->hw_locked)
|
||||
LOCK_HARDWARE(fmesa);
|
||||
FFBFifo(fmesa, 1);
|
||||
fmesa->regs->fbc = FFB_FBC_RB_C;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
FFBWait(fmesa, fmesa->regs);
|
||||
|
||||
zbase = ((char *)fmesa->sfb32 +
|
||||
(dPriv->x << 2) + (dPriv->y << 13));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
GLint y1 = (dPriv->h - y[i]);
|
||||
GLint x1 = x[i];
|
||||
GLuint *zptr;
|
||||
|
||||
zptr = (GLuint *)
|
||||
(zbase + (x1 << 2) + (y1 << 13));
|
||||
stencil[i] = (*zptr >> 28) & 0xf;
|
||||
}
|
||||
|
||||
FFBFifo(fmesa, 1);
|
||||
fmesa->regs->fbc = fmesa->fbc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
if (!fmesa->hw_locked)
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plug in the Get/Put routines for the given driRenderbuffer.
|
||||
*/
|
||||
void
|
||||
ffbSetStencilFunctions(driRenderbuffer *drb, const GLvisual *vis)
|
||||
{
|
||||
assert(drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT);
|
||||
drb->Base.GetRow = FFBReadStencilSpan;
|
||||
drb->Base.GetValues = FFBReadStencilPixels;
|
||||
drb->Base.PutRow = FFBWriteStencilSpan;
|
||||
/*drb->Base.PutMonoRow = FFBWriteMonoStencilSpan;*/
|
||||
drb->Base.PutValues = FFBWriteStencilPixels;
|
||||
drb->Base.PutMonoValues = NULL;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
#ifndef _FFB_STENCIL_H
|
||||
#define _FFB_STENCIL_H
|
||||
|
||||
void ffbSetStencilFunctions(driRenderbuffer *drb, const GLvisual *vis);
|
||||
|
||||
#endif /* !(_FFB_STENCIL_H) */
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "ffb_tex.h"
|
||||
|
||||
/* No texture unit, all software. */
|
||||
void ffbDDInitTexFuncs(GLcontext *ctx)
|
||||
{
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D.
|
||||
* Copyright (C) 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef _FFB_TEX_H
|
||||
#define _FFB_TEX_H
|
||||
|
||||
extern void ffbDDInitTexFuncs(GLcontext *ctx);
|
||||
|
||||
#endif /* !(_FFB_DD_H) */
|
||||
|
||||
@@ -1,945 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000, 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "main/macros.h"
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast/s_context.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_tris.h"
|
||||
#include "ffb_lines.h"
|
||||
#include "ffb_lock.h"
|
||||
#include "ffb_points.h"
|
||||
#include "ffb_state.h"
|
||||
#include "ffb_vb.h"
|
||||
|
||||
#undef TRI_DEBUG
|
||||
#undef FFB_RENDER_TRACE
|
||||
#undef STATE_TRACE
|
||||
|
||||
#ifdef TRI_DEBUG
|
||||
static void ffb_print_vertex(const ffb_vertex *v)
|
||||
{
|
||||
fprintf(stderr, "Vertex @(%p): "
|
||||
"X[%f] Y[%f] Z[%f]\n",
|
||||
v, v->x, v->y, v->z);
|
||||
fprintf(stderr, "Vertex @(%p): "
|
||||
"A[%f] R[%f] G[%f] B[%f]\n",
|
||||
v,
|
||||
v->color[0].alpha,
|
||||
v->color[0].red,
|
||||
v->color[0].green,
|
||||
v->color[0].blue);
|
||||
}
|
||||
#define FFB_DUMP_VERTEX(V) ffb_print_vertex(V)
|
||||
#else
|
||||
#define FFB_DUMP_VERTEX(V) do { } while(0)
|
||||
#endif
|
||||
|
||||
#define FFB_ALPHA_BIT 0x01
|
||||
#define FFB_FLAT_BIT 0x02
|
||||
#define FFB_TRI_CULL_BIT 0x04
|
||||
#define MAX_FFB_RENDER_FUNCS 0x08
|
||||
|
||||
/***********************************************************************
|
||||
* Build low-level triangle/quad rasterize functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define FFB_TRI_FLAT_BIT 0x01
|
||||
#define FFB_TRI_ALPHA_BIT 0x02
|
||||
/*#define FFB_TRI_CULL_BIT 0x04*/
|
||||
|
||||
static ffb_tri_func ffb_tri_tab[0x8];
|
||||
static ffb_quad_func ffb_quad_tab[0x8];
|
||||
|
||||
#define IND (0)
|
||||
#define TAG(x) x
|
||||
#include "ffb_tritmp.h"
|
||||
|
||||
#define IND (FFB_TRI_FLAT_BIT)
|
||||
#define TAG(x) x##_flat
|
||||
#include "ffb_tritmp.h"
|
||||
|
||||
#define IND (FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_cull
|
||||
#include "ffb_tritmp.h"
|
||||
|
||||
#define IND (FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT)
|
||||
#define TAG(x) x##_cull_flat
|
||||
#include "ffb_tritmp.h"
|
||||
|
||||
#define IND (FFB_TRI_ALPHA_BIT)
|
||||
#define TAG(x) x##_alpha
|
||||
#include "ffb_tritmp.h"
|
||||
|
||||
#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_FLAT_BIT)
|
||||
#define TAG(x) x##_alpha_flat
|
||||
#include "ffb_tritmp.h"
|
||||
|
||||
#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_alpha_cull
|
||||
#include "ffb_tritmp.h"
|
||||
|
||||
#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT)
|
||||
#define TAG(x) x##_alpha_cull_flat
|
||||
#include "ffb_tritmp.h"
|
||||
|
||||
static void init_tri_tab(void)
|
||||
{
|
||||
ffb_init();
|
||||
ffb_init_flat();
|
||||
ffb_init_cull();
|
||||
ffb_init_cull_flat();
|
||||
ffb_init_alpha();
|
||||
ffb_init_alpha_flat();
|
||||
ffb_init_alpha_cull();
|
||||
ffb_init_alpha_cull_flat();
|
||||
}
|
||||
|
||||
/* Build a SWvertex from a hardware vertex. */
|
||||
static void ffb_translate_vertex(GLcontext *ctx, const ffb_vertex *src,
|
||||
SWvertex *dst)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
GLfloat *m = ctx->Viewport._WindowMap.m;
|
||||
const GLfloat sx = m[0];
|
||||
const GLfloat sy = m[5];
|
||||
const GLfloat sz = m[10];
|
||||
const GLfloat tx = m[12];
|
||||
const GLfloat ty = m[13];
|
||||
const GLfloat tz = m[14];
|
||||
|
||||
dst->attrib[FRAG_ATTRIB_WPOS][0] = sx * src->x + tx;
|
||||
dst->attrib[FRAG_ATTRIB_WPOS][1] = sy * src->y + ty;
|
||||
dst->attrib[FRAG_ATTRIB_WPOS][2] = sz * src->z + tz;
|
||||
dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
|
||||
|
||||
dst->color[0] = FFB_UBYTE_FROM_COLOR(src->color[0].red);
|
||||
dst->color[1] = FFB_UBYTE_FROM_COLOR(src->color[0].green);
|
||||
dst->color[2] = FFB_UBYTE_FROM_COLOR(src->color[0].blue);
|
||||
dst->color[3] = FFB_UBYTE_FROM_COLOR(src->color[0].alpha);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Build fallback triangle/quad rasterize functions *
|
||||
***********************************************************************/
|
||||
|
||||
static void ffb_fallback_triangle(GLcontext *ctx, ffb_vertex *v0,
|
||||
ffb_vertex *v1, ffb_vertex *v2)
|
||||
{
|
||||
SWvertex v[3];
|
||||
|
||||
ffb_translate_vertex(ctx, v0, &v[0]);
|
||||
ffb_translate_vertex(ctx, v1, &v[1]);
|
||||
ffb_translate_vertex(ctx, v2, &v[2]);
|
||||
|
||||
_swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
|
||||
}
|
||||
|
||||
static void ffb_fallback_quad(GLcontext *ctx,
|
||||
ffb_vertex *v0, ffb_vertex *v1,
|
||||
ffb_vertex *v2, ffb_vertex *v3)
|
||||
{
|
||||
SWvertex v[4];
|
||||
|
||||
ffb_translate_vertex(ctx, v0, &v[0]);
|
||||
ffb_translate_vertex(ctx, v1, &v[1]);
|
||||
ffb_translate_vertex(ctx, v2, &v[2]);
|
||||
ffb_translate_vertex(ctx, v3, &v[3]);
|
||||
|
||||
_swrast_Quad(ctx, &v[0], &v[1], &v[2], &v[3]);
|
||||
}
|
||||
|
||||
void ffb_fallback_line(GLcontext *ctx, ffb_vertex *v0, ffb_vertex *v1)
|
||||
{
|
||||
SWvertex v[2];
|
||||
|
||||
ffb_translate_vertex(ctx, v0, &v[0]);
|
||||
ffb_translate_vertex(ctx, v1, &v[1]);
|
||||
|
||||
_swrast_Line(ctx, &v[0], &v[1]);
|
||||
}
|
||||
|
||||
void ffb_fallback_point(GLcontext *ctx, ffb_vertex *v0)
|
||||
{
|
||||
SWvertex v[1];
|
||||
|
||||
ffb_translate_vertex(ctx, v0, &v[0]);
|
||||
|
||||
_swrast_Point(ctx, &v[0]);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Rasterization functions for culled tris/quads *
|
||||
***********************************************************************/
|
||||
|
||||
static void ffb_nodraw_triangle(GLcontext *ctx, ffb_vertex *v0,
|
||||
ffb_vertex *v1, ffb_vertex *v2)
|
||||
{
|
||||
(void) (ctx && v0 && v1 && v2);
|
||||
}
|
||||
|
||||
static void ffb_nodraw_quad(GLcontext *ctx,
|
||||
ffb_vertex *v0, ffb_vertex *v1,
|
||||
ffb_vertex *v2, ffb_vertex *v3)
|
||||
{
|
||||
(void) (ctx && v0 && v1 && v2 && v3);
|
||||
}
|
||||
|
||||
static void ffb_update_cullsign(GLcontext *ctx)
|
||||
{
|
||||
GLfloat backface_sign = 1;
|
||||
|
||||
switch (ctx->Polygon.CullFaceMode) {
|
||||
case GL_BACK:
|
||||
if (ctx->Polygon.FrontFace==GL_CCW)
|
||||
backface_sign = -1;
|
||||
break;
|
||||
|
||||
case GL_FRONT:
|
||||
if (ctx->Polygon.FrontFace!=GL_CCW)
|
||||
backface_sign = -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
FFB_CONTEXT(ctx)->backface_sign = backface_sign;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Choose triangle/quad rasterize functions *
|
||||
***********************************************************************/
|
||||
|
||||
void ffbChooseTriangleState(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
GLuint ind = 0;
|
||||
|
||||
if (flags & DD_TRI_SMOOTH) {
|
||||
fmesa->draw_tri = ffb_fallback_triangle;
|
||||
fmesa->draw_quad = ffb_fallback_quad;
|
||||
return;
|
||||
}
|
||||
|
||||
if (flags & DD_FLATSHADE)
|
||||
ind |= FFB_TRI_FLAT_BIT;
|
||||
|
||||
if (ctx->Polygon.CullFlag) {
|
||||
if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
|
||||
fmesa->draw_tri = ffb_nodraw_triangle;
|
||||
fmesa->draw_quad = ffb_nodraw_quad;
|
||||
return;
|
||||
}
|
||||
|
||||
ind |= FFB_TRI_CULL_BIT;
|
||||
ffb_update_cullsign(ctx);
|
||||
} else
|
||||
FFB_CONTEXT(ctx)->backface_sign = 0;
|
||||
|
||||
/* If blending or the alpha test is enabled we need to
|
||||
* provide alpha components to the chip, else we can
|
||||
* do without it and thus feed vertex data to the chip
|
||||
* more efficiently.
|
||||
*/
|
||||
if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
|
||||
ind |= FFB_TRI_ALPHA_BIT;
|
||||
|
||||
fmesa->draw_tri = ffb_tri_tab[ind];
|
||||
fmesa->draw_quad = ffb_quad_tab[ind];
|
||||
}
|
||||
|
||||
static const GLenum reduced_prim[GL_POLYGON+1] = {
|
||||
GL_POINTS,
|
||||
GL_LINES,
|
||||
GL_LINES,
|
||||
GL_LINES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES
|
||||
};
|
||||
|
||||
static void ffbRenderPrimitive(GLcontext *ctx, GLenum prim);
|
||||
static void ffbRasterPrimitive(GLcontext *ctx, GLenum rprim);
|
||||
|
||||
/***********************************************************************
|
||||
* Build render functions from dd templates *
|
||||
***********************************************************************/
|
||||
|
||||
#define FFB_OFFSET_BIT 0x01
|
||||
#define FFB_TWOSIDE_BIT 0x02
|
||||
#define FFB_UNFILLED_BIT 0x04
|
||||
#define FFB_MAX_TRIFUNC 0x08
|
||||
|
||||
static struct {
|
||||
tnl_triangle_func triangle;
|
||||
tnl_quad_func quad;
|
||||
} rast_tab[FFB_MAX_TRIFUNC];
|
||||
|
||||
#define DO_OFFSET (IND & FFB_OFFSET_BIT)
|
||||
#define DO_UNFILLED (IND & FFB_UNFILLED_BIT)
|
||||
#define DO_TWOSIDE (IND & FFB_TWOSIDE_BIT)
|
||||
#define DO_FLAT 0
|
||||
#define DO_QUAD 1
|
||||
#define DO_FULL_QUAD 1
|
||||
#define DO_TRI 1
|
||||
#define DO_LINE 0
|
||||
#define DO_POINTS 0
|
||||
|
||||
#define QUAD( a, b, c, d ) fmesa->draw_quad( ctx, a, b, c, d )
|
||||
#define TRI( a, b, c ) fmesa->draw_tri( ctx, a, b, c )
|
||||
#define LINE( a, b ) fmesa->draw_line( ctx, a, b )
|
||||
#define POINT( a ) fmesa->draw_point( ctx, a )
|
||||
|
||||
#define HAVE_BACK_COLORS 1
|
||||
#define HAVE_RGBA 1
|
||||
#define HAVE_SPEC 0
|
||||
#define HAVE_HW_FLATSHADE 1
|
||||
#define VERTEX ffb_vertex
|
||||
#define TAB rast_tab
|
||||
|
||||
#define UNFILLED_TRI unfilled_tri
|
||||
#define UNFILLED_QUAD unfilled_quad
|
||||
#define DEPTH_SCALE (fmesa->depth_scale)
|
||||
#define VERT_X(_v) (_v->x)
|
||||
#define VERT_Y(_v) (_v->y)
|
||||
#define VERT_Z(_v) (_v->z)
|
||||
#define AREA_IS_CCW( a ) (a < fmesa->ffb_zero)
|
||||
#define GET_VERTEX(e) (&fmesa->verts[e])
|
||||
#define INSANE_VERTICES
|
||||
#define VERT_SET_Z(v,val) ((v)->z = (val))
|
||||
#define VERT_Z_ADD(v,val) ((v)->z += (val))
|
||||
|
||||
#define VERT_COPY_RGBA1( _v ) _v->color[0] = _v->color[1]
|
||||
#define VERT_COPY_RGBA( v0, v1 ) v0->color[0] = v1->color[0]
|
||||
#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->color[0]
|
||||
#define VERT_RESTORE_RGBA( idx ) v[idx]->color[0] = color[idx]
|
||||
|
||||
#define LOCAL_VARS(n) \
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable; \
|
||||
ffb_color color[n] = { { 0 } }; \
|
||||
(void) color; (void) dPriv;
|
||||
|
||||
/***********************************************************************
|
||||
* Helpers for rendering unfilled primitives *
|
||||
***********************************************************************/
|
||||
|
||||
#define RASTERIZE(x) if (fmesa->raster_primitive != reduced_prim[x]) \
|
||||
ffbRasterPrimitive( ctx, reduced_prim[x] )
|
||||
#define RENDER_PRIMITIVE fmesa->render_primitive
|
||||
#define TAG(x) x
|
||||
#include "tnl_dd/t_dd_unfilled.h"
|
||||
|
||||
/***********************************************************************
|
||||
* Generate GL render functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define IND (0)
|
||||
#define TAG(x) x
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (FFB_OFFSET_BIT)
|
||||
#define TAG(x) x##_offset
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (FFB_TWOSIDE_BIT)
|
||||
#define TAG(x) x##_twoside
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (FFB_TWOSIDE_BIT|FFB_OFFSET_BIT)
|
||||
#define TAG(x) x##_twoside_offset
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (FFB_UNFILLED_BIT)
|
||||
#define TAG(x) x##_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (FFB_OFFSET_BIT|FFB_UNFILLED_BIT)
|
||||
#define TAG(x) x##_offset_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (FFB_TWOSIDE_BIT|FFB_UNFILLED_BIT)
|
||||
#define TAG(x) x##_twoside_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (FFB_TWOSIDE_BIT|FFB_OFFSET_BIT|FFB_UNFILLED_BIT)
|
||||
#define TAG(x) x##_twoside_offset_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
static void init_rast_tab( void )
|
||||
{
|
||||
init();
|
||||
init_offset();
|
||||
init_twoside();
|
||||
init_twoside_offset();
|
||||
init_unfilled();
|
||||
init_offset_unfilled();
|
||||
init_twoside_unfilled();
|
||||
init_twoside_offset_unfilled();
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render clipped primitives */
|
||||
/**********************************************************************/
|
||||
|
||||
static void ffbRenderClippedPolygon(GLcontext *ctx, const GLuint *elts, GLuint n)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint prim = fmesa->render_primitive;
|
||||
|
||||
/* Render the new vertices as an unclipped polygon. */
|
||||
{
|
||||
GLuint *tmp = VB->Elts;
|
||||
VB->Elts = (GLuint *)elts;
|
||||
tnl->Driver.Render.PrimTabElts[GL_POLYGON](ctx, 0, n, PRIM_BEGIN|PRIM_END);
|
||||
VB->Elts = tmp;
|
||||
}
|
||||
|
||||
/* Restore the render primitive. */
|
||||
if (prim != GL_POLYGON)
|
||||
tnl->Driver.Render.PrimitiveNotify(ctx, prim);
|
||||
}
|
||||
|
||||
static void ffbRenderClippedLine(GLcontext *ctx, GLuint ii, GLuint jj)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.Render.Line(ctx, ii, jj);
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render unclipped begin/end objects */
|
||||
/**********************************************************************/
|
||||
|
||||
static void ffb_vb_noop(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
|
||||
{
|
||||
(void)(ctx && start && count && flags);
|
||||
}
|
||||
|
||||
#define ELT(x) x
|
||||
|
||||
#define IND 0
|
||||
#define TAG(x) x
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_FLAT_BIT)
|
||||
#define TAG(x) x##_flat
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_ALPHA_BIT)
|
||||
#define TAG(x) x##_alpha
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT)
|
||||
#define TAG(x) x##_flat_alpha
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_tricull
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_FLAT_BIT | FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_flat_tricull
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_alpha_tricull
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_flat_alpha_tricull
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#undef ELT
|
||||
#define ELT(x) elt[x]
|
||||
|
||||
#define IND 0
|
||||
#define TAG(x) x##_elt
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_FLAT_BIT)
|
||||
#define TAG(x) x##_flat_elt
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_ALPHA_BIT)
|
||||
#define TAG(x) x##_alpha_elt
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT)
|
||||
#define TAG(x) x##_flat_alpha_elt
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_tricull_elt
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_FLAT_BIT | FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_flat_tricull_elt
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_alpha_tricull_elt
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
|
||||
#define TAG(x) x##_flat_alpha_tricull_elt
|
||||
#include "ffb_rendertmp.h"
|
||||
|
||||
static void *render_tabs[MAX_FFB_RENDER_FUNCS];
|
||||
static void *render_tabs_elt[MAX_FFB_RENDER_FUNCS];
|
||||
|
||||
static void init_render_tab(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
render_tabs[0] = render_tab;
|
||||
render_tabs[FFB_FLAT_BIT] = render_tab_flat;
|
||||
render_tabs[FFB_ALPHA_BIT] = render_tab_alpha;
|
||||
render_tabs[FFB_FLAT_BIT|FFB_ALPHA_BIT] = render_tab_flat_alpha;
|
||||
render_tabs[FFB_TRI_CULL_BIT] = render_tab_tricull;
|
||||
render_tabs[FFB_FLAT_BIT|FFB_TRI_CULL_BIT] = render_tab_flat_tricull;
|
||||
render_tabs[FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = render_tab_alpha_tricull;
|
||||
render_tabs[FFB_FLAT_BIT|FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] =
|
||||
render_tab_flat_alpha_tricull;
|
||||
|
||||
render_tabs_elt[0] = render_tab_elt;
|
||||
render_tabs_elt[FFB_FLAT_BIT] = render_tab_flat_elt;
|
||||
render_tabs_elt[FFB_ALPHA_BIT] = render_tab_alpha_elt;
|
||||
render_tabs_elt[FFB_FLAT_BIT|FFB_ALPHA_BIT] = render_tab_flat_alpha_elt;
|
||||
render_tabs_elt[FFB_TRI_CULL_BIT] = render_tab_tricull_elt;
|
||||
render_tabs_elt[FFB_FLAT_BIT|FFB_TRI_CULL_BIT] = render_tab_flat_tricull_elt;
|
||||
render_tabs_elt[FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = render_tab_alpha_tricull_elt;
|
||||
render_tabs_elt[FFB_FLAT_BIT|FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] =
|
||||
render_tab_flat_alpha_tricull_elt;
|
||||
|
||||
for (i = 0; i < MAX_FFB_RENDER_FUNCS; i++) {
|
||||
tnl_render_func *rf = render_tabs[i];
|
||||
tnl_render_func *rfe = render_tabs_elt[i];
|
||||
|
||||
if (i & FFB_TRI_CULL_BIT) {
|
||||
int from_idx = (i & ~FFB_TRI_CULL_BIT);
|
||||
tnl_render_func *rf_from = render_tabs[from_idx];
|
||||
tnl_render_func *rfe_from = render_tabs_elt[from_idx];
|
||||
int j;
|
||||
|
||||
for (j = GL_POINTS; j < GL_TRIANGLES; j++) {
|
||||
rf[j] = rf_from[j];
|
||||
rfe[j] = rfe_from[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Choose render functions */
|
||||
/**********************************************************************/
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
static void ffbPrintRenderFlags(GLuint index, GLuint render_index)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ffbChooseRenderState: "
|
||||
"index(%s%s%s) "
|
||||
"render_index(%s%s%s)\n",
|
||||
((index & FFB_TWOSIDE_BIT) ? "twoside " : ""),
|
||||
((index & FFB_OFFSET_BIT) ? "offset " : ""),
|
||||
((index & FFB_UNFILLED_BIT) ? "unfilled " : ""),
|
||||
((render_index & FFB_FLAT_BIT) ? "flat " : ""),
|
||||
((render_index & FFB_ALPHA_BIT) ? "alpha " : ""),
|
||||
((render_index & FFB_TRI_CULL_BIT) ? "tricull " : ""));
|
||||
}
|
||||
#endif
|
||||
|
||||
void ffbChooseRenderState(GLcontext *ctx)
|
||||
{
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint index = 0;
|
||||
|
||||
/* Per-primitive fallbacks and the selection of fmesa->draw_* are
|
||||
* handled elsewhere.
|
||||
*/
|
||||
if (flags & DD_TRI_LIGHT_TWOSIDE)
|
||||
index |= FFB_TWOSIDE_BIT;
|
||||
|
||||
if (flags & DD_TRI_OFFSET)
|
||||
index |= FFB_OFFSET_BIT;
|
||||
|
||||
if (flags & DD_TRI_UNFILLED)
|
||||
index |= FFB_UNFILLED_BIT;
|
||||
|
||||
tnl->Driver.Render.Triangle = rast_tab[index].triangle;
|
||||
tnl->Driver.Render.Quad = rast_tab[index].quad;
|
||||
|
||||
if (index == 0) {
|
||||
GLuint render_index = 0;
|
||||
|
||||
if (flags & DD_FLATSHADE)
|
||||
render_index |= FFB_FLAT_BIT;
|
||||
|
||||
if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
|
||||
render_index |= FFB_ALPHA_BIT;
|
||||
|
||||
if (ctx->Polygon.CullFlag)
|
||||
render_index |= FFB_TRI_CULL_BIT;
|
||||
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
ffbPrintRenderFlags(index, render_index);
|
||||
#endif
|
||||
tnl->Driver.Render.PrimTabVerts = render_tabs[render_index];
|
||||
tnl->Driver.Render.PrimTabElts = render_tabs_elt[render_index];
|
||||
} else {
|
||||
#ifdef FFB_RENDER_TRACE
|
||||
ffbPrintRenderFlags(index, 0);
|
||||
#endif
|
||||
tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
|
||||
tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
|
||||
}
|
||||
|
||||
tnl->Driver.Render.ClippedPolygon = ffbRenderClippedPolygon;
|
||||
tnl->Driver.Render.ClippedLine = ffbRenderClippedLine;
|
||||
}
|
||||
|
||||
static void ffbRunPipeline(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
if (fmesa->bad_fragment_attrs == 0 &&
|
||||
fmesa->new_gl_state) {
|
||||
if (fmesa->new_gl_state & _FFB_NEW_TRIANGLE)
|
||||
ffbChooseTriangleState(ctx);
|
||||
if (fmesa->new_gl_state & _FFB_NEW_LINE)
|
||||
ffbChooseLineState(ctx);
|
||||
if (fmesa->new_gl_state & _FFB_NEW_POINT)
|
||||
ffbChoosePointState(ctx);
|
||||
if (fmesa->new_gl_state & _FFB_NEW_RENDER)
|
||||
ffbChooseRenderState(ctx);
|
||||
if (fmesa->new_gl_state & _FFB_NEW_VERTEX)
|
||||
ffbChooseVertexState(ctx);
|
||||
|
||||
fmesa->new_gl_state = 0;
|
||||
}
|
||||
|
||||
_tnl_run_pipeline(ctx);
|
||||
}
|
||||
|
||||
static void ffbRenderStart(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
LOCK_HARDWARE(fmesa);
|
||||
fmesa->hw_locked = 1;
|
||||
|
||||
if (fmesa->state_dirty != 0)
|
||||
ffbSyncHardware(fmesa);
|
||||
}
|
||||
|
||||
static void ffbRenderFinish(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
fmesa->hw_locked = 0;
|
||||
}
|
||||
|
||||
/* Even when doing full software rendering we need to
|
||||
* wrap render{start,finish} so that the hardware is kept
|
||||
* in sync (because multipass rendering changes the write
|
||||
* buffer etc.)
|
||||
*/
|
||||
static void ffbSWRenderStart(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
LOCK_HARDWARE(fmesa);
|
||||
fmesa->hw_locked = 1;
|
||||
|
||||
if (fmesa->state_dirty != 0)
|
||||
ffbSyncHardware(fmesa);
|
||||
}
|
||||
|
||||
static void ffbSWRenderFinish(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
fmesa->hw_locked = 0;
|
||||
}
|
||||
|
||||
static void ffbRasterPrimitive(GLcontext *ctx, GLenum rprim)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
GLuint drawop, fbc, ppc;
|
||||
int do_sw = 0;
|
||||
|
||||
fmesa->raster_primitive = rprim;
|
||||
|
||||
drawop = fmesa->drawop;
|
||||
fbc = fmesa->fbc;
|
||||
ppc = fmesa->ppc & ~(FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK);
|
||||
|
||||
#ifdef STATE_TRACE
|
||||
fprintf(stderr,
|
||||
"ffbReducedPrimitiveChange: rprim(%d) ", rprim);
|
||||
#endif
|
||||
switch(rprim) {
|
||||
case GL_POINTS:
|
||||
#ifdef STATE_TRACE
|
||||
fprintf(stderr, "GL_POINTS ");
|
||||
#endif
|
||||
if (fmesa->draw_point == ffb_fallback_point) {
|
||||
do_sw = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctx->Point.SmoothFlag) {
|
||||
ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST);
|
||||
drawop = FFB_DRAWOP_AADOT;
|
||||
} else {
|
||||
ppc |= (FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
|
||||
drawop = FFB_DRAWOP_DOT;
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_LINES:
|
||||
#ifdef STATE_TRACE
|
||||
fprintf(stderr, "GL_LINES ");
|
||||
#endif
|
||||
if (fmesa->draw_line == ffb_fallback_line) {
|
||||
do_sw = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
||||
ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
|
||||
} else {
|
||||
ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
|
||||
}
|
||||
if (ctx->Line.SmoothFlag)
|
||||
drawop = FFB_DRAWOP_AALINE;
|
||||
else
|
||||
drawop = FFB_DRAWOP_DDLINE;
|
||||
break;
|
||||
|
||||
case GL_TRIANGLES:
|
||||
#ifdef STATE_TRACE
|
||||
fprintf(stderr, "GL_POLYGON ");
|
||||
#endif
|
||||
if (fmesa->draw_tri == ffb_fallback_triangle) {
|
||||
do_sw = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
ppc &= ~FFB_PPC_APE_MASK;
|
||||
if (ctx->Polygon.StippleFlag)
|
||||
ppc |= FFB_PPC_APE_ENABLE;
|
||||
else
|
||||
ppc |= FFB_PPC_APE_DISABLE;
|
||||
|
||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
||||
ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
|
||||
} else {
|
||||
ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
|
||||
}
|
||||
drawop = FFB_DRAWOP_TRIANGLE;
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef STATE_TRACE
|
||||
fprintf(stderr, "unknown %d!\n", rprim);
|
||||
#endif
|
||||
return;
|
||||
};
|
||||
|
||||
#ifdef STATE_TRACE
|
||||
fprintf(stderr, "do_sw(%d) ", do_sw);
|
||||
#endif
|
||||
if (do_sw != 0) {
|
||||
fbc &= ~(FFB_FBC_WB_C);
|
||||
fbc &= ~(FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK);
|
||||
fbc |= FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK;
|
||||
ppc &= ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK |
|
||||
FFB_PPC_DCE_MASK | FFB_PPC_APE_MASK);
|
||||
ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR | FFB_PPC_XS_WID |
|
||||
FFB_PPC_ABE_DISABLE | FFB_PPC_DCE_DISABLE |
|
||||
FFB_PPC_APE_DISABLE);
|
||||
} else {
|
||||
fbc |= FFB_FBC_WB_C;
|
||||
fbc &= ~(FFB_FBC_RGBE_MASK);
|
||||
fbc |= FFB_FBC_RGBE_MASK;
|
||||
ppc &= ~(FFB_PPC_ABE_MASK | FFB_PPC_XS_MASK);
|
||||
if (ctx->Color.BlendEnabled) {
|
||||
if ((rprim == GL_POINTS && !ctx->Point.SmoothFlag) ||
|
||||
(rprim != GL_POINTS && ctx->_TriangleCaps & DD_FLATSHADE))
|
||||
ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_CONST;
|
||||
else
|
||||
ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_VAR;
|
||||
} else {
|
||||
ppc |= FFB_PPC_ABE_DISABLE | FFB_PPC_XS_WID;
|
||||
}
|
||||
}
|
||||
#ifdef STATE_TRACE
|
||||
fprintf(stderr, "fbc(%08x) ppc(%08x)\n", fbc, ppc);
|
||||
#endif
|
||||
|
||||
FFBFifo(fmesa, 4);
|
||||
if (fmesa->drawop != drawop)
|
||||
fmesa->regs->drawop = fmesa->drawop = drawop;
|
||||
if (fmesa->fbc != fbc)
|
||||
fmesa->regs->fbc = fmesa->fbc = fbc;
|
||||
if (fmesa->ppc != ppc)
|
||||
fmesa->regs->ppc = fmesa->ppc = ppc;
|
||||
if (do_sw != 0) {
|
||||
fmesa->regs->cmp =
|
||||
(fmesa->cmp & ~(0xff<<16)) | (0x80 << 16);
|
||||
} else
|
||||
fmesa->regs->cmp = fmesa->cmp;
|
||||
}
|
||||
|
||||
static void ffbRenderPrimitive(GLcontext *ctx, GLenum prim)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
GLuint rprim = reduced_prim[prim];
|
||||
|
||||
fmesa->render_primitive = prim;
|
||||
|
||||
if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
|
||||
return;
|
||||
|
||||
if (fmesa->raster_primitive != rprim) {
|
||||
ffbRasterPrimitive( ctx, rprim );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Transition to/from hardware rasterization. */
|
||||
/**********************************************************************/
|
||||
|
||||
static char *fallbackStrings[] = {
|
||||
"Fog enabled",
|
||||
"Blend function",
|
||||
"Blend ROP",
|
||||
"Blend equation",
|
||||
"Stencil",
|
||||
"Texture",
|
||||
"LIBGL_SOFTWARE_RENDERING"
|
||||
};
|
||||
|
||||
static char *getFallbackString(GLuint bit)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (bit > 1) {
|
||||
i++;
|
||||
bit >>= 1;
|
||||
}
|
||||
return fallbackStrings[i];
|
||||
}
|
||||
|
||||
void ffbFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint oldfallback = fmesa->bad_fragment_attrs;
|
||||
|
||||
if (mode) {
|
||||
fmesa->bad_fragment_attrs |= bit;
|
||||
if (oldfallback == 0) {
|
||||
/* FFB_FIREVERTICES(fmesa); */
|
||||
_swsetup_Wakeup( ctx );
|
||||
if (fmesa->debugFallbacks)
|
||||
fprintf(stderr, "FFB begin software fallback: 0x%x %s\n",
|
||||
bit, getFallbackString(bit));
|
||||
}
|
||||
} else {
|
||||
fmesa->bad_fragment_attrs &= ~bit;
|
||||
if (oldfallback == bit) {
|
||||
_swrast_flush( ctx );
|
||||
|
||||
tnl->Driver.Render.Start = ffbRenderStart;
|
||||
tnl->Driver.Render.PrimitiveNotify = ffbRenderPrimitive;
|
||||
tnl->Driver.Render.Finish = ffbRenderFinish;
|
||||
fmesa->new_gl_state = ~0;
|
||||
|
||||
/* Just re-choose everything:
|
||||
*/
|
||||
ffbChooseVertexState(ctx);
|
||||
ffbChooseRenderState(ctx);
|
||||
ffbChooseTriangleState(ctx);
|
||||
ffbChooseLineState(ctx);
|
||||
ffbChoosePointState(ctx);
|
||||
|
||||
if (fmesa->debugFallbacks)
|
||||
fprintf(stderr, "FFB end software fallback: 0x%x %s\n",
|
||||
bit, getFallbackString(bit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Initialization. */
|
||||
/**********************************************************************/
|
||||
|
||||
void ffbDDInitRenderFuncs( GLcontext *ctx )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
SWcontext *swrast = SWRAST_CONTEXT(ctx);
|
||||
static int firsttime = 1;
|
||||
|
||||
if (firsttime) {
|
||||
init_rast_tab();
|
||||
init_tri_tab();
|
||||
init_render_tab();
|
||||
firsttime = 0;
|
||||
}
|
||||
|
||||
tnl->Driver.RunPipeline = ffbRunPipeline;
|
||||
tnl->Driver.Render.Start = ffbRenderStart;
|
||||
tnl->Driver.Render.Finish = ffbRenderFinish;
|
||||
tnl->Driver.Render.PrimitiveNotify = ffbRenderPrimitive;
|
||||
tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
|
||||
tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
|
||||
tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
|
||||
|
||||
swrast->Driver.SpanRenderStart = ffbSWRenderStart;
|
||||
swrast->Driver.SpanRenderFinish = ffbSWRenderFinish;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
#ifndef _FFB_TRIS_H
|
||||
#define _FFB_TRIS_H
|
||||
|
||||
extern void ffbDDInitRenderFuncs( GLcontext *ctx );
|
||||
|
||||
|
||||
#define _FFB_NEW_RENDER (_DD_NEW_TRI_LIGHT_TWOSIDE | \
|
||||
_DD_NEW_TRI_OFFSET | \
|
||||
_DD_NEW_TRI_UNFILLED)
|
||||
|
||||
extern void ffbChooseRenderState(GLcontext *ctx);
|
||||
|
||||
|
||||
#define _FFB_NEW_TRIANGLE (_DD_NEW_TRI_SMOOTH | \
|
||||
_DD_NEW_FLATSHADE | \
|
||||
_NEW_POLYGON | \
|
||||
_NEW_COLOR)
|
||||
|
||||
extern void ffbChooseTriangleState(GLcontext *ctx);
|
||||
|
||||
extern void ffbFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
|
||||
#define FALLBACK( ctx, bit, mode ) ffbFallback( ctx, bit, mode )
|
||||
|
||||
#endif /* !(_FFB_TRIS_H) */
|
||||
@@ -1,238 +0,0 @@
|
||||
|
||||
static void TAG(ffb_triangle)( GLcontext *ctx,
|
||||
ffb_vertex *v0,
|
||||
ffb_vertex *v1,
|
||||
ffb_vertex *v2 )
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
ffb_fbcPtr ffb = fmesa->regs;
|
||||
#if (IND & FFB_TRI_FLAT_BIT)
|
||||
GLuint const_fg;
|
||||
#endif
|
||||
FFB_DELAYED_VIEWPORT_VARS;
|
||||
|
||||
#ifdef TRI_DEBUG
|
||||
fprintf(stderr, "FFB: ffb_triangle ["
|
||||
#if (IND & FFB_TRI_CULL_BIT)
|
||||
" CULL"
|
||||
#endif
|
||||
#if (IND & FFB_TRI_FLAT_BIT)
|
||||
" FLAT"
|
||||
#endif
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
" ALPHA"
|
||||
#endif
|
||||
" ]\n");
|
||||
#endif
|
||||
|
||||
#if (IND & FFB_TRI_CULL_BIT)
|
||||
{ /* NOTE: These are not viewport transformed yet. */
|
||||
GLfloat ex = v1->x - v0->x;
|
||||
GLfloat ey = v1->y - v0->y;
|
||||
GLfloat fx = v2->x - v0->x;
|
||||
GLfloat fy = v2->y - v0->y;
|
||||
GLfloat c = ex*fy-ey*fx;
|
||||
|
||||
/* Culled... */
|
||||
if (c * fmesa->backface_sign > fmesa->ffb_zero)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (IND & FFB_TRI_FLAT_BIT)
|
||||
const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v2->color[0] );
|
||||
#ifdef TRI_DEBUG
|
||||
fprintf(stderr, "FFB_tri: const_fg %08x (B[%f] G[%f] R[%f])\n",
|
||||
const_fg,
|
||||
FFB_2_30_FIXED_TO_FLOAT(v2->color[0].blue),
|
||||
FFB_2_30_FIXED_TO_FLOAT(v2->color[0].green),
|
||||
FFB_2_30_FIXED_TO_FLOAT(v2->color[0].red));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if (IND & FFB_TRI_FLAT_BIT)
|
||||
FFBFifo(fmesa, 1);
|
||||
ffb->fg = const_fg;
|
||||
#endif
|
||||
|
||||
#if (IND & FFB_TRI_FLAT_BIT)
|
||||
FFBFifo(fmesa, 9);
|
||||
#else
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
FFBFifo(fmesa, 21);
|
||||
#else
|
||||
FFBFifo(fmesa, 18);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FFB_DUMP_VERTEX(v0);
|
||||
#if !(IND & FFB_TRI_FLAT_BIT)
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
ffb->alpha = FFB_GET_ALPHA(v0);
|
||||
#endif
|
||||
ffb->red = FFB_GET_RED(v0);
|
||||
ffb->green = FFB_GET_GREEN(v0);
|
||||
ffb->blue = FFB_GET_BLUE(v0);
|
||||
#endif
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_DUMP_VERTEX(v1);
|
||||
#if !(IND & FFB_TRI_FLAT_BIT)
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
ffb->alpha = FFB_GET_ALPHA(v1);
|
||||
#endif
|
||||
ffb->red = FFB_GET_RED(v1);
|
||||
ffb->green = FFB_GET_GREEN(v1);
|
||||
ffb->blue = FFB_GET_BLUE(v1);
|
||||
#endif
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
|
||||
FFB_DUMP_VERTEX(v2);
|
||||
#if !(IND & FFB_TRI_FLAT_BIT)
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
ffb->alpha = FFB_GET_ALPHA(v2);
|
||||
#endif
|
||||
ffb->red = FFB_GET_RED(v2);
|
||||
ffb->green = FFB_GET_GREEN(v2);
|
||||
ffb->blue = FFB_GET_BLUE(v2);
|
||||
#endif
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->y = FFB_GET_Y(v2);
|
||||
ffb->x = FFB_GET_X(v2);
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
|
||||
static void TAG(ffb_quad)(GLcontext *ctx,
|
||||
ffb_vertex *v0,
|
||||
ffb_vertex *v1,
|
||||
ffb_vertex *v2,
|
||||
ffb_vertex *v3 )
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
ffb_fbcPtr ffb = fmesa->regs;
|
||||
#if (IND & FFB_TRI_FLAT_BIT)
|
||||
GLuint const_fg;
|
||||
#endif
|
||||
FFB_DELAYED_VIEWPORT_VARS;
|
||||
|
||||
#ifdef TRI_DEBUG
|
||||
fprintf(stderr, "FFB: ffb_quad ["
|
||||
#if (IND & FFB_TRI_CULL_BIT)
|
||||
" CULL"
|
||||
#endif
|
||||
#if (IND & FFB_TRI_FLAT_BIT)
|
||||
" FLAT"
|
||||
#endif
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
" ALPHA"
|
||||
#endif
|
||||
" ]\n");
|
||||
#endif /* TRI_DEBUG */
|
||||
|
||||
#if (IND & FFB_TRI_CULL_BIT)
|
||||
{ /* NOTE: These are not viewport transformed yet. */
|
||||
GLfloat ex = v2->x - v0->x;
|
||||
GLfloat ey = v2->y - v0->y;
|
||||
GLfloat fx = v3->x - v1->x;
|
||||
GLfloat fy = v3->y - v1->y;
|
||||
GLfloat c = ex*fy-ey*fx;
|
||||
|
||||
/* Culled... */
|
||||
if (c * fmesa->backface_sign > fmesa->ffb_zero)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (IND & FFB_TRI_FLAT_BIT)
|
||||
const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v3->color[0] );
|
||||
#ifdef TRI_DEBUG
|
||||
fprintf(stderr, "FFB_quad: const_fg %08x (B[%f] G[%f] R[%f])\n",
|
||||
const_fg,
|
||||
FFB_2_30_FIXED_TO_FLOAT(v3->color[0].blue),
|
||||
FFB_2_30_FIXED_TO_FLOAT(v3->color[0].green),
|
||||
FFB_2_30_FIXED_TO_FLOAT(v3->color[0].red));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if (IND & FFB_TRI_FLAT_BIT)
|
||||
FFBFifo(fmesa, 13);
|
||||
ffb->fg = const_fg;
|
||||
#else
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
FFBFifo(fmesa, 28);
|
||||
#else
|
||||
FFBFifo(fmesa, 24);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FFB_DUMP_VERTEX(v0);
|
||||
#if !(IND & FFB_TRI_FLAT_BIT)
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
ffb->alpha = FFB_GET_ALPHA(v0);
|
||||
#endif
|
||||
ffb->red = FFB_GET_RED(v0);
|
||||
ffb->green = FFB_GET_GREEN(v0);
|
||||
ffb->blue = FFB_GET_BLUE(v0);
|
||||
#endif
|
||||
ffb->z = FFB_GET_Z(v0);
|
||||
ffb->ryf = FFB_GET_Y(v0);
|
||||
ffb->rxf = FFB_GET_X(v0);
|
||||
|
||||
FFB_DUMP_VERTEX(v1);
|
||||
#if !(IND & FFB_TRI_FLAT_BIT)
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
ffb->alpha = FFB_GET_ALPHA(v1);
|
||||
#endif
|
||||
ffb->red = FFB_GET_RED(v1);
|
||||
ffb->green = FFB_GET_GREEN(v1);
|
||||
ffb->blue = FFB_GET_BLUE(v1);
|
||||
#endif
|
||||
ffb->z = FFB_GET_Z(v1);
|
||||
ffb->y = FFB_GET_Y(v1);
|
||||
ffb->x = FFB_GET_X(v1);
|
||||
|
||||
FFB_DUMP_VERTEX(v2);
|
||||
#if !(IND & FFB_TRI_FLAT_BIT)
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
ffb->alpha = FFB_GET_ALPHA(v2);
|
||||
#endif
|
||||
ffb->red = FFB_GET_RED(v2);
|
||||
ffb->green = FFB_GET_GREEN(v2);
|
||||
ffb->blue = FFB_GET_BLUE(v2);
|
||||
#endif
|
||||
ffb->z = FFB_GET_Z(v2);
|
||||
ffb->y = FFB_GET_Y(v2);
|
||||
ffb->x = FFB_GET_X(v2);
|
||||
|
||||
FFB_DUMP_VERTEX(v3);
|
||||
#if !(IND & FFB_TRI_FLAT_BIT)
|
||||
#if (IND & FFB_TRI_ALPHA_BIT)
|
||||
ffb->alpha = FFB_GET_ALPHA(v3);
|
||||
#endif
|
||||
ffb->red = FFB_GET_RED(v3);
|
||||
ffb->green = FFB_GET_GREEN(v3);
|
||||
ffb->blue = FFB_GET_BLUE(v3);
|
||||
#endif
|
||||
ffb->z = FFB_GET_Z(v3);
|
||||
ffb->dmyf = FFB_GET_Y(v3);
|
||||
ffb->dmxf = FFB_GET_X(v3);
|
||||
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
static void TAG(ffb_init)(void)
|
||||
{
|
||||
ffb_tri_tab[IND] = TAG(ffb_triangle);
|
||||
ffb_quad_tab[IND] = TAG(ffb_quad);
|
||||
}
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
||||
@@ -1,207 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000, 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "ffb_xmesa.h"
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_vb.h"
|
||||
#include "main/imports.h"
|
||||
#include "tnl/t_context.h"
|
||||
|
||||
#undef VB_DEBUG
|
||||
|
||||
static void ffb_copy_pv_oneside(GLcontext *ctx, GLuint edst, GLuint esrc)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
ffb_vertex *dst = &fmesa->verts[edst];
|
||||
ffb_vertex *src = &fmesa->verts[esrc];
|
||||
|
||||
#ifdef VB_DEBUG
|
||||
fprintf(stderr, "ffb_copy_pv_oneside: edst(%d) esrc(%d)\n", edst, esrc);
|
||||
#endif
|
||||
dst->color[0].alpha = src->color[0].alpha;
|
||||
dst->color[0].red = src->color[0].red;
|
||||
dst->color[0].green = src->color[0].green;
|
||||
dst->color[0].blue = src->color[0].blue;
|
||||
}
|
||||
|
||||
static void ffb_copy_pv_twoside(GLcontext *ctx, GLuint edst, GLuint esrc)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
ffb_vertex *dst = &fmesa->verts[edst];
|
||||
ffb_vertex *src = &fmesa->verts[esrc];
|
||||
|
||||
#ifdef VB_DEBUG
|
||||
fprintf(stderr, "ffb_copy_pv_twoside: edst(%d) esrc(%d)\n", edst, esrc);
|
||||
#endif
|
||||
dst->color[0].alpha = src->color[0].alpha;
|
||||
dst->color[0].red = src->color[0].red;
|
||||
dst->color[0].green = src->color[0].green;
|
||||
dst->color[0].blue = src->color[0].blue;
|
||||
dst->color[1].alpha = src->color[1].alpha;
|
||||
dst->color[1].red = src->color[1].red;
|
||||
dst->color[1].green = src->color[1].green;
|
||||
dst->color[1].blue = src->color[1].blue;
|
||||
}
|
||||
|
||||
#define FFB_VB_RGBA_BIT 0x01
|
||||
#define FFB_VB_XYZ_BIT 0x02
|
||||
#define FFB_VB_TWOSIDE_BIT 0x04
|
||||
#define FFB_VB_MAX 0x08
|
||||
|
||||
typedef void (*ffb_emit_func)(GLcontext *, GLuint, GLuint);
|
||||
|
||||
static struct {
|
||||
ffb_emit_func emit;
|
||||
tnl_interp_func interp;
|
||||
} setup_tab[FFB_VB_MAX];
|
||||
|
||||
|
||||
#define IND (FFB_VB_XYZ_BIT)
|
||||
#define TAG(x) x##_w
|
||||
#include "ffb_vbtmp.h"
|
||||
|
||||
#define IND (FFB_VB_RGBA_BIT)
|
||||
#define TAG(x) x##_g
|
||||
#include "ffb_vbtmp.h"
|
||||
|
||||
#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT)
|
||||
#define TAG(x) x##_wg
|
||||
#include "ffb_vbtmp.h"
|
||||
|
||||
#define IND (FFB_VB_TWOSIDE_BIT)
|
||||
#define TAG(x) x##_t
|
||||
#include "ffb_vbtmp.h"
|
||||
|
||||
#define IND (FFB_VB_XYZ_BIT | FFB_VB_TWOSIDE_BIT)
|
||||
#define TAG(x) x##_wt
|
||||
#include "ffb_vbtmp.h"
|
||||
|
||||
#define IND (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT)
|
||||
#define TAG(x) x##_gt
|
||||
#include "ffb_vbtmp.h"
|
||||
|
||||
#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT)
|
||||
#define TAG(x) x##_wgt
|
||||
#include "ffb_vbtmp.h"
|
||||
|
||||
static void init_setup_tab( void )
|
||||
{
|
||||
init_w();
|
||||
init_g();
|
||||
init_wg();
|
||||
init_t();
|
||||
init_wt();
|
||||
init_gt();
|
||||
init_wgt();
|
||||
}
|
||||
|
||||
#ifdef VB_DEBUG
|
||||
static void ffbPrintSetupFlags(char *msg, GLuint flags)
|
||||
{
|
||||
fprintf(stderr, "%s(%x): %s%s%s\n",
|
||||
msg,
|
||||
(int)flags,
|
||||
(flags & FFB_VB_XYZ_BIT) ? " xyz," : "",
|
||||
(flags & FFB_VB_RGBA_BIT) ? " rgba," : "",
|
||||
(flags & FFB_VB_TWOSIDE_BIT) ? " twoside," : "");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void ffbDDBuildVertices(GLcontext *ctx, GLuint start, GLuint count,
|
||||
GLuint newinputs)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
newinputs |= fmesa->setupnewinputs;
|
||||
fmesa->setupnewinputs = 0;
|
||||
|
||||
if (!newinputs)
|
||||
return;
|
||||
|
||||
if (newinputs & VERT_BIT_POS) {
|
||||
setup_tab[fmesa->setupindex].emit(ctx, start, count);
|
||||
} else {
|
||||
GLuint ind = 0;
|
||||
|
||||
if (newinputs & VERT_BIT_COLOR0)
|
||||
ind |= (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT);
|
||||
|
||||
ind &= fmesa->setupindex;
|
||||
|
||||
if (ind)
|
||||
setup_tab[ind].emit(ctx, start, count);
|
||||
}
|
||||
}
|
||||
|
||||
void ffbChooseVertexState( GLcontext *ctx )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
int ind = FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT;
|
||||
|
||||
if (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
|
||||
ind |= FFB_VB_TWOSIDE_BIT;
|
||||
|
||||
#ifdef VB_DEBUG
|
||||
ffbPrintSetupFlags("ffb: full setup function", ind);
|
||||
#endif
|
||||
|
||||
fmesa->setupindex = ind;
|
||||
|
||||
tnl->Driver.Render.BuildVertices = ffbDDBuildVertices;
|
||||
tnl->Driver.Render.Interp = setup_tab[ind].interp;
|
||||
if (ind & FFB_VB_TWOSIDE_BIT)
|
||||
tnl->Driver.Render.CopyPV = ffb_copy_pv_twoside;
|
||||
else
|
||||
tnl->Driver.Render.CopyPV = ffb_copy_pv_oneside;
|
||||
}
|
||||
|
||||
void ffbInitVB( GLcontext *ctx )
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
|
||||
|
||||
fmesa->verts = (ffb_vertex *)_mesa_align_malloc(size * sizeof(ffb_vertex), 32);
|
||||
|
||||
{
|
||||
static int firsttime = 1;
|
||||
if (firsttime) {
|
||||
init_setup_tab();
|
||||
firsttime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ffbFreeVB( GLcontext *ctx )
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
if (fmesa->verts) {
|
||||
_mesa_align_free(fmesa->verts);
|
||||
fmesa->verts = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
|
||||
#ifndef _FFB_VB_H
|
||||
#define _FFB_VB_H
|
||||
|
||||
#include "main/mtypes.h"
|
||||
#include "main/macros.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define __FFB_2_30_FIXED_SCALE 1073741824.0f
|
||||
#define FFB_2_30_FLOAT_TO_FIXED(X) \
|
||||
(IROUND((X) * fmesa->ffb_2_30_fixed_scale))
|
||||
#define FFB_2_30_FIXED_TO_FLOAT(X) \
|
||||
(((GLfloat)(X)) * fmesa->ffb_one_over_2_30_fixed_scale)
|
||||
|
||||
#define __FFB_16_16_FIXED_SCALE 65536.0f
|
||||
#define FFB_16_16_FLOAT_TO_FIXED(X) \
|
||||
(IROUND((X) * fmesa->ffb_16_16_fixed_scale))
|
||||
#define FFB_16_16_FIXED_TO_FLOAT(X) \
|
||||
(((GLfloat)(X)) * fmesa->ffb_one_over_16_16_fixed_scale)
|
||||
|
||||
#define FFB_Z_FROM_FLOAT(VAL) FFB_2_30_FLOAT_TO_FIXED(VAL)
|
||||
#define FFB_Z_TO_FLOAT(VAL) FFB_2_30_FIXED_TO_FLOAT(VAL)
|
||||
#define FFB_XY_FROM_FLOAT(VAL) FFB_16_16_FLOAT_TO_FIXED(VAL)
|
||||
#define FFB_XY_TO_FLOAT(VAL) FFB_16_16_FIXED_TO_FLOAT(VAL)
|
||||
|
||||
#define FFB_UBYTE_FROM_COLOR(VAL) ((IROUND((VAL) * fmesa->ffb_ubyte_color_scale)))
|
||||
|
||||
#define FFB_PACK_CONST_UBYTE_ARGB_COLOR(C) \
|
||||
((FFB_UBYTE_FROM_COLOR(C.alpha) << 24) | \
|
||||
(FFB_UBYTE_FROM_COLOR(C.blue) << 16) | \
|
||||
(FFB_UBYTE_FROM_COLOR(C.green) << 8) | \
|
||||
(FFB_UBYTE_FROM_COLOR(C.red) << 0))
|
||||
|
||||
#define FFB_COLOR_FROM_FLOAT(VAL) FFB_2_30_FLOAT_TO_FIXED(VAL)
|
||||
|
||||
#define _FFB_NEW_VERTEX (_DD_NEW_TRI_LIGHT_TWOSIDE)
|
||||
|
||||
extern void ffbDDSetupInit(void);
|
||||
extern void ffbChooseVertexState(GLcontext *);
|
||||
extern void ffbInitVB( GLcontext *ctx );
|
||||
extern void ffbFreeVB( GLcontext *ctx );
|
||||
|
||||
#endif /* !(_FFB_VB_H) */
|
||||
@@ -1,150 +0,0 @@
|
||||
|
||||
static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
#if defined(VB_DEBUG) || (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
#endif
|
||||
#if (IND & (FFB_VB_RGBA_BIT))
|
||||
GLfloat (*col0)[4];
|
||||
GLuint col0_stride;
|
||||
#if (IND & (FFB_VB_TWOSIDE_BIT))
|
||||
GLfloat (*col1)[4];
|
||||
GLuint col1_stride;
|
||||
#endif
|
||||
#endif
|
||||
#if (IND & FFB_VB_XYZ_BIT)
|
||||
GLfloat (*proj)[4] = VB->NdcPtr->data;
|
||||
GLuint proj_stride = VB->NdcPtr->stride;
|
||||
const GLubyte *mask = VB->ClipMask;
|
||||
#endif
|
||||
ffb_vertex *v = &fmesa->verts[start];
|
||||
int i;
|
||||
|
||||
#ifdef VB_DEBUG
|
||||
fprintf(stderr, "FFB: ffb_emit ["
|
||||
#if (IND & (FFB_VB_XYZ_BIT))
|
||||
" XYZ"
|
||||
#endif
|
||||
#if (IND & (FFB_VB_RGBA_BIT))
|
||||
" RGBA"
|
||||
#endif
|
||||
#if (IND & (FFB_VB_TWOSIDE_BIT))
|
||||
" TWOSIDE"
|
||||
#endif
|
||||
"] start(%d) end(%d) import(%d)\n",
|
||||
start, end,
|
||||
VB->importable_data);
|
||||
#endif
|
||||
|
||||
#if (IND & (FFB_VB_RGBA_BIT))
|
||||
col0 = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
|
||||
col0_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
|
||||
#if (IND & (FFB_VB_TWOSIDE_BIT))
|
||||
col1 = VB->BackfaceColorPtr->data;
|
||||
col1_stride = VB->BackfaceColorPtr->stride;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
{
|
||||
if (start) {
|
||||
#if (IND & (FFB_VB_XYZ_BIT))
|
||||
proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
|
||||
#endif
|
||||
#if (IND & (FFB_VB_RGBA_BIT))
|
||||
col0 = (GLfloat (*)[4])((GLubyte *)col0 + start * col0_stride);
|
||||
#if (IND & (FFB_VB_TWOSIDE_BIT))
|
||||
col1 = (GLfloat (*)[4])((GLubyte *)col1 + start * col1_stride);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
for (i = start; i < end; i++, v++) {
|
||||
#if (IND & (FFB_VB_XYZ_BIT))
|
||||
if (mask[i] == 0) {
|
||||
v->x = proj[0][0];
|
||||
v->y = proj[0][1];
|
||||
v->z = proj[0][2];
|
||||
}
|
||||
proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
|
||||
#endif
|
||||
#if (IND & (FFB_VB_RGBA_BIT))
|
||||
v->color[0].alpha = CLAMP(col0[0][3], 0.0f, 1.0f);
|
||||
v->color[0].red = CLAMP(col0[0][0], 0.0f, 1.0f);
|
||||
v->color[0].green = CLAMP(col0[0][1], 0.0f, 1.0f);
|
||||
v->color[0].blue = CLAMP(col0[0][2], 0.0f, 1.0f);
|
||||
col0 = (GLfloat (*)[4])((GLubyte *)col0 + col0_stride);
|
||||
#if (IND & (FFB_VB_TWOSIDE_BIT))
|
||||
v->color[1].alpha = CLAMP(col1[0][3], 0.0f, 1.0f);
|
||||
v->color[1].red = CLAMP(col1[0][0], 0.0f, 1.0f);
|
||||
v->color[1].green = CLAMP(col1[0][1], 0.0f, 1.0f);
|
||||
v->color[1].blue = CLAMP(col1[0][2], 0.0f, 1.0f);
|
||||
col1 = (GLfloat (*)[4])((GLubyte *)col1 + col1_stride);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void TAG(interp)(GLcontext *ctx, GLfloat t,
|
||||
GLuint edst, GLuint eout, GLuint ein,
|
||||
GLboolean force_boundary)
|
||||
{
|
||||
#if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
#endif
|
||||
#if (IND & (FFB_VB_XYZ_BIT))
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
const GLfloat *dstclip = VB->ClipPtr->data[edst];
|
||||
GLfloat oow = 1.0 / dstclip[3];
|
||||
#endif
|
||||
#if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
|
||||
ffb_vertex *dst = &fmesa->verts[edst];
|
||||
#endif
|
||||
#if (IND & (FFB_VB_RGBA_BIT))
|
||||
ffb_vertex *in = &fmesa->verts[eout];
|
||||
ffb_vertex *out = &fmesa->verts[ein];
|
||||
#endif
|
||||
|
||||
#ifdef VB_DEBUG
|
||||
fprintf(stderr, "FFB: ffb_interp ["
|
||||
#if (IND & (FFB_VB_XYZ_BIT))
|
||||
" XYZ"
|
||||
#endif
|
||||
#if (IND & (FFB_VB_RGBA_BIT))
|
||||
" RGBA"
|
||||
#endif
|
||||
#if (IND & (FFB_VB_TWOSIDE_BIT))
|
||||
" TWOSIDE"
|
||||
#endif
|
||||
"] edst(%d) eout(%d) ein(%d)\n",
|
||||
edst, eout, ein);
|
||||
#endif
|
||||
|
||||
#if (IND & (FFB_VB_XYZ_BIT))
|
||||
dst->x = dstclip[0] * oow;
|
||||
dst->y = dstclip[1] * oow;
|
||||
dst->z = dstclip[2] * oow;
|
||||
#endif
|
||||
|
||||
#if (IND & (FFB_VB_RGBA_BIT))
|
||||
INTERP_F(t, dst->color[0].alpha, out->color[0].alpha, in->color[0].alpha);
|
||||
INTERP_F(t, dst->color[0].red, out->color[0].red, in->color[0].red);
|
||||
INTERP_F(t, dst->color[0].green, out->color[0].green, in->color[0].green);
|
||||
INTERP_F(t, dst->color[0].blue, out->color[0].blue, in->color[0].blue);
|
||||
#if (IND & (FFB_VB_TWOSIDE_BIT))
|
||||
INTERP_F(t, dst->color[1].alpha, out->color[1].alpha, in->color[1].alpha);
|
||||
INTERP_F(t, dst->color[1].red, out->color[1].red, in->color[1].red);
|
||||
INTERP_F(t, dst->color[1].green, out->color[1].green, in->color[1].green);
|
||||
INTERP_F(t, dst->color[1].blue, out->color[1].blue, in->color[1].blue);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static void TAG(init)(void)
|
||||
{
|
||||
setup_tab[IND].emit = TAG(emit);
|
||||
setup_tab[IND].interp = TAG(interp);
|
||||
}
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
||||
@@ -1,414 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "api_noop.h"
|
||||
#include "main/context.h"
|
||||
#include "light.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/imports.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "main/simple_list.h"
|
||||
#include "vtxfmt.h"
|
||||
#include "ffb_xmesa.h"
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_vb.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/tcontext.h"
|
||||
|
||||
#include "ffb_vtxfmt.h"
|
||||
|
||||
#define TNL_VERTEX ffbTnlVertex
|
||||
|
||||
#define INTERP_RGBA(t, out, a, b) \
|
||||
do { \
|
||||
GLint i; \
|
||||
for ( i = 0 ; i < 4 ; i++ ) { \
|
||||
GLfloat fa = a[i]; \
|
||||
GLfloat fb = b[i]; \
|
||||
out[i] = LINTERP( t, fa, fb ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Color functions: */
|
||||
|
||||
static INLINE void ffb_recalc_base_color(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
struct gl_light *light;
|
||||
|
||||
COPY_3V(fmesa->vtx_state.light.base_color, ctx->Light._BaseColor[0]);
|
||||
foreach (light, &ctx->Light.EnabledList) {
|
||||
ACC_3V(fmesa->vtx_state.light.base_color,
|
||||
light->_MatAmbient[0]);
|
||||
}
|
||||
|
||||
fmesa->vtx_state.light.base_alpha = ctx->Light._BaseAlpha[0];
|
||||
}
|
||||
|
||||
#define GET_CURRENT \
|
||||
GET_CURRENT_CONTEXT(ctx); \
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx)
|
||||
|
||||
#define CURRENT_COLOR(COMP) fmesa->vtx_state.current.color[COMP]
|
||||
#define CURRENT_SPECULAR(COMP) fmesa->vtx_state.current.specular[COMP]
|
||||
#define COLOR_IS_FLOAT
|
||||
#define RECALC_BASE_COLOR(ctx) ffb_recalc_base_color(ctx)
|
||||
|
||||
#define TAG(x) ffb_##x
|
||||
#include "tnl_dd/t_dd_imm_capi.h"
|
||||
|
||||
/* Normal functions: */
|
||||
|
||||
struct ffb_norm_tab {
|
||||
void (*normal3f_multi)(GLfloat x, GLfloat y, GLfloat z);
|
||||
void (*normal3fv_multi)(const GLfloat *v);
|
||||
void (*normal3f_single)(GLfloat x, GLfloat y, GLfloat z);
|
||||
void (*normal3fv_single)(const GLfloat *v);
|
||||
};
|
||||
|
||||
static struct ffb_norm_tab norm_tab[0x4];
|
||||
|
||||
#define HAVE_HW_LIGHTING 0
|
||||
#define GET_CURRENT_VERTEX \
|
||||
GET_CURRENT_CONTEXT(ctx); \
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
|
||||
ffbTnlVertexPtr v = fmesa->imm.v0
|
||||
|
||||
#define CURRENT_NORMAL fmesa->vtx_state.current.normal
|
||||
#define BASE_COLOR fmesa->vtx_state.light.base_color
|
||||
#define BASE_ALPHA fmesa->vtx_state.light.base_alpha
|
||||
#define VERT_COLOR( COMP ) v->color[COMP]
|
||||
#define VERT_COLOR_IS_FLOAT
|
||||
|
||||
#define IND (0)
|
||||
#define TAG(x) ffb_##x
|
||||
#define PRESERVE_NORMAL_DEFS
|
||||
#include "tnl_dd/t_dd_imm_napi.h"
|
||||
|
||||
#define IND (NORM_RESCALE)
|
||||
#define TAG(x) ffb_##x##_rescale
|
||||
#define PRESERVE_NORMAL_DEFS
|
||||
#include "tnl_dd/t_dd_imm_napi.h"
|
||||
|
||||
#define IND (NORM_NORMALIZE)
|
||||
#define TAG(x) ffb_##x##_normalize
|
||||
#include "tnl_dd/t_dd_imm_napi.h"
|
||||
|
||||
static void ffb_init_norm_funcs(void)
|
||||
{
|
||||
ffb_init_norm();
|
||||
ffb_init_norm_rescale();
|
||||
ffb_init_norm_normalize();
|
||||
}
|
||||
|
||||
static void choose_normals(void)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLuint index;
|
||||
|
||||
if (ctx->Light.Enabled) {
|
||||
if (ctx->Transform.Normalize) {
|
||||
index = NORM_NORMALIZE;
|
||||
} else if (!ctx->Transform.RescaleNormals &&
|
||||
ctx->_ModelViewInvScale != 1.0) {
|
||||
index = NORM_RESCALE;
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev) {
|
||||
SET_Normal3f(ctx->Exec, norm_tab[index].normal3f_single);
|
||||
SET_Normal3fv(ctx->Exec, norm_tab[index].normal3fv_single);
|
||||
} else {
|
||||
SET_Normal3f(ctx->Exec, norm_tab[index].normal3f_multi);
|
||||
SET_Normal3fv(ctx->Exec, norm_tab[index].normal3fv_multi);
|
||||
}
|
||||
} else {
|
||||
SET_Normal3f(ctx->Exec, _mesa_noop_Normal3f);
|
||||
SET_Normal3fv(ctx->Exec, _mesa_noop_Normal3fv);
|
||||
}
|
||||
}
|
||||
|
||||
static void ffb_choose_Normal3f(GLfloat x, GLfloat y, GLfloat z)
|
||||
{
|
||||
choose_normals();
|
||||
CALL_Normal3f(GET_DISPATCH(), (x, y, z));
|
||||
}
|
||||
|
||||
static void ffb_choose_Normal3fv(const GLfloat *v)
|
||||
{
|
||||
choose_normals();
|
||||
CALL_Normal3fv(GET_DISPATCH(), (v));
|
||||
}
|
||||
|
||||
/* Vertex functions: */
|
||||
|
||||
#define GET_CURRENT_VERTEX \
|
||||
GET_CURRENT_CONTEXT(ctx); \
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
|
||||
ffbTnlVertexPtr v = fmesa->imm.v0
|
||||
|
||||
#define CURRENT_VERTEX v->obj
|
||||
#define SAVE_VERTEX fmesa->imm.save_vertex(ctx, v)
|
||||
|
||||
#define TAG(x) ffb_##x
|
||||
#include "tnl_dd/t_dd_imm_vapi.h"
|
||||
|
||||
struct ffb_vert_tab {
|
||||
void (*save_vertex)(GLcontext *ctx, ffbTnlVertexPtr v);
|
||||
void (*interpolate_vertex)(GLfloat t,
|
||||
ffbTnlVertex *O,
|
||||
const ffbTnlVertex *I,
|
||||
const ffbTnlVertex *J);
|
||||
};
|
||||
|
||||
static struct ffb_vert_tab vert_tab[0xf];
|
||||
|
||||
#define VTX_NORMAL 0x0
|
||||
#define VTX_RGBA 0x1
|
||||
|
||||
#define LOCAL_VARS \
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx)
|
||||
|
||||
#define CURRENT_COLOR fmesa->vtx_state.current.color
|
||||
#define COLOR_IS_FLOAT
|
||||
#define FLUSH_VERTEX fmesa->imm.flush_vertex( ctx, v );
|
||||
|
||||
#define IND (VTX_NORMAL)
|
||||
#define TAG(x) ffb_##x##_NORMAL
|
||||
#define PRESERVE_VERTEX_DEFS
|
||||
#include "tnl_dd/t_dd_imm_vertex.h"
|
||||
|
||||
#define IND (VTX_RGBA)
|
||||
#define TAG(x) ffb_##x##_RGBA
|
||||
#include "tnl_dd/t_dd_imm_vertex.h"
|
||||
|
||||
static void ffb_init_vert_funcs( void )
|
||||
{
|
||||
ffb_init_vert_NORMAL();
|
||||
ffb_init_vert_RGBA();
|
||||
}
|
||||
|
||||
#define LOCAL_VARS \
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx)
|
||||
|
||||
#define GET_INTERP_FUNC \
|
||||
ffb_interp_func interp = fmesa->imm.interp
|
||||
|
||||
#define FLUSH_VERTEX fmesa->imm.flush_vertex
|
||||
#define IMM_VERTEX( V ) fmesa->imm.V
|
||||
#define IMM_VERTICES( n ) fmesa->imm.vertices[n]
|
||||
|
||||
#define EMIT_VERTEX_USES_HWREGS
|
||||
|
||||
/* XXX Implement me XXX */
|
||||
#define EMIT_VERTEX_TRI(VTX0, VTX1, VTX2) \
|
||||
do { } while (0)
|
||||
#define EMIT_VERTEX_LINE(VTX0, VTX1) \
|
||||
do { } while (0)
|
||||
#define EMIT_VERTEX_POINT(VTX0) \
|
||||
do { } while (0)
|
||||
|
||||
#define TAG(x) ffb_##x
|
||||
#include "tnl_dd/t_dd_imm_primtmp.h"
|
||||
|
||||
/* Bzzt: Material changes are lost on fallback. */
|
||||
static void ffb_Materialfv(GLenum face, GLenum pname,
|
||||
const GLfloat *params)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
_mesa_noop_Materialfv( face, pname, params );
|
||||
ffb_recalc_base_color( ctx );
|
||||
}
|
||||
|
||||
/* Fallback functions: */
|
||||
|
||||
static void ffb_do_fallback(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
struct ffb_current_state *current = &fmesa->vtx_state.current;
|
||||
|
||||
/* Tell tnl to restore its exec vtxfmt, rehook its driver callbacks
|
||||
* and revive internal state that depended on those callbacks:
|
||||
*/
|
||||
_tnl_wakeup_exec(ctx);
|
||||
|
||||
/* Replay enough vertices that the current primitive is continued
|
||||
* correctly:
|
||||
*/
|
||||
if (fmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END )
|
||||
CALL_Begin(GET_DISPATCH(), (fmesa->imm.prim));
|
||||
|
||||
if (ctx->Light.Enabled) {
|
||||
/* Catch ColorMaterial */
|
||||
CALL_Color4fv(GET_DISPATCH(), (ctx->Current.Color));
|
||||
CALL_Normal3fv(GET_DISPATCH(), (current->normal));
|
||||
} else {
|
||||
CALL_Color4fv(GET_DISPATCH(), (current->color));
|
||||
}
|
||||
}
|
||||
|
||||
#define PRE_LOOPBACK( FUNC ) do { \
|
||||
GET_CURRENT_CONTEXT(ctx); \
|
||||
ffb_do_fallback( ctx ); \
|
||||
} while (0)
|
||||
|
||||
#define TAG(x) ffb_fallback_##x
|
||||
#include "vtxfmt_tmp.h"
|
||||
|
||||
static void ffb_Begin(GLenum prim)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
if (prim > GL_POLYGON) {
|
||||
_mesa_error( ctx, GL_INVALID_ENUM, "glBegin" );
|
||||
return;
|
||||
}
|
||||
|
||||
if (fmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END) {
|
||||
_mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->Driver.NeedFlush |= (FLUSH_STORED_VERTICES |
|
||||
FLUSH_UPDATE_CURRENT);
|
||||
|
||||
fmesa->imm.prim = prim;
|
||||
fmesa->imm.v0 = &fmesa->imm.vertices[0];
|
||||
fmesa->imm.save_vertex = ffb_save_vertex_RGBA;
|
||||
fmesa->imm.flush_vertex = ffb_flush_tab[prim];
|
||||
|
||||
/* XXX Lock hardware, update FBC, PPC, DRAWOP, etc. XXX */
|
||||
}
|
||||
|
||||
static void ffb_End(void)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
|
||||
if (fmesa->imm.prim == PRIM_OUTSIDE_BEGIN_END) {
|
||||
_mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
|
||||
return;
|
||||
}
|
||||
|
||||
fmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END;
|
||||
|
||||
ctx->Driver.NeedFlush &= ~(FLUSH_STORED_VERTICES |
|
||||
FLUSH_UPDATE_CURRENT);
|
||||
|
||||
/* XXX Unlock hardware, etc. */
|
||||
}
|
||||
|
||||
void ffbInitTnlModule(GLcontext *ctx)
|
||||
{
|
||||
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
|
||||
GLvertexformat *vfmt = &(fmesa->imm.vtxfmt);
|
||||
|
||||
/* Work in progress... */
|
||||
return;
|
||||
|
||||
ffb_init_norm_funcs();
|
||||
ffb_init_vert_funcs();
|
||||
|
||||
/* start by initializing to no-op functions */
|
||||
_mesa_noop_vtxfmt_init(vfmt);
|
||||
|
||||
/* Handled fully in supported states: */
|
||||
vfmt->ArrayElement = NULL; /* FIXME: ... */
|
||||
vfmt->Color3f = ffb_choose_Color3f;
|
||||
vfmt->Color3fv = ffb_choose_Color3fv;
|
||||
vfmt->Color3ub = ffb_choose_Color3ub;
|
||||
vfmt->Color3ubv = ffb_choose_Color3ubv;
|
||||
vfmt->Color4f = ffb_choose_Color4f;
|
||||
vfmt->Color4fv = ffb_choose_Color4fv;
|
||||
vfmt->Color4ub = ffb_choose_Color4ub;
|
||||
vfmt->Color4ubv = ffb_choose_Color4ubv;
|
||||
vfmt->FogCoordfvEXT = ffb_FogCoordfvEXT;
|
||||
vfmt->FogCoordfEXT = ffb_FogCoordfEXT;
|
||||
vfmt->Materialfv = ffb_Materialfv;
|
||||
vfmt->MultiTexCoord1fARB = ffb_fallback_MultiTexCoord1fARB;
|
||||
vfmt->MultiTexCoord1fvARB = ffb_fallback_MultiTexCoord1fvARB;
|
||||
vfmt->MultiTexCoord2fARB = ffb_fallback_MultiTexCoord2fARB;
|
||||
vfmt->MultiTexCoord2fvARB = ffb_fallback_MultiTexCoord2fvARB;
|
||||
vfmt->MultiTexCoord3fARB = ffb_fallback_MultiTexCoord3fARB;
|
||||
vfmt->MultiTexCoord3fvARB = ffb_fallback_MultiTexCoord3fvARB;
|
||||
vfmt->MultiTexCoord4fARB = ffb_fallback_MultiTexCoord4fARB;
|
||||
vfmt->MultiTexCoord4fvARB = ffb_fallback_MultiTexCoord4fvARB;
|
||||
vfmt->Normal3f = ffb_choose_Normal3f;
|
||||
vfmt->Normal3fv = ffb_choose_Normal3fv;
|
||||
vfmt->SecondaryColor3ubEXT = ffb_SecondaryColor3ubEXT;
|
||||
vfmt->SecondaryColor3ubvEXT = ffb_SecondaryColor3ubvEXT;
|
||||
vfmt->SecondaryColor3fEXT = ffb_SecondaryColor3fEXT;
|
||||
vfmt->SecondaryColor3fvEXT = ffb_SecondaryColor3fvEXT;
|
||||
vfmt->TexCoord1f = ffb_fallback_TexCoord1f;
|
||||
vfmt->TexCoord1fv = ffb_fallback_TexCoord1fv;
|
||||
vfmt->TexCoord2f = ffb_fallback_TexCoord2f;
|
||||
vfmt->TexCoord2fv = ffb_fallback_TexCoord2fv;
|
||||
vfmt->TexCoord3f = ffb_fallback_TexCoord3f;
|
||||
vfmt->TexCoord3fv = ffb_fallback_TexCoord3fv;
|
||||
vfmt->TexCoord4f = ffb_fallback_TexCoord4f;
|
||||
vfmt->TexCoord4fv = ffb_fallback_TexCoord4fv;
|
||||
|
||||
vfmt->Vertex2f = ffb_Vertex2f;
|
||||
vfmt->Vertex2fv = ffb_Vertex2fv;
|
||||
vfmt->Vertex3f = ffb_Vertex3f;
|
||||
vfmt->Vertex3fv = ffb_Vertex3fv;
|
||||
vfmt->Vertex4f = ffb_Vertex4f;
|
||||
vfmt->Vertex4fv = ffb_Vertex4fv;
|
||||
|
||||
vfmt->Begin = ffb_Begin;
|
||||
vfmt->End = ffb_End;
|
||||
|
||||
vfmt->DrawArrays = NULL;
|
||||
vfmt->DrawElements = NULL;
|
||||
|
||||
/* Active but unsupported -- fallback if we receive these:
|
||||
*
|
||||
* All of these fallbacks can be fixed with additional code, except
|
||||
* CallList, unless we build a play_immediate_noop() command which
|
||||
* turns an immediate back into glBegin/glEnd commands...
|
||||
*/
|
||||
vfmt->CallList = ffb_fallback_CallList;
|
||||
vfmt->EvalCoord1f = ffb_fallback_EvalCoord1f;
|
||||
vfmt->EvalCoord1fv = ffb_fallback_EvalCoord1fv;
|
||||
vfmt->EvalCoord2f = ffb_fallback_EvalCoord2f;
|
||||
vfmt->EvalCoord2fv = ffb_fallback_EvalCoord2fv;
|
||||
vfmt->EvalMesh1 = ffb_fallback_EvalMesh1;
|
||||
vfmt->EvalMesh2 = ffb_fallback_EvalMesh2;
|
||||
vfmt->EvalPoint1 = ffb_fallback_EvalPoint1;
|
||||
vfmt->EvalPoint2 = ffb_fallback_EvalPoint2;
|
||||
|
||||
vfmt->prefer_float_colors = GL_TRUE;
|
||||
|
||||
fmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END;
|
||||
|
||||
/* THIS IS A HACK! */
|
||||
_mesa_install_exec_vtxfmt( ctx, vfmt );
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
#ifndef _FFB_VTXFMT_H
|
||||
#define _FFB_VTXFMT_H
|
||||
|
||||
extern void ffbInitTnlModule(GLcontext *);
|
||||
|
||||
#endif /* !(_FFB_VTXFMT_H) */
|
||||
@@ -1,729 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* GLX Hardware Device Driver for Sun Creator/Creator3D
|
||||
* Copyright (C) 2000, 2001 David S. Miller
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*
|
||||
*
|
||||
* David S. Miller <davem@redhat.com>
|
||||
*/
|
||||
|
||||
#include "ffb_xmesa.h"
|
||||
#include "main/context.h"
|
||||
#include "main/framebuffer.h"
|
||||
#include "main/renderbuffer.h"
|
||||
#include "main/simple_list.h"
|
||||
#include "main/imports.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
#include "vbo/vbo.h"
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
|
||||
#include "ffb_context.h"
|
||||
#include "ffb_dd.h"
|
||||
#include "ffb_span.h"
|
||||
#include "ffb_depth.h"
|
||||
#include "ffb_stencil.h"
|
||||
#include "ffb_clear.h"
|
||||
#include "ffb_vb.h"
|
||||
#include "ffb_tris.h"
|
||||
#include "ffb_lines.h"
|
||||
#include "ffb_points.h"
|
||||
#include "ffb_state.h"
|
||||
#include "ffb_lock.h"
|
||||
#include "ffb_vtxfmt.h"
|
||||
#include "ffb_bitmap.h"
|
||||
|
||||
#include "drm_sarea.h"
|
||||
|
||||
#include "drirenderbuffer.h"
|
||||
|
||||
static GLboolean
|
||||
ffbInitDriver(__DRIscreen *sPriv)
|
||||
{
|
||||
ffbScreenPrivate *ffbScreen;
|
||||
FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
|
||||
drmAddress map;
|
||||
|
||||
if (getenv("LIBGL_FORCE_XSERVER"))
|
||||
return GL_FALSE;
|
||||
|
||||
|
||||
if (sPriv->devPrivSize != sizeof(FFBDRIRec)) {
|
||||
fprintf(stderr,"\nERROR! sizeof(FFBDRIRec) does not match passed size from device driver\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Allocate the private area. */
|
||||
ffbScreen = (ffbScreenPrivate *) MALLOC(sizeof(ffbScreenPrivate));
|
||||
if (!ffbScreen)
|
||||
return GL_FALSE;
|
||||
|
||||
/* Map FBC registers. */
|
||||
if (drmMap(sPriv->fd,
|
||||
gDRIPriv->hFbcRegs,
|
||||
gDRIPriv->sFbcRegs,
|
||||
&map)) {
|
||||
FREE(ffbScreen);
|
||||
return GL_FALSE;
|
||||
}
|
||||
ffbScreen->regs = (ffb_fbcPtr) map;
|
||||
|
||||
/* Map ramdac registers. */
|
||||
if (drmMap(sPriv->fd,
|
||||
gDRIPriv->hDacRegs,
|
||||
gDRIPriv->sDacRegs,
|
||||
&map)) {
|
||||
drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
|
||||
FREE(ffbScreen);
|
||||
return GL_FALSE;
|
||||
}
|
||||
ffbScreen->dac = (ffb_dacPtr) map;
|
||||
|
||||
/* Map "Smart" framebuffer views. */
|
||||
if (drmMap(sPriv->fd,
|
||||
gDRIPriv->hSfb8r,
|
||||
gDRIPriv->sSfb8r,
|
||||
&map)) {
|
||||
drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
|
||||
drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs);
|
||||
FREE(ffbScreen);
|
||||
return GL_FALSE;
|
||||
}
|
||||
ffbScreen->sfb8r = (volatile char *) map;
|
||||
|
||||
if (drmMap(sPriv->fd,
|
||||
gDRIPriv->hSfb32,
|
||||
gDRIPriv->sSfb32,
|
||||
&map)) {
|
||||
drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
|
||||
drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs);
|
||||
drmUnmap((drmAddress)ffbScreen->sfb8r, gDRIPriv->sSfb8r);
|
||||
FREE(ffbScreen);
|
||||
return GL_FALSE;
|
||||
}
|
||||
ffbScreen->sfb32 = (volatile char *) map;
|
||||
|
||||
if (drmMap(sPriv->fd,
|
||||
gDRIPriv->hSfb64,
|
||||
gDRIPriv->sSfb64,
|
||||
&map)) {
|
||||
drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
|
||||
drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs);
|
||||
drmUnmap((drmAddress)ffbScreen->sfb8r, gDRIPriv->sSfb8r);
|
||||
drmUnmap((drmAddress)ffbScreen->sfb32, gDRIPriv->sSfb32);
|
||||
FREE(ffbScreen);
|
||||
return GL_FALSE;
|
||||
}
|
||||
ffbScreen->sfb64 = (volatile char *) map;
|
||||
|
||||
ffbScreen->fifo_cache = 0;
|
||||
ffbScreen->rp_active = 0;
|
||||
|
||||
ffbScreen->sPriv = sPriv;
|
||||
sPriv->private = (void *) ffbScreen;
|
||||
|
||||
ffbDDLinefuncInit();
|
||||
ffbDDPointfuncInit();
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ffbDestroyScreen(__DRIscreen *sPriv)
|
||||
{
|
||||
ffbScreenPrivate *ffbScreen = sPriv->private;
|
||||
FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
|
||||
|
||||
drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
|
||||
drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs);
|
||||
drmUnmap((drmAddress)ffbScreen->sfb8r, gDRIPriv->sSfb8r);
|
||||
drmUnmap((drmAddress)ffbScreen->sfb32, gDRIPriv->sSfb32);
|
||||
drmUnmap((drmAddress)ffbScreen->sfb64, gDRIPriv->sSfb64);
|
||||
|
||||
FREE(ffbScreen);
|
||||
}
|
||||
|
||||
static const struct tnl_pipeline_stage *ffb_pipeline[] = {
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage,
|
||||
/* REMOVE: fog coord stage */
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
/* REMOVE: point attenuation stage */
|
||||
&_tnl_render_stage,
|
||||
0,
|
||||
};
|
||||
|
||||
/* Create and initialize the Mesa and driver specific context data */
|
||||
static GLboolean
|
||||
ffbCreateContext(const __GLcontextModes *mesaVis,
|
||||
__DRIcontext *driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
{
|
||||
ffbContextPtr fmesa;
|
||||
GLcontext *ctx, *shareCtx;
|
||||
__DRIscreen *sPriv;
|
||||
ffbScreenPrivate *ffbScreen;
|
||||
char *debug;
|
||||
struct dd_function_table functions;
|
||||
|
||||
/* Allocate ffb context */
|
||||
fmesa = (ffbContextPtr) CALLOC(sizeof(ffbContextRec));
|
||||
if (!fmesa)
|
||||
return GL_FALSE;
|
||||
|
||||
_mesa_init_driver_functions(&functions);
|
||||
|
||||
/* Allocate Mesa context */
|
||||
if (sharedContextPrivate)
|
||||
shareCtx = ((ffbContextPtr) sharedContextPrivate)->glCtx;
|
||||
else
|
||||
shareCtx = NULL;
|
||||
fmesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
|
||||
&functions, fmesa);
|
||||
if (!fmesa->glCtx) {
|
||||
FREE(fmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
driContextPriv->driverPrivate = fmesa;
|
||||
ctx = fmesa->glCtx;
|
||||
|
||||
sPriv = driContextPriv->driScreenPriv;
|
||||
ffbScreen = (ffbScreenPrivate *) sPriv->private;
|
||||
|
||||
/* Dri stuff. */
|
||||
fmesa->hHWContext = driContextPriv->hHWContext;
|
||||
fmesa->driFd = sPriv->fd;
|
||||
fmesa->driHwLock = &sPriv->pSAREA->lock;
|
||||
|
||||
fmesa->ffbScreen = ffbScreen;
|
||||
fmesa->driScreen = sPriv;
|
||||
fmesa->ffb_sarea = FFB_DRISHARE(sPriv->pSAREA);
|
||||
|
||||
/* Register and framebuffer pointers. */
|
||||
fmesa->regs = ffbScreen->regs;
|
||||
fmesa->sfb32 = ffbScreen->sfb32;
|
||||
|
||||
ffbDDInitContextHwState(ctx);
|
||||
|
||||
/* Default clear and depth colors. */
|
||||
{
|
||||
GLubyte r = (GLint) (ctx->Color.ClearColor[0] * 255.0F);
|
||||
GLubyte g = (GLint) (ctx->Color.ClearColor[1] * 255.0F);
|
||||
GLubyte b = (GLint) (ctx->Color.ClearColor[2] * 255.0F);
|
||||
|
||||
fmesa->clear_pixel = ((r << 0) |
|
||||
(g << 8) |
|
||||
(b << 16));
|
||||
}
|
||||
fmesa->clear_depth = Z_FROM_MESA(ctx->Depth.Clear * 4294967295.0f);
|
||||
fmesa->clear_stencil = ctx->Stencil.Clear & 0xf;
|
||||
|
||||
/* No wide points. */
|
||||
ctx->Const.MinPointSize = 1.0;
|
||||
ctx->Const.MinPointSizeAA = 1.0;
|
||||
ctx->Const.MaxPointSize = 1.0;
|
||||
ctx->Const.MaxPointSizeAA = 1.0;
|
||||
|
||||
/* Disable wide lines as we can't antialias them correctly in
|
||||
* hardware.
|
||||
*/
|
||||
ctx->Const.MinLineWidth = 1.0;
|
||||
ctx->Const.MinLineWidthAA = 1.0;
|
||||
ctx->Const.MaxLineWidth = 1.0;
|
||||
ctx->Const.MaxLineWidthAA = 1.0;
|
||||
ctx->Const.LineWidthGranularity = 1.0;
|
||||
|
||||
ctx->Const.MaxDrawBuffers = 1;
|
||||
|
||||
/* Instead of having GCC emit these constants a zillion times
|
||||
* everywhere in the driver, put them here.
|
||||
*/
|
||||
fmesa->ffb_2_30_fixed_scale = __FFB_2_30_FIXED_SCALE;
|
||||
fmesa->ffb_one_over_2_30_fixed_scale = (1.0 / __FFB_2_30_FIXED_SCALE);
|
||||
fmesa->ffb_16_16_fixed_scale = __FFB_16_16_FIXED_SCALE;
|
||||
fmesa->ffb_one_over_16_16_fixed_scale = (1.0 / __FFB_16_16_FIXED_SCALE);
|
||||
fmesa->ffb_ubyte_color_scale = 255.0f;
|
||||
fmesa->ffb_zero = 0.0f;
|
||||
|
||||
fmesa->debugFallbacks = GL_FALSE;
|
||||
debug = getenv("LIBGL_DEBUG");
|
||||
if (debug && strstr(debug, "fallbacks"))
|
||||
fmesa->debugFallbacks = GL_TRUE;
|
||||
|
||||
/* Initialize the software rasterizer and helper modules. */
|
||||
_swrast_CreateContext( ctx );
|
||||
_vbo_CreateContext( ctx );
|
||||
_tnl_CreateContext( ctx );
|
||||
_swsetup_CreateContext( ctx );
|
||||
|
||||
/* All of this need only be done once for a new context. */
|
||||
/* XXX these should be moved right after the
|
||||
* _mesa_init_driver_functions() call above.
|
||||
*/
|
||||
ffbDDExtensionsInit(ctx);
|
||||
ffbDDInitDriverFuncs(ctx);
|
||||
ffbDDInitStateFuncs(ctx);
|
||||
ffbDDInitRenderFuncs(ctx);
|
||||
/*ffbDDInitTexFuncs(ctx); not needed */
|
||||
ffbDDInitBitmapFuncs(ctx);
|
||||
ffbInitVB(ctx);
|
||||
|
||||
#if 0
|
||||
ffbInitTnlModule(ctx);
|
||||
#endif
|
||||
|
||||
_tnl_destroy_pipeline(ctx);
|
||||
_tnl_install_pipeline(ctx, ffb_pipeline);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
ffbDestroyContext(__DRIcontext *driContextPriv)
|
||||
{
|
||||
ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
|
||||
|
||||
if (fmesa) {
|
||||
ffbFreeVB(fmesa->glCtx);
|
||||
|
||||
_swsetup_DestroyContext( fmesa->glCtx );
|
||||
_tnl_DestroyContext( fmesa->glCtx );
|
||||
_vbo_DestroyContext( fmesa->glCtx );
|
||||
_swrast_DestroyContext( fmesa->glCtx );
|
||||
|
||||
/* free the Mesa context */
|
||||
fmesa->glCtx->DriverCtx = NULL;
|
||||
_mesa_destroy_context(fmesa->glCtx);
|
||||
|
||||
FREE(fmesa);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create and initialize the Mesa and driver specific pixmap buffer data */
|
||||
static GLboolean
|
||||
ffbCreateBuffer(__DRIscreen *driScrnPriv,
|
||||
__DRIdrawable *driDrawPriv,
|
||||
const __GLcontextModes *mesaVis,
|
||||
GLboolean isPixmap )
|
||||
{
|
||||
/* Mesa checks for pitch > 0, but ffb doesn't use pitches */
|
||||
int bogusPitch = 1;
|
||||
int bpp = 4; /* we've always got a 32bpp framebuffer */
|
||||
int offset = 0; /* always at 0 for offset */
|
||||
|
||||
if (isPixmap) {
|
||||
return GL_FALSE; /* not implemented */
|
||||
} else {
|
||||
GLboolean swStencil = (mesaVis->stencilBits > 0 &&
|
||||
mesaVis->depthBits != 24);
|
||||
struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
|
||||
|
||||
{
|
||||
driRenderbuffer *frontRb
|
||||
= driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, bpp, offset, bogusPitch,
|
||||
driDrawPriv);
|
||||
ffbSetSpanFunctions(frontRb, mesaVis);
|
||||
_mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
|
||||
}
|
||||
|
||||
if (mesaVis->doubleBufferMode) {
|
||||
driRenderbuffer *backRb
|
||||
= driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, bpp, offset, bogusPitch,
|
||||
driDrawPriv);
|
||||
ffbSetSpanFunctions(backRb, mesaVis);
|
||||
_mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
|
||||
}
|
||||
|
||||
if (mesaVis->depthBits == 16) {
|
||||
driRenderbuffer *depthRb
|
||||
= driNewRenderbuffer(MESA_FORMAT_Z16, NULL, bpp, offset,
|
||||
bogusPitch, driDrawPriv);
|
||||
ffbSetDepthFunctions(depthRb, mesaVis);
|
||||
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
|
||||
}
|
||||
|
||||
if (mesaVis->stencilBits > 0 && !swStencil) {
|
||||
driRenderbuffer *stencilRb
|
||||
= driNewRenderbuffer(MESA_FORMAT_S8, NULL, bpp, offset,
|
||||
bogusPitch, driDrawPriv);
|
||||
ffbSetStencilFunctions(stencilRb, mesaVis);
|
||||
_mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
|
||||
}
|
||||
|
||||
_mesa_add_soft_renderbuffers(fb,
|
||||
GL_FALSE, /* color */
|
||||
GL_FALSE, /* depth */
|
||||
swStencil,
|
||||
mesaVis->accumRedBits > 0,
|
||||
GL_FALSE, /* alpha */
|
||||
GL_FALSE /* aux */);
|
||||
driDrawPriv->driverPrivate = (void *) fb;
|
||||
|
||||
return (driDrawPriv->driverPrivate != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ffbDestroyBuffer(__DRIdrawable *driDrawPriv)
|
||||
{
|
||||
_mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
|
||||
}
|
||||
|
||||
|
||||
#define USE_FAST_SWAP
|
||||
|
||||
static void
|
||||
ffbSwapBuffers( __DRIdrawable *dPriv )
|
||||
{
|
||||
ffbContextPtr fmesa = (ffbContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
unsigned int fbc, wid, wid_reg_val, dac_db_bit;
|
||||
unsigned int shadow_dac_addr, active_dac_addr;
|
||||
ffb_fbcPtr ffb;
|
||||
ffb_dacPtr dac;
|
||||
|
||||
if (fmesa == NULL ||
|
||||
fmesa->glCtx->Visual.doubleBufferMode == 0)
|
||||
return;
|
||||
|
||||
/* Flush pending rendering commands */
|
||||
_mesa_notifySwapBuffers(fmesa->glCtx);
|
||||
|
||||
ffb = fmesa->regs;
|
||||
dac = fmesa->ffbScreen->dac;
|
||||
|
||||
fbc = fmesa->fbc;
|
||||
wid = fmesa->wid;
|
||||
|
||||
/* Swap the buffer we render into and read pixels from. */
|
||||
fmesa->back_buffer ^= 1;
|
||||
|
||||
/* If we are writing into both buffers, don't mess with
|
||||
* the WB setting.
|
||||
*/
|
||||
if ((fbc & FFB_FBC_WB_AB) != FFB_FBC_WB_AB) {
|
||||
if ((fbc & FFB_FBC_WB_A) != 0)
|
||||
fbc = (fbc & ~FFB_FBC_WB_A) | FFB_FBC_WB_B;
|
||||
else
|
||||
fbc = (fbc & ~FFB_FBC_WB_B) | FFB_FBC_WB_A;
|
||||
}
|
||||
|
||||
/* But either way, we must flip the read buffer setting. */
|
||||
if ((fbc & FFB_FBC_RB_A) != 0)
|
||||
fbc = (fbc & ~FFB_FBC_RB_A) | FFB_FBC_RB_B;
|
||||
else
|
||||
fbc = (fbc & ~FFB_FBC_RB_B) | FFB_FBC_RB_A;
|
||||
|
||||
LOCK_HARDWARE(fmesa);
|
||||
|
||||
if (fmesa->fbc != fbc) {
|
||||
FFBFifo(fmesa, 1);
|
||||
ffb->fbc = fmesa->fbc = fbc;
|
||||
fmesa->ffbScreen->rp_active = 1;
|
||||
}
|
||||
|
||||
/* And swap the buffer displayed in the WID. */
|
||||
if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1) {
|
||||
shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid);
|
||||
active_dac_addr = FFBDAC_PAC1_APWLUT(wid);
|
||||
dac_db_bit = FFBDAC_PAC1_WLUT_DB;
|
||||
} else {
|
||||
shadow_dac_addr = FFBDAC_PAC2_SPWLUT(wid);
|
||||
active_dac_addr = FFBDAC_PAC2_APWLUT(wid);
|
||||
dac_db_bit = FFBDAC_PAC2_WLUT_DB;
|
||||
}
|
||||
|
||||
FFBWait(fmesa, ffb);
|
||||
|
||||
wid_reg_val = DACCFG_READ(dac, active_dac_addr);
|
||||
if (fmesa->back_buffer == 0)
|
||||
wid_reg_val |= dac_db_bit;
|
||||
else
|
||||
wid_reg_val &= ~dac_db_bit;
|
||||
#ifdef USE_FAST_SWAP
|
||||
DACCFG_WRITE(dac, active_dac_addr, wid_reg_val);
|
||||
#else
|
||||
DACCFG_WRITE(dac, shadow_dac_addr, wid_reg_val);
|
||||
|
||||
/* Schedule the window transfer. */
|
||||
DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL,
|
||||
(FFBDAC_CFG_WTCTRL_TCMD | FFBDAC_CFG_WTCTRL_TE));
|
||||
|
||||
{
|
||||
int limit = 1000000;
|
||||
while (limit--) {
|
||||
unsigned int wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL);
|
||||
|
||||
if ((wtctrl & FFBDAC_CFG_WTCTRL_DS) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
}
|
||||
|
||||
static void ffb_init_wid(ffbContextPtr fmesa, unsigned int wid)
|
||||
{
|
||||
ffb_dacPtr dac = fmesa->ffbScreen->dac;
|
||||
unsigned int wid_reg_val, dac_db_bit, active_dac_addr;
|
||||
unsigned int shadow_dac_addr;
|
||||
|
||||
if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1) {
|
||||
shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid);
|
||||
active_dac_addr = FFBDAC_PAC1_APWLUT(wid);
|
||||
dac_db_bit = FFBDAC_PAC1_WLUT_DB;
|
||||
} else {
|
||||
shadow_dac_addr = FFBDAC_PAC2_SPWLUT(wid);
|
||||
active_dac_addr = FFBDAC_PAC2_APWLUT(wid);
|
||||
dac_db_bit = FFBDAC_PAC2_WLUT_DB;
|
||||
}
|
||||
|
||||
wid_reg_val = DACCFG_READ(dac, active_dac_addr);
|
||||
wid_reg_val &= ~dac_db_bit;
|
||||
#ifdef USE_FAST_SWAP
|
||||
DACCFG_WRITE(dac, active_dac_addr, wid_reg_val);
|
||||
#else
|
||||
DACCFG_WRITE(dac, shadow_dac_addr, wid_reg_val);
|
||||
|
||||
/* Schedule the window transfer. */
|
||||
DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL,
|
||||
(FFBDAC_CFG_WTCTRL_TCMD | FFBDAC_CFG_WTCTRL_TE));
|
||||
|
||||
{
|
||||
int limit = 1000000;
|
||||
while (limit--) {
|
||||
unsigned int wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL);
|
||||
|
||||
if ((wtctrl & FFBDAC_CFG_WTCTRL_DS) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Force the context `c' to be the current context and associate with it
|
||||
buffer `b' */
|
||||
static GLboolean
|
||||
ffbMakeCurrent(__DRIcontext *driContextPriv,
|
||||
__DRIdrawable *driDrawPriv,
|
||||
__DRIdrawable *driReadPriv)
|
||||
{
|
||||
if (driContextPriv) {
|
||||
ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
|
||||
int first_time;
|
||||
|
||||
fmesa->driDrawable = driDrawPriv;
|
||||
|
||||
_mesa_make_current(fmesa->glCtx,
|
||||
(GLframebuffer *) driDrawPriv->driverPrivate,
|
||||
(GLframebuffer *) driReadPriv->driverPrivate);
|
||||
|
||||
first_time = 0;
|
||||
if (fmesa->wid == ~0) {
|
||||
first_time = 1;
|
||||
if (getenv("LIBGL_SOFTWARE_RENDERING"))
|
||||
FALLBACK( fmesa->glCtx, FFB_BADATTR_SWONLY, GL_TRUE );
|
||||
}
|
||||
|
||||
LOCK_HARDWARE(fmesa);
|
||||
if (first_time) {
|
||||
fmesa->wid = fmesa->ffb_sarea->wid_table[driDrawPriv->index];
|
||||
ffb_init_wid(fmesa, fmesa->wid);
|
||||
}
|
||||
|
||||
fmesa->state_dirty |= FFB_STATE_ALL;
|
||||
fmesa->state_fifo_ents = fmesa->state_all_fifo_ents;
|
||||
ffbSyncHardware(fmesa);
|
||||
UNLOCK_HARDWARE(fmesa);
|
||||
|
||||
if (first_time) {
|
||||
/* Also, at the first switch to a new context,
|
||||
* we need to clear all the hw buffers.
|
||||
*/
|
||||
ffbDDClear(fmesa->glCtx,
|
||||
(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT |
|
||||
BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL));
|
||||
}
|
||||
} else {
|
||||
_mesa_make_current(NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* Force the context `c' to be unbound from its buffer */
|
||||
static GLboolean
|
||||
ffbUnbindContext(__DRIcontext *driContextPriv)
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void ffbXMesaUpdateState(ffbContextPtr fmesa)
|
||||
{
|
||||
__DRIdrawable *dPriv = fmesa->driDrawable;
|
||||
__DRIscreen *sPriv = fmesa->driScreen;
|
||||
int stamp = dPriv->lastStamp;
|
||||
|
||||
DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
|
||||
|
||||
if (dPriv->lastStamp != stamp) {
|
||||
GLcontext *ctx = fmesa->glCtx;
|
||||
|
||||
ffbCalcViewport(ctx);
|
||||
driUpdateFramebufferSize(ctx, dPriv);
|
||||
if (ctx->Polygon.StippleFlag) {
|
||||
ffbXformAreaPattern(fmesa,
|
||||
(const GLubyte *)ctx->PolygonStipple);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const __DRIconfig **
|
||||
ffbFillInModes( __DRIscreen *psp,
|
||||
unsigned pixel_bits, unsigned depth_bits,
|
||||
unsigned stencil_bits, GLboolean have_back_buffer )
|
||||
{
|
||||
__DRIconfig **configs;
|
||||
__GLcontextModes *m;
|
||||
unsigned depth_buffer_factor;
|
||||
unsigned back_buffer_factor;
|
||||
GLenum fb_format;
|
||||
GLenum fb_type;
|
||||
int i;
|
||||
|
||||
/* GLX_SWAP_COPY_OML is only supported because the FFB driver doesn't
|
||||
* support pageflipping at all.
|
||||
*/
|
||||
static const GLenum back_buffer_modes[] = {
|
||||
GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
|
||||
};
|
||||
|
||||
uint8_t depth_bits_array[3];
|
||||
uint8_t stencil_bits_array[3];
|
||||
uint8_t msaa_samples_array[1];
|
||||
|
||||
depth_bits_array[0] = 0;
|
||||
depth_bits_array[1] = depth_bits;
|
||||
depth_bits_array[2] = depth_bits;
|
||||
|
||||
/* Just like with the accumulation buffer, always provide some modes
|
||||
* with a stencil buffer. It will be a sw fallback, but some apps won't
|
||||
* care about that.
|
||||
*/
|
||||
stencil_bits_array[0] = 0;
|
||||
stencil_bits_array[1] = 0;
|
||||
stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits;
|
||||
|
||||
msaa_samples_array[0] = 0;
|
||||
|
||||
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
|
||||
back_buffer_factor = (have_back_buffer) ? 3 : 1;
|
||||
|
||||
if ( pixel_bits == 16 ) {
|
||||
fb_format = GL_RGB;
|
||||
fb_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
}
|
||||
else {
|
||||
fb_format = GL_BGRA;
|
||||
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
configs = driCreateConfigs(fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor, back_buffer_modes,
|
||||
back_buffer_factor,
|
||||
msaa_samples_array, 1, GL_TRUE);
|
||||
if (configs == NULL) {
|
||||
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
|
||||
__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for (i = 0; configs[i]; i++) {
|
||||
m = &configs[i]->modes;
|
||||
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
return (const __DRIconfig **) configs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the driver specific part of the createNewScreen entry point.
|
||||
*
|
||||
* \todo maybe fold this into intelInitDriver
|
||||
*
|
||||
* \return the __GLcontextModes supported by this driver
|
||||
*/
|
||||
static const __DRIconfig **
|
||||
ffbInitScreen(__DRIscreen *psp)
|
||||
{
|
||||
static const __DRIversion ddx_expected = { 0, 1, 1 };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
static const __DRIversion drm_expected = { 0, 0, 1 };
|
||||
|
||||
if ( ! driCheckDriDdxDrmVersions2( "ffb",
|
||||
&psp->dri_version, & dri_expected,
|
||||
&psp->ddx_version, & ddx_expected,
|
||||
&psp->drm_version, & drm_expected ) )
|
||||
return NULL;
|
||||
|
||||
if (!ffbInitDriver(psp))
|
||||
return NULL;
|
||||
|
||||
return ffbFillInModes( psp, 32, 16, 0, GL_TRUE );
|
||||
}
|
||||
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
.InitScreen = ffbInitScreen,
|
||||
.DestroyScreen = ffbDestroyScreen,
|
||||
.CreateContext = ffbCreateContext,
|
||||
.DestroyContext = ffbDestroyContext,
|
||||
.CreateBuffer = ffbCreateBuffer,
|
||||
.DestroyBuffer = ffbDestroyBuffer,
|
||||
.SwapBuffers = ffbSwapBuffers,
|
||||
.MakeCurrent = ffbMakeCurrent,
|
||||
.UnbindContext = ffbUnbindContext,
|
||||
.GetSwapInfo = NULL,
|
||||
.GetDrawableMSC = NULL,
|
||||
.WaitForMSC = NULL,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
};
|
||||
|
||||
/* This is the table of extensions that the loader will dlsym() for. */
|
||||
PUBLIC const __DRIextension *__driDriverExtensions[] = {
|
||||
&driCoreExtension.base,
|
||||
&driLegacyExtension.base,
|
||||
NULL
|
||||
};
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
#ifndef _FFB_XMESA_H_
|
||||
#define _FFB_XMESA_H_
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "dri_util.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "ffb_drishare.h"
|
||||
#include "ffb_regs.h"
|
||||
#include "ffb_dac.h"
|
||||
#include "ffb_fifo.h"
|
||||
|
||||
typedef struct {
|
||||
__DRIscreen *sPriv;
|
||||
ffb_fbcPtr regs;
|
||||
ffb_dacPtr dac;
|
||||
volatile char *sfb8r;
|
||||
volatile char *sfb32;
|
||||
volatile char *sfb64;
|
||||
|
||||
int fifo_cache;
|
||||
int rp_active;
|
||||
} ffbScreenPrivate;
|
||||
|
||||
#endif /* !(_FFB_XMESA_H) */
|
||||
@@ -1,366 +0,0 @@
|
||||
/*
|
||||
* Acceleration for the Creator and Creator3D framebuffer - DAC register layout.
|
||||
*
|
||||
* Copyright (C) 2000 David S. Miller (davem@redhat.com)
|
||||
*
|
||||
* 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
|
||||
* DAVID MILLER 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 _FFB_DAC_H
|
||||
#define _FFB_DAC_H
|
||||
|
||||
#define Bool int
|
||||
|
||||
/* FFB utilizes two different ramdac chips:
|
||||
*
|
||||
* 1) BT9068 "Pacifica1", used in all FFB1 and
|
||||
* FFB2 boards.
|
||||
*
|
||||
* 2) BT498(a) "Pacifica2", used in FFB2+ and
|
||||
* AFB boards.
|
||||
*
|
||||
* They are mostly equivalent, except in a few key areas:
|
||||
*
|
||||
* 1) WID register layout
|
||||
* 2) Number of CLUT tables
|
||||
* 3) Presence of Window Address Mask register
|
||||
* 4) Method of GAMMA correction support
|
||||
*/
|
||||
|
||||
/* NOTE: All addresses described in this file are DAC
|
||||
* indirect addresses.
|
||||
*/
|
||||
|
||||
/* DAC color values are in the following format. */
|
||||
#define FFBDAC_COLOR_BLUE 0x00ff0000
|
||||
#define FFBDAC_COLOR_BLUE_SHFT 16
|
||||
#define FFBDAC_COLOR_GREEN 0x0000ff00
|
||||
#define FFBDAC_COLOR_GREEN_SHFT 8
|
||||
#define FFBDAC_COLOR_RED 0x000000ff
|
||||
#define FFBDAC_COLOR_RED_SHFT 0
|
||||
|
||||
/* Cursor DAC register addresses. */
|
||||
#define FFBDAC_CUR_BITMAP_P0 0x000 /* Plane 0 cursor bitmap */
|
||||
#define FFBDAC_CUR_BITMAP_P1 0x080 /* Plane 1 cursor bitmap */
|
||||
#define FFBDAC_CUR_CTRL 0x100 /* Cursor control */
|
||||
#define FFBDAC_CUR_COLOR0 0x101 /* Cursor Color 0 */
|
||||
#define FFBDAC_CUR_COLOR1 0x102 /* Cursor Color 1 (bg) */
|
||||
#define FFBDAC_CUR_COLOR2 0x103 /* Cursor Color 2 (fg) */
|
||||
#define FFBDAC_CUR_POS 0x104 /* Active cursor position */
|
||||
|
||||
/* Cursor control register.
|
||||
* WARNING: Be careful, reverse logic on these bits.
|
||||
*/
|
||||
#define FFBDAC_CUR_CTRL_P0 0x00000001 /* Plane0 display disable */
|
||||
#define FFBDAC_CUR_CTRL_P1 0x00000002 /* Plane1 display disable */
|
||||
|
||||
/* Active cursor position register */
|
||||
#define FFBDAC_CUR_POS_Y_SIGN 0x80000000 /* Sign of Y position */
|
||||
#define FFBDAC_CUR_POS_Y 0x0fff0000 /* Y position */
|
||||
#define FFBDAC_CUR_POS_X_SIGN 0x00008000 /* Sign of X position */
|
||||
#define FFBDAC_CUR_POS_X 0x00000fff /* X position */
|
||||
|
||||
/* Configuration and Palette DAC register addresses. */
|
||||
#define FFBDAC_CFG_PPLLCTRL 0x0000 /* Pixel PLL Control */
|
||||
#define FFBDAC_CFG_GPLLCTRL 0x0001 /* General Purpose PLL Control */
|
||||
#define FFBDAC_CFG_PFCTRL 0x1000 /* Pixel Format Control */
|
||||
#define FFBDAC_CFG_UCTRL 0x1001 /* User Control */
|
||||
#define FFBDAC_CFG_CLUP_BASE 0x2000 /* Color Lookup Palette */
|
||||
#define FFBDAC_CFG_CLUP(entry) (FFBDAC_CFG_CLUP_BASE + ((entry) * 0x100))
|
||||
#define FFBDAC_PAC2_SOVWLUT0 0x3100 /* Shadow Overlay Window Lookup 0*/
|
||||
#define FFBDAC_PAC2_SOVWLUT1 0x3101 /* Shadow Overlay Window Lookup 1*/
|
||||
#define FFBDAC_PAC2_SOVWLUT2 0x3102 /* Shadow Overlay Window Lookup 2*/
|
||||
#define FFBDAC_PAC2_SOVWLUT3 0x3103 /* Shadow Overlay Window Lookup 3*/
|
||||
#define FFBDAC_PAC2_AOVWLUT0 0x3210 /* Active Overlay Window Lookup 0*/
|
||||
#define FFBDAC_PAC2_AOVWLUT1 0x3211 /* Active Overlay Window Lookup 1*/
|
||||
#define FFBDAC_PAC2_AOVWLUT2 0x3212 /* Active Overlay Window Lookup 2*/
|
||||
#define FFBDAC_PAC2_AOVWLUT3 0x3213 /* Active Overlay Window Lookup 3*/
|
||||
#define FFBDAC_CFG_WTCTRL 0x3150 /* Window Transfer Control */
|
||||
#define FFBDAC_CFG_TMCTRL 0x3151 /* Transparent Mask Control */
|
||||
#define FFBDAC_CFG_TCOLORKEY 0x3152 /* Transparent Color Key */
|
||||
#define FFBDAC_CFG_WAMASK 0x3153 /* Window Address Mask (PAC2 only) */
|
||||
#define FFBDAC_PAC1_SPWLUT_BASE 0x3100 /* Shadow Primary Window Lookups */
|
||||
#define FFBDAC_PAC1_SPWLUT(entry) (FFBDAC_PAC1_SPWLUT_BASE + (entry))
|
||||
#define FFBDAC_PAC1_APWLUT_BASE 0x3120 /* Active Primary Window Lookups */
|
||||
#define FFBDAC_PAC1_APWLUT(entry) (FFBDAC_PAC1_APWLUT_BASE + (entry))
|
||||
#define FFBDAC_PAC2_SPWLUT_BASE 0x3200 /* Shadow Primary Window Lookups */
|
||||
#define FFBDAC_PAC2_SPWLUT(entry) (FFBDAC_PAC2_SPWLUT_BASE + (entry))
|
||||
#define FFBDAC_PAC2_APWLUT_BASE 0x3240 /* Active Primary Window Lookups */
|
||||
#define FFBDAC_PAC2_APWLUT(entry) (FFBDAC_PAC2_APWLUT_BASE + (entry))
|
||||
#define FFBDAC_CFG_SANAL 0x5000 /* Signature Analysis Control */
|
||||
#define FFBDAC_CFG_DACCTRL 0x5001 /* DAC Control */
|
||||
#define FFBDAC_CFG_TGEN 0x6000 /* Timing Generator Control */
|
||||
#define FFBDAC_CFG_VBNP 0x6001 /* Vertical Blank Negation Point */
|
||||
#define FFBDAC_CFG_VBAP 0x6002 /* Vertical Blank Assertion Point*/
|
||||
#define FFBDAC_CFG_VSNP 0x6003 /* Vertical Sync Negation Point */
|
||||
#define FFBDAC_CFG_VSAP 0x6004 /* Vertical Sync Assertion Point */
|
||||
#define FFBDAC_CFG_HSNP 0x6005 /* Horz Serration Negation Point */
|
||||
#define FFBDAC_CFG_HBNP 0x6006 /* Horz Blank Negation Point */
|
||||
#define FFBDAC_CFG_HBAP 0x6007 /* Horz Blank Assertion Point */
|
||||
#define FFBDAC_CFG_HSYNCNP 0x6008 /* Horz Sync Negation Point */
|
||||
#define FFBDAC_CFG_HSYNCAP 0x6009 /* Horz Sync Assertion Point */
|
||||
#define FFBDAC_CFG_HSCENNP 0x600A /* Horz SCEN Negation Point */
|
||||
#define FFBDAC_CFG_HSCENAP 0x600B /* Horz SCEN Assertion Point */
|
||||
#define FFBDAC_CFG_EPNP 0x600C /* Eql'zing Pulse Negation Point */
|
||||
#define FFBDAC_CFG_EINP 0x600D /* Eql'zing Intvl Negation Point */
|
||||
#define FFBDAC_CFG_EIAP 0x600E /* Eql'zing Intvl Assertion Point*/
|
||||
#define FFBDAC_CFG_TGVC 0x600F /* Timing Generator Vert Counter */
|
||||
#define FFBDAC_CFG_TGHC 0x6010 /* Timing Generator Horz Counter */
|
||||
#define FFBDAC_CFG_DID 0x8000 /* Device Identification */
|
||||
#define FFBDAC_CFG_MPDATA 0x8001 /* Monitor Port Data */
|
||||
#define FFBDAC_CFG_MPSENSE 0x8002 /* Monitor Port Sense */
|
||||
|
||||
/* Pixel PLL Control Register */
|
||||
#define FFBDAC_CFG_PPLLCTRL_M 0x0000007f /* PLL VCO Multiplicand */
|
||||
#define FFBDAC_CFG_PPLLCTRL_D 0x00000780 /* PLL VCO Divisor */
|
||||
#define FFBDAC_CFG_PPLLCTRL_PFD 0x00001800 /* Post VCO Frequency Divider */
|
||||
#define FFBDAC_CFG_PPLLCTRL_EN 0x00004000 /* Enable PLL as pixel clock src */
|
||||
|
||||
/* General Purpose PLL Control Register */
|
||||
#define FFBDAC_CFG_GPLLCTRL_M 0x0000007f /* PLL VCO Multiplicand */
|
||||
#define FFBDAC_CFG_GPLLCTRL_D 0x00000780 /* PLL VCO Divisor */
|
||||
#define FFBDAC_CFG_GPLLCTRL_PFD 0x00001800 /* Post VCO Frequency Divider */
|
||||
#define FFBDAC_CFG_GPLLCTRL_EN 0x00004000 /* Enable PLL as Gen. Purpose clk*/
|
||||
|
||||
/* Pixel Format Control Register */
|
||||
#define FFBDAC_CFG_PFCTRL_2_1 0x00000000 /* 2:1 pixel interleave format */
|
||||
#define FFBDAC_CFG_PFCTRL_4_1 0x00000001 /* 4:1 pixel interleave format */
|
||||
#define FFBDAC_CFG_PFCTRL_42_1 0x00000002 /* 4/2:1 pixel interleave format */
|
||||
#define FFBDAC_CFG_PFCTRL_82_1 0x00000003 /* 8/2:1 pixel interleave format */
|
||||
|
||||
/* User Control Register */
|
||||
#define FFBDAC_UCTRL_IPDISAB 0x00000001 /* Disable input pullup resistors*/
|
||||
#define FFBDAC_UCTRL_ABLANK 0x00000002 /* Asynchronous Blank */
|
||||
#define FFBDAC_UCTRL_DBENAB 0x00000004 /* Double-Buffer Enable */
|
||||
#define FFBDAC_UCTRL_OVENAB 0x00000008 /* Overlay Enable */
|
||||
#define FFBDAC_UCTRL_WMODE 0x00000030 /* Window Mode */
|
||||
#define FFBDAC_UCTRL_WM_COMB 0x00000000 /* Window Mode = Combined */
|
||||
#define FFBDAC_UCTRL_WM_S4 0x00000010 /* Window Mode = Seperate_4 */
|
||||
#define FFBDAC_UCTRL_WM_S8 0x00000020 /* Window Mode = Seperate_8 */
|
||||
#define FFBDAC_UCTRL_WM_RESV 0x00000030 /* Window Mode = reserved */
|
||||
#define FFBDAC_UCTRL_MANREV 0x00000f00 /* 4-bit Manufacturing Revision */
|
||||
|
||||
/* Overlay Window Lookup Registers (PAC2 only) */
|
||||
#define FFBDAC_CFG_OVWLUT_PSEL 0x0000000f /* Palette Section, Seperate_4 */
|
||||
#define FFBDAC_CFG_OVWLUT_PTBL 0x00000030 /* Palette Table */
|
||||
#define FFBDAC_CFG_OVWLUT_LKUP 0x00000100 /* 1 = Use palette, 0 = Bypass */
|
||||
#define FFBDAC_CFG_OVWLUT_OTYP 0x00000c00 /* Overlay Type */
|
||||
#define FFBDAC_CFG_OVWLUT_O_N 0x00000000 /* Overlay Type - None */
|
||||
#define FFBDAC_CFG_OVWLUT_O_T 0x00000400 /* Overlay Type - Transparent */
|
||||
#define FFBDAC_CFG_OVWLUT_O_O 0x00000800 /* Overlay Type - Opaque */
|
||||
#define FFBDAC_CFG_OVWLUT_O_R 0x00000c00 /* Overlay Type - Reserved */
|
||||
#define FFBDAC_CFG_OVWLUT_PCS 0x00003000 /* Psuedocolor Src */
|
||||
#define FFBDAC_CFG_OVWLUT_P_XO 0x00000000 /* Psuedocolor Src - XO[7:0] */
|
||||
#define FFBDAC_CFG_OVWLUT_P_R 0x00001000 /* Psuedocolor Src - R[7:0] */
|
||||
#define FFBDAC_CFG_OVWLUT_P_G 0x00002000 /* Psuedocolor Src - G[7:0] */
|
||||
#define FFBDAC_CFG_OVWLUT_P_B 0x00003000 /* Psuedocolor Src - B[7:0] */
|
||||
|
||||
/* Window Transfer Control Register */
|
||||
#define FFBDAC_CFG_WTCTRL_DS 0x00000001 /* Device Status, 1 = Busy */
|
||||
#define FFBDAC_CFG_WTCTRL_TCMD 0x00000002 /* Transfer Command
|
||||
* 1 = Transfer, 0 = No Action
|
||||
*/
|
||||
#define FFBDAC_CFG_WTCTRL_TE 0x00000004 /* Transfer Event
|
||||
* 1 = Next Frame, 0 = Next Field
|
||||
*/
|
||||
#define FFBDAC_CFG_WTCTRL_DRD 0x00000008 /* Drawing Data
|
||||
* 1 = Local Drawing Active
|
||||
* 0 = Local Drawing Idle
|
||||
*/
|
||||
#define FFBDAC_CFG_WTCTRL_DRS 0x00000010 /* Drawing Status
|
||||
* 1 = Network Drawing Active
|
||||
* 0 = Network Drawing Idle
|
||||
*/
|
||||
|
||||
/* Transparent Mask Control Register */
|
||||
#define FFBDAC_CFG_TMCTRL_OMSK 0x000000ff /* Overlay Mask */
|
||||
|
||||
/* Transparent Color Key Register */
|
||||
#define FFBDAC_CFG_TCOLORKEY_K 0x000000ff /* Overlay Color Key */
|
||||
|
||||
/* Window Address Mask Register (PAC2 only) */
|
||||
#define FFBDAC_CFG_WAMASK_PMSK 0x0000003f /* PWLUT select PMASK */
|
||||
#define FFBDAC_CFG_WAMASK_OMSK 0x00000300 /* OWLUT control OMASK */
|
||||
|
||||
/* (non-Overlay) Window Lookup Table Registers, PAC1 format */
|
||||
#define FFBDAC_PAC1_WLUT_DB 0x00000020 /* 0 = Buffer A, 1 = Buffer B */
|
||||
#define FFBDAC_PAC1_WLUT_C 0x0000001c /* C: Color Model Selection */
|
||||
#define FFBDAC_PAC1_WLUT_C_8P 0x00000000 /* C: 8bpp Pseudocolor */
|
||||
#define FFBDAC_PAC1_WLUT_C_8LG 0x00000004 /* C: 8bpp Linear Grey */
|
||||
#define FFBDAC_PAC1_WLUT_C_8NG 0x00000008 /* C: 8bpp Non-Linear Grey */
|
||||
#define FFBDAC_PAC1_WLUT_C_24D 0x00000010 /* C: 24bpp Directcolor */
|
||||
#define FFBDAC_PAC1_WLUT_C_24LT 0x00000014 /* C: 24bpp Linear Truecolor */
|
||||
#define FFBDAC_PAC1_WLUT_C_24NT 0x00000018 /* C: 24bpp Non-Linear Truecolor */
|
||||
#define FFBDAC_PAC1_WLUT_PCS 0x00000003 /* Pseudocolor Src */
|
||||
#define FFBDAC_PAC1_WLUT_P_XO 0x00000000 /* Pseudocolor Src - XO[7:0] */
|
||||
#define FFBDAC_PAC1_WLUT_P_R 0x00000001 /* Pseudocolor Src - R[7:0] */
|
||||
#define FFBDAC_PAC1_WLUT_P_G 0x00000002 /* Pseudocolor Src - G[7:0] */
|
||||
#define FFBDAC_PAC1_WLUT_P_B 0x00000003 /* Pseudocolor Src - B[7:0] */
|
||||
|
||||
/* (non-Overlay) Window Lookup Table Registers, PAC2 format */
|
||||
#define FFBDAC_PAC2_WLUT_PTBL 0x00000030 /* Palette Table Entry */
|
||||
#define FFBDAC_PAC2_WLUT_LKUP 0x00000100 /* 1 = Use palette, 0 = Bypass */
|
||||
#define FFBDAC_PAC2_WLUT_PCS 0x00003000 /* Pseudocolor Src */
|
||||
#define FFBDAC_PAC2_WLUT_P_XO 0x00000000 /* Pseudocolor Src - XO[7:0] */
|
||||
#define FFBDAC_PAC2_WLUT_P_R 0x00001000 /* Pseudocolor Src - R[7:0] */
|
||||
#define FFBDAC_PAC2_WLUT_P_G 0x00002000 /* Pseudocolor Src - G[7:0] */
|
||||
#define FFBDAC_PAC2_WLUT_P_B 0x00003000 /* Pseudocolor Src - B[7:0] */
|
||||
#define FFBDAC_PAC2_WLUT_DEPTH 0x00004000 /* 0 = Pseudocolor, 1 = Truecolor*/
|
||||
#define FFBDAC_PAC2_WLUT_DB 0x00008000 /* 0 = Buffer A, 1 = Buffer B */
|
||||
|
||||
/* Signature Analysis Control Register */
|
||||
#define FFBDAC_CFG_SANAL_SRR 0x000000ff /* DAC Seed/Result for Red */
|
||||
#define FFBDAC_CFG_SANAL_SRG 0x0000ff00 /* DAC Seed/Result for Green */
|
||||
#define FFBDAC_CFG_SANAL_SRB 0x00ff0000 /* DAC Seed/Result for Blue */
|
||||
#define FFBDAC_CFG_SANAL_RQST 0x01000000 /* Signature Capture Request */
|
||||
#define FFBDAC_CFG_SANAL_BSY 0x02000000 /* Signature Analysis Busy */
|
||||
#define FFBDAC_CFG_SANAL_DSM 0x04000000 /* Data Strobe Mode
|
||||
* 0 = Signature Analysis Mode
|
||||
* 1 = Data Strobe Mode
|
||||
*/
|
||||
|
||||
/* DAC Control Register */
|
||||
#define FFBDAC_CFG_DACCTRL_O2 0x00000003 /* Operand 2 Select
|
||||
* 00 = Normal Operation
|
||||
* 01 = Select 145mv Reference
|
||||
* 10 = Select Blue DAC Output
|
||||
* 11 = Reserved
|
||||
*/
|
||||
#define FFBDAC_CFG_DACCTRL_O1 0x0000000c /* Operand 1 Select
|
||||
* 00 = Normal Operation
|
||||
* 01 = Select Green DAC Output
|
||||
* 10 = Select Red DAC Output
|
||||
* 11 = Reserved
|
||||
*/
|
||||
#define FFBDAC_CFG_DACCTRL_CR 0x00000010 /* Comparator Result
|
||||
* 0 = operand1 < operand2
|
||||
* 1 = operand1 > operand2
|
||||
*/
|
||||
#define FFBDAC_CFG_DACCTRL_SGE 0x00000020 /* Sync-on-Green Enable */
|
||||
#define FFBDAC_CFG_DACCTRL_PE 0x00000040 /* Pedestal Enable */
|
||||
#define FFBDAC_CFG_DACCTRL_VPD 0x00000080 /* VSYNC* Pin Disable */
|
||||
#define FFBDAC_CFG_DACCTRL_SPB 0x00000100 /* Sync Polarity Bit
|
||||
* 0 = VSYNC* and CSYNC* active low
|
||||
* 1 = VSYNC* and CSYNC* active high
|
||||
*/
|
||||
|
||||
/* Timing Generator Control Register */
|
||||
#define FFBDAC_CFG_TGEN_VIDE 0x00000001 /* Video Enable */
|
||||
#define FFBDAC_CFG_TGEN_TGE 0x00000002 /* Timing Generator Enable */
|
||||
#define FFBDAC_CFG_TGEN_HSD 0x00000004 /* HSYNC* Disabled */
|
||||
#define FFBDAC_CFG_TGEN_VSD 0x00000008 /* VSYNC* Disabled */
|
||||
#define FFBDAC_CFG_TGEN_EQD 0x00000010 /* Equalization Disabled */
|
||||
#define FFBDAC_CFG_TGEN_MM 0x00000020 /* 0 = Slave, 1 = Master */
|
||||
#define FFBDAC_CFG_TGEN_IM 0x00000040 /* 1 = Interlaced Mode */
|
||||
|
||||
/* Device Identification Register, should be 0xA236E1AD for FFB bt497/bt498 */
|
||||
#define FFBDAC_CFG_DID_ONE 0x00000001 /* Always set */
|
||||
#define FFBDAC_CFG_DID_MANUF 0x00000ffe /* Manufacturer ID */
|
||||
#define FFBDAC_CFG_DID_PNUM 0x0ffff000 /* Device Part Number */
|
||||
#define FFBDAC_CFG_DID_REV 0xf0000000 /* Device Revision */
|
||||
|
||||
/* Monitor Port Data Register */
|
||||
#define FFBDAC_CFG_MPDATA_SCL 0x00000001 /* SCL Data */
|
||||
#define FFBDAC_CFG_MPDATA_SDA 0x00000002 /* SDA Data */
|
||||
|
||||
/* Monitor Port Sense Register */
|
||||
#define FFBDAC_CFG_MPSENSE_SCL 0x00000001 /* SCL Sense */
|
||||
#define FFBDAC_CFG_MPSENSE_SDA 0x00000002 /* SDA Sense */
|
||||
|
||||
/* DAC register access shorthands. */
|
||||
#define DACCUR_READ(DAC, ADDR) ((DAC)->cur = (ADDR), (DAC)->curdata)
|
||||
#define DACCUR_WRITE(DAC, ADDR, VAL) ((DAC)->cur = (ADDR), (DAC)->curdata = (VAL))
|
||||
#define DACCFG_READ(DAC, ADDR) ((DAC)->cfg = (ADDR), (DAC)->cfgdata)
|
||||
#define DACCFG_WRITE(DAC, ADDR, VAL) ((DAC)->cfg = (ADDR), (DAC)->cfgdata = (VAL))
|
||||
|
||||
typedef struct ffb_dac_hwstate {
|
||||
unsigned int ppllctrl;
|
||||
unsigned int gpllctrl;
|
||||
unsigned int pfctrl;
|
||||
unsigned int uctrl;
|
||||
unsigned int clut[256 * 4]; /* One 256 entry clut on PAC1, 4 on PAC2 */
|
||||
unsigned int ovluts[4]; /* Overlay WLUTS, PAC2 only */
|
||||
unsigned int wtctrl;
|
||||
unsigned int tmctrl;
|
||||
unsigned int tcolorkey;
|
||||
unsigned int wamask;
|
||||
unsigned int pwluts[64];
|
||||
unsigned int dacctrl;
|
||||
unsigned int tgen;
|
||||
unsigned int vbnp;
|
||||
unsigned int vbap;
|
||||
unsigned int vsnp;
|
||||
unsigned int vsap;
|
||||
unsigned int hsnp;
|
||||
unsigned int hbnp;
|
||||
unsigned int hbap;
|
||||
unsigned int hsyncnp;
|
||||
unsigned int hsyncap;
|
||||
unsigned int hscennp;
|
||||
unsigned int hscenap;
|
||||
unsigned int epnp;
|
||||
unsigned int einp;
|
||||
unsigned int eiap;
|
||||
} ffb_dac_hwstate_t;
|
||||
|
||||
typedef struct {
|
||||
Bool InUse;
|
||||
|
||||
/* The following fields are undefined unless InUse is TRUE. */
|
||||
int refcount;
|
||||
Bool canshare;
|
||||
unsigned int wlut_regval;
|
||||
int buffer; /* 0 = Buffer A, 1 = Buffer B */
|
||||
int depth; /* 8 or 32 bpp */
|
||||
int greyscale; /* 1 = greyscale, 0 = color */
|
||||
int linear; /* 1 = linear, 0 = non-linear */
|
||||
int direct; /* 1 = 24bpp directcolor */
|
||||
int channel; /* 0 = X, 1 = R, 2 = G, 3 = B */
|
||||
int palette; /* Only PAC2 has multiple CLUTs */
|
||||
} ffb_wid_info_t;
|
||||
|
||||
#define FFB_MAX_PWIDS 64
|
||||
typedef struct {
|
||||
int num_wids;
|
||||
int wid_shift; /* To get X channel value */
|
||||
ffb_wid_info_t wid_pool[FFB_MAX_PWIDS];
|
||||
} ffb_wid_pool_t;
|
||||
|
||||
typedef struct ffb_dac_info {
|
||||
unsigned int flags;
|
||||
#define FFB_DAC_PAC1 0x00000001 /* Pacifica1 DAC, BT9068 */
|
||||
#define FFB_DAC_PAC2 0x00000002 /* Pacifica2 DAC, BT498 */
|
||||
#define FFB_DAC_ICURCTL 0x00000004 /* Inverted CUR_CTRL bits */
|
||||
|
||||
unsigned int kernel_wid;
|
||||
|
||||
/* These registers need to be modified when changing DAC
|
||||
* timing state, so at init time we capture their values.
|
||||
*/
|
||||
unsigned int ffbcfg0;
|
||||
unsigned int ffbcfg2;
|
||||
unsigned int ffb_passin_ctrl; /* FFB2+/AFB only */
|
||||
|
||||
ffb_dac_hwstate_t kern_dac_state;
|
||||
ffb_dac_hwstate_t x_dac_state;
|
||||
|
||||
ffb_wid_pool_t wid_table;
|
||||
} ffb_dac_info_t;
|
||||
|
||||
#endif /* _FFB_DAC_H */
|
||||
@@ -1,47 +0,0 @@
|
||||
|
||||
#ifndef _FFB_DRISHARE_H
|
||||
#define _FFB_DRISHARE_H
|
||||
|
||||
typedef struct ffb_dri_state {
|
||||
int flags;
|
||||
#define FFB_DRI_FFB2 0x00000001
|
||||
#define FFB_DRI_FFB2PLUS 0x00000002
|
||||
#define FFB_DRI_PAC1 0x00000004
|
||||
#define FFB_DRI_PAC2 0x00000008
|
||||
|
||||
/* Indexed by DRI drawable id. */
|
||||
#define FFB_DRI_NWIDS 64
|
||||
unsigned int wid_table[FFB_DRI_NWIDS];
|
||||
} ffb_dri_state_t;
|
||||
|
||||
#define FFB_DRISHARE(SAREA) \
|
||||
((ffb_dri_state_t *) (((char *)(SAREA)) + sizeof(drm_sarea_t)))
|
||||
|
||||
typedef struct {
|
||||
drm_handle_t hFbcRegs;
|
||||
drmSize sFbcRegs;
|
||||
|
||||
drm_handle_t hDacRegs;
|
||||
drmSize sDacRegs;
|
||||
|
||||
drm_handle_t hSfb8r;
|
||||
drmSize sSfb8r;
|
||||
|
||||
drm_handle_t hSfb32;
|
||||
drmSize sSfb32;
|
||||
|
||||
drm_handle_t hSfb64;
|
||||
drmSize sSfb64;
|
||||
|
||||
/* Fastfill/Pagefill parameters. */
|
||||
unsigned char disable_pagefill;
|
||||
int fastfill_small_area;
|
||||
int pagefill_small_area;
|
||||
int fastfill_height;
|
||||
int fastfill_width;
|
||||
int pagefill_height;
|
||||
int pagefill_width;
|
||||
short Pf_AlignTab[0x800];
|
||||
} FFBDRIRec, *FFBDRIPtr;
|
||||
|
||||
#endif /* !(_FFB_DRISHARE_H) */
|
||||
@@ -1,508 +0,0 @@
|
||||
/*
|
||||
* Acceleration for the Creator and Creator3D framebuffer - register layout.
|
||||
*
|
||||
* Copyright (C) 1998,1999,2000 Jakub Jelinek (jakub@redhat.com)
|
||||
* Copyright (C) 1998 Michal Rehacek (majkl@iname.com)
|
||||
* Copyright (C) 1999 David S. Miller (davem@redhat.com)
|
||||
*
|
||||
* 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
|
||||
* JAKUB JELINEK, MICHAL REHACEK, OR DAVID MILLER 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 FFBREGS_H
|
||||
#define FFBREGS_H
|
||||
|
||||
/* Auxilliary clips. */
|
||||
typedef struct {
|
||||
volatile unsigned int min;
|
||||
volatile unsigned int max;
|
||||
} ffb_auxclip, *ffb_auxclipPtr;
|
||||
|
||||
/* FFB register set. */
|
||||
typedef struct _ffb_fbc {
|
||||
/* Next vertex registers, on the right we list which drawops
|
||||
* use said register and the logical name the register has in
|
||||
* that context.
|
||||
*/ /* DESCRIPTION DRAWOP(NAME) */
|
||||
/*0x00*/unsigned int pad1[3]; /* Reserved */
|
||||
/*0x0c*/volatile unsigned int alpha; /* ALPHA Transparency */
|
||||
/*0x10*/volatile unsigned int red; /* RED */
|
||||
/*0x14*/volatile unsigned int green; /* GREEN */
|
||||
/*0x18*/volatile unsigned int blue; /* BLUE */
|
||||
/*0x1c*/volatile unsigned int z; /* DEPTH */
|
||||
/*0x20*/volatile unsigned int y; /* Y triangle(DOYF) */
|
||||
/* aadot(DYF) */
|
||||
/* ddline(DYF) */
|
||||
/* aaline(DYF) */
|
||||
/*0x24*/volatile unsigned int x; /* X triangle(DOXF) */
|
||||
/* aadot(DXF) */
|
||||
/* ddline(DXF) */
|
||||
/* aaline(DXF) */
|
||||
/*0x28*/unsigned int pad2[2]; /* Reserved */
|
||||
/*0x30*/volatile unsigned int ryf; /* Y (alias to DOYF) ddline(RYF) */
|
||||
/* aaline(RYF) */
|
||||
/* triangle(RYF) */
|
||||
/*0x34*/volatile unsigned int rxf; /* X ddline(RXF) */
|
||||
/* aaline(RXF) */
|
||||
/* triangle(RXF) */
|
||||
/*0x38*/unsigned int pad3[2]; /* Reserved */
|
||||
/*0x40*/volatile unsigned int dmyf; /* Y (alias to DOYF) triangle(DMYF) */
|
||||
/*0x44*/volatile unsigned int dmxf; /* X triangle(DMXF) */
|
||||
/*0x48*/unsigned int pad4[2]; /* Reserved */
|
||||
/*0x50*/volatile unsigned int ebyi; /* Y (alias to RYI) polygon(EBYI) */
|
||||
/*0x54*/volatile unsigned int ebxi; /* X polygon(EBXI) */
|
||||
/*0x58*/unsigned int pad5[2]; /* Reserved */
|
||||
/*0x60*/volatile unsigned int by; /* Y brline(RYI) */
|
||||
/* fastfill(OP) */
|
||||
/* polygon(YI) */
|
||||
/* rectangle(YI) */
|
||||
/* bcopy(SRCY) */
|
||||
/* vscroll(SRCY) */
|
||||
/*0x64*/volatile unsigned int bx; /* X brline(RXI) */
|
||||
/* polygon(XI) */
|
||||
/* rectangle(XI) */
|
||||
/* bcopy(SRCX) */
|
||||
/* vscroll(SRCX) */
|
||||
/* fastfill(GO) */
|
||||
/*0x68*/volatile unsigned int dy; /* destination Y fastfill(DSTY) */
|
||||
/* bcopy(DSRY) */
|
||||
/* vscroll(DSRY) */
|
||||
/*0x6c*/volatile unsigned int dx; /* destination X fastfill(DSTX) */
|
||||
/* bcopy(DSTX) */
|
||||
/* vscroll(DSTX) */
|
||||
/*0x70*/volatile unsigned int bh; /* Y (alias to RYI) brline(DYI) */
|
||||
/* dot(DYI) */
|
||||
/* polygon(ETYI) */
|
||||
/* Height fastfill(H) */
|
||||
/* bcopy(H) */
|
||||
/* vscroll(H) */
|
||||
/* Y count fastfill(NY) */
|
||||
/*0x74*/volatile unsigned int bw; /* X dot(DXI) */
|
||||
/* brline(DXI) */
|
||||
/* polygon(ETXI) */
|
||||
/* fastfill(W) */
|
||||
/* bcopy(W) */
|
||||
/* vscroll(W) */
|
||||
/* fastfill(NX) */
|
||||
/*0x78*/unsigned int pad6[2]; /* Reserved */
|
||||
/*0x80*/unsigned int pad7[32]; /* Reserved */
|
||||
|
||||
/* Setup Unit's vertex state register */
|
||||
/*100*/ volatile unsigned int suvtx;
|
||||
/*104*/ unsigned int pad8[63]; /* Reserved */
|
||||
|
||||
/* Frame Buffer Control Registers */
|
||||
/*200*/ volatile unsigned int ppc; /* Pixel Processor Control */
|
||||
/*204*/ volatile unsigned int wid; /* Current WID */
|
||||
/*208*/ volatile unsigned int fg; /* FG data */
|
||||
/*20c*/ volatile unsigned int bg; /* BG data */
|
||||
/*210*/ volatile unsigned int consty; /* Constant Y */
|
||||
/*214*/ volatile unsigned int constz; /* Constant Z */
|
||||
/*218*/ volatile unsigned int xclip; /* X Clip */
|
||||
/*21c*/ volatile unsigned int dcss; /* Depth Cue Scale Slope */
|
||||
/*220*/ volatile unsigned int vclipmin; /* Viewclip XY Min Bounds */
|
||||
/*224*/ volatile unsigned int vclipmax; /* Viewclip XY Max Bounds */
|
||||
/*228*/ volatile unsigned int vclipzmin; /* Viewclip Z Min Bounds */
|
||||
/*22c*/ volatile unsigned int vclipzmax; /* Viewclip Z Max Bounds */
|
||||
/*230*/ volatile unsigned int dcsf; /* Depth Cue Scale Front Bound */
|
||||
/*234*/ volatile unsigned int dcsb; /* Depth Cue Scale Back Bound */
|
||||
/*238*/ volatile unsigned int dczf; /* Depth Cue Z Front */
|
||||
/*23c*/ volatile unsigned int dczb; /* Depth Cue Z Back */
|
||||
/*240*/ unsigned int pad9; /* Reserved */
|
||||
/*244*/ volatile unsigned int blendc; /* Alpha Blend Control */
|
||||
/*248*/ volatile unsigned int blendc1; /* Alpha Blend Color 1 */
|
||||
/*24c*/ volatile unsigned int blendc2; /* Alpha Blend Color 2 */
|
||||
/*250*/ volatile unsigned int fbramitc; /* FB RAM Interleave Test Control */
|
||||
/*254*/ volatile unsigned int fbc; /* Frame Buffer Control */
|
||||
/*258*/ volatile unsigned int rop; /* Raster OPeration */
|
||||
/*25c*/ volatile unsigned int cmp; /* Frame Buffer Compare */
|
||||
/*260*/ volatile unsigned int matchab; /* Buffer AB Match Mask */
|
||||
/*264*/ volatile unsigned int matchc; /* Buffer C(YZ) Match Mask */
|
||||
/*268*/ volatile unsigned int magnab; /* Buffer AB Magnitude Mask */
|
||||
/*26c*/ volatile unsigned int magnc; /* Buffer C(YZ) Magnitude Mask */
|
||||
/*270*/ volatile unsigned int fbcfg0; /* Frame Buffer Config 0 */
|
||||
/*274*/ volatile unsigned int fbcfg1; /* Frame Buffer Config 1 */
|
||||
/*278*/ volatile unsigned int fbcfg2; /* Frame Buffer Config 2 */
|
||||
/*27c*/ volatile unsigned int fbcfg3; /* Frame Buffer Config 3 */
|
||||
/*280*/ volatile unsigned int ppcfg; /* Pixel Processor Config */
|
||||
/*284*/ volatile unsigned int pick; /* Picking Control */
|
||||
/*288*/ volatile unsigned int fillmode; /* FillMode */
|
||||
/*28c*/ volatile unsigned int fbramwac; /* FB RAM Write Address Control */
|
||||
/*290*/ volatile unsigned int pmask; /* RGB PlaneMask */
|
||||
/*294*/ volatile unsigned int xpmask; /* X PlaneMask */
|
||||
/*298*/ volatile unsigned int ypmask; /* Y PlaneMask */
|
||||
/*29c*/ volatile unsigned int zpmask; /* Z PlaneMask */
|
||||
/*2a0*/ ffb_auxclip auxclip[4]; /* Auxilliary Viewport Clip */
|
||||
|
||||
/* New 3dRAM III support regs */
|
||||
/*2c0*/ volatile unsigned int rawblend2;
|
||||
/*2c4*/ volatile unsigned int rawpreblend;
|
||||
/*2c8*/ volatile unsigned int rawstencil;
|
||||
/*2cc*/ volatile unsigned int rawstencilctl;
|
||||
/*2d0*/ volatile unsigned int threedram1;
|
||||
/*2d4*/ volatile unsigned int threedram2;
|
||||
/*2d8*/ volatile unsigned int passin;
|
||||
/*2dc*/ volatile unsigned int rawclrdepth;
|
||||
/*2e0*/ volatile unsigned int rawpmask;
|
||||
/*2e4*/ volatile unsigned int rawcsrc;
|
||||
/*2e8*/ volatile unsigned int rawmatch;
|
||||
/*2ec*/ volatile unsigned int rawmagn;
|
||||
/*2f0*/ volatile unsigned int rawropblend;
|
||||
/*2f4*/ volatile unsigned int rawcmp;
|
||||
/*2f8*/ volatile unsigned int rawwac;
|
||||
/*2fc*/ volatile unsigned int fbramid;
|
||||
|
||||
/*300*/ volatile unsigned int drawop; /* Draw OPeration */
|
||||
/*304*/ unsigned int pad10[2]; /* Reserved */
|
||||
/*30c*/ volatile unsigned int lpat; /* Line Pattern control */
|
||||
/*310*/ unsigned int pad11; /* Reserved */
|
||||
/*314*/ volatile unsigned int fontxy; /* XY Font coordinate */
|
||||
/*318*/ volatile unsigned int fontw; /* Font Width */
|
||||
/*31c*/ volatile unsigned int fontinc; /* Font Increment */
|
||||
/*320*/ volatile unsigned int font; /* Font bits */
|
||||
/*324*/ unsigned int pad12[3]; /* Reserved */
|
||||
/*330*/ volatile unsigned int blend2;
|
||||
/*334*/ volatile unsigned int preblend;
|
||||
/*338*/ volatile unsigned int stencil;
|
||||
/*33c*/ volatile unsigned int stencilctl;
|
||||
|
||||
/*340*/ unsigned int pad13[4]; /* Reserved */
|
||||
/*350*/ volatile unsigned int dcss1; /* Depth Cue Scale Slope 1 */
|
||||
/*354*/ volatile unsigned int dcss2; /* Depth Cue Scale Slope 2 */
|
||||
/*358*/ volatile unsigned int dcss3; /* Depth Cue Scale Slope 3 */
|
||||
/*35c*/ volatile unsigned int widpmask;
|
||||
/*360*/ volatile unsigned int dcs2;
|
||||
/*364*/ volatile unsigned int dcs3;
|
||||
/*368*/ volatile unsigned int dcs4;
|
||||
/*36c*/ unsigned int pad14; /* Reserved */
|
||||
/*370*/ volatile unsigned int dcd2;
|
||||
/*374*/ volatile unsigned int dcd3;
|
||||
/*378*/ volatile unsigned int dcd4;
|
||||
/*37c*/ unsigned int pad15; /* Reserved */
|
||||
/*380*/ volatile unsigned int pattern[32]; /* area Pattern */
|
||||
/*400*/ unsigned int pad16[8]; /* Reserved */
|
||||
/*420*/ volatile unsigned int reset; /* chip RESET */
|
||||
/*424*/ unsigned int pad17[247]; /* Reserved */
|
||||
/*800*/ volatile unsigned int devid; /* Device ID */
|
||||
/*804*/ unsigned int pad18[63]; /* Reserved */
|
||||
/*900*/ volatile unsigned int ucsr; /* User Control & Status Register */
|
||||
/*904*/ unsigned int pad19[31]; /* Reserved */
|
||||
/*980*/ volatile unsigned int mer; /* Mode Enable Register */
|
||||
/*984*/ unsigned int pad20[1439]; /* Reserved */
|
||||
} ffb_fbc, *ffb_fbcPtr;
|
||||
|
||||
/* Draw operations */
|
||||
#define FFB_DRAWOP_DOT 0x00
|
||||
#define FFB_DRAWOP_AADOT 0x01
|
||||
#define FFB_DRAWOP_BRLINECAP 0x02
|
||||
#define FFB_DRAWOP_BRLINEOPEN 0x03
|
||||
#define FFB_DRAWOP_DDLINE 0x04
|
||||
#define FFB_DRAWOP_AALINE 0x05
|
||||
#define FFB_DRAWOP_TRIANGLE 0x06
|
||||
#define FFB_DRAWOP_POLYGON 0x07
|
||||
#define FFB_DRAWOP_RECTANGLE 0x08
|
||||
#define FFB_DRAWOP_FASTFILL 0x09
|
||||
#define FFB_DRAWOP_BCOPY 0x0a /* Not implemented in any FFB, VIS is faster */
|
||||
#define FFB_DRAWOP_VSCROLL 0x0b /* Up to 12x faster than BCOPY, 3-4x faster than VIS */
|
||||
|
||||
/* FastFill operation codes. */
|
||||
#define FFB_FASTFILL_PAGE 0x01
|
||||
#define FFB_FASTFILL_BLOCK 0x02
|
||||
#define FFB_FASTFILL_COLOR_BLK 0x03
|
||||
#define FFB_FASTFILL_BLOCK_X 0x04
|
||||
|
||||
/* Spanfill Unit Line Pattern */
|
||||
#define FFB_LPAT_SCALEPTR 0xf0000000
|
||||
#define FFB_LPAT_SCALEPTR_SHIFT 28
|
||||
#define FFB_LPAT_PATPTR 0x0f000000
|
||||
#define FFB_LPAT_PATPTR_SHIFT 24
|
||||
#define FFB_LPAT_SCALEVAL 0x00f00000
|
||||
#define FFB_LPAT_SCALEVAL_SHIFT 20
|
||||
#define FFB_LPAT_PATLEN 0x000f0000
|
||||
#define FFB_LPAT_PATLEN_SHIFT 16
|
||||
#define FFB_LPAT_PATTERN 0x0000ffff
|
||||
#define FFB_LPAT_PATTERN_SHIFT 0
|
||||
|
||||
/* Pixel processor control */
|
||||
/* Force WID */
|
||||
#define FFB_PPC_FW_DISABLE 0x800000
|
||||
#define FFB_PPC_FW_ENABLE 0xc00000
|
||||
#define FFB_PPC_FW_MASK 0xc00000
|
||||
/* Auxiliary clip */
|
||||
#define FFB_PPC_ACE_DISABLE 0x040000
|
||||
#define FFB_PPC_ACE_AUX_SUB 0x080000
|
||||
#define FFB_PPC_ACE_AUX_ADD 0x0c0000
|
||||
#define FFB_PPC_ACE_MASK 0x0c0000
|
||||
/* Depth cue */
|
||||
#define FFB_PPC_DCE_DISABLE 0x020000
|
||||
#define FFB_PPC_DCE_ENABLE 0x030000
|
||||
#define FFB_PPC_DCE_MASK 0x030000
|
||||
/* Alpha blend */
|
||||
#define FFB_PPC_ABE_DISABLE 0x008000
|
||||
#define FFB_PPC_ABE_ENABLE 0x00c000
|
||||
#define FFB_PPC_ABE_MASK 0x00c000
|
||||
/* View clip */
|
||||
#define FFB_PPC_VCE_DISABLE 0x001000
|
||||
#define FFB_PPC_VCE_2D 0x002000
|
||||
#define FFB_PPC_VCE_3D 0x003000
|
||||
#define FFB_PPC_VCE_MASK 0x003000
|
||||
/* Area pattern */
|
||||
#define FFB_PPC_APE_DISABLE 0x000800
|
||||
#define FFB_PPC_APE_ENABLE 0x000c00
|
||||
#define FFB_PPC_APE_MASK 0x000c00
|
||||
/* Transparent background */
|
||||
#define FFB_PPC_TBE_OPAQUE 0x000200
|
||||
#define FFB_PPC_TBE_TRANSPARENT 0x000300
|
||||
#define FFB_PPC_TBE_MASK 0x000300
|
||||
/* Z source */
|
||||
#define FFB_PPC_ZS_VAR 0x000080
|
||||
#define FFB_PPC_ZS_CONST 0x0000c0
|
||||
#define FFB_PPC_ZS_MASK 0x0000c0
|
||||
/* Y source */
|
||||
#define FFB_PPC_YS_VAR 0x000020
|
||||
#define FFB_PPC_YS_CONST 0x000030
|
||||
#define FFB_PPC_YS_MASK 0x000030
|
||||
/* X source */
|
||||
#define FFB_PPC_XS_WID 0x000004
|
||||
#define FFB_PPC_XS_VAR 0x000008
|
||||
#define FFB_PPC_XS_CONST 0x00000c
|
||||
#define FFB_PPC_XS_MASK 0x00000c
|
||||
/* Color (BGR) source */
|
||||
#define FFB_PPC_CS_VAR 0x000002
|
||||
#define FFB_PPC_CS_CONST 0x000003
|
||||
#define FFB_PPC_CS_MASK 0x000003
|
||||
|
||||
/* X Clip */
|
||||
#define FFB_XCLIP_XREF 0x000000ff
|
||||
#define FFB_XCLIP_TEST_MASK 0x00070000
|
||||
#define FFB_XCLIP_TEST_ALWAYS 0x00000000
|
||||
#define FFB_XCLIP_TEST_GT 0x00010000
|
||||
#define FFB_XCLIP_TEST_EQ 0x00020000
|
||||
#define FFB_XCLIP_TEST_GE 0x00030000
|
||||
#define FFB_XCLIP_TEST_NEVER 0x00040000
|
||||
#define FFB_XCLIP_TEST_LE 0x00050000
|
||||
#define FFB_XCLIP_TEST_NE 0x00060000
|
||||
#define FFB_XCLIP_TEST_LT 0x00070000
|
||||
|
||||
/* FB Control register */
|
||||
/* Write buffer dest */
|
||||
#define FFB_FBC_WB_A 0x20000000
|
||||
#define FFB_FBC_WB_B 0x40000000
|
||||
#define FFB_FBC_WB_AB 0x60000000
|
||||
#define FFB_FBC_WB_C 0x80000000
|
||||
#define FFB_FBC_WB_AC 0xa0000000
|
||||
#define FFB_FBC_WB_BC 0xc0000000
|
||||
#define FFB_FBC_WB_ABC 0xe0000000
|
||||
#define FFB_FBC_WB_MASK 0xe0000000
|
||||
/* Write enable */
|
||||
#define FFB_FBC_WE_FORCEOFF 0x00100000
|
||||
#define FFB_FBC_WE_FORCEON 0x00200000
|
||||
#define FFB_FBC_WE_USE_WMASK 0x00300000
|
||||
#define FFB_FBC_WE_MASK 0x00300000
|
||||
/* Write group mode */
|
||||
#define FFB_FBC_WM_RSVD 0x00040000
|
||||
#define FFB_FBC_WM_COMBINED 0x00080000
|
||||
#define FFB_FBC_WM_SEPARATE 0x000c0000
|
||||
#define FFB_FBC_WM_MASK 0x000c0000
|
||||
/* Read buffer src */
|
||||
#define FFB_FBC_RB_A 0x00004000
|
||||
#define FFB_FBC_RB_B 0x00008000
|
||||
#define FFB_FBC_RB_C 0x0000c000
|
||||
#define FFB_FBC_RB_MASK 0x0000c000
|
||||
/* Stereo buf dest */
|
||||
#define FFB_FBC_SB_LEFT 0x00001000
|
||||
#define FFB_FBC_SB_RIGHT 0x00002000
|
||||
#define FFB_FBC_SB_BOTH 0x00003000
|
||||
#define FFB_FBC_SB_MASK 0x00003000
|
||||
/* Z plane group enable */
|
||||
#define FFB_FBC_ZE_OFF 0x00000400
|
||||
#define FFB_FBC_ZE_ON 0x00000800
|
||||
#define FFB_FBC_ZE_MASK 0x00000c00
|
||||
/* Y plane group enable */
|
||||
#define FFB_FBC_YE_OFF 0x00000100
|
||||
#define FFB_FBC_YE_ON 0x00000200
|
||||
#define FFB_FBC_YE_MASK 0x00000300
|
||||
/* X plane group enable */
|
||||
#define FFB_FBC_XE_OFF 0x00000040
|
||||
#define FFB_FBC_XE_ON 0x00000080
|
||||
#define FFB_FBC_XE_MASK 0x000000c0
|
||||
/* B plane group enable */
|
||||
#define FFB_FBC_BE_OFF 0x00000010
|
||||
#define FFB_FBC_BE_ON 0x00000020
|
||||
#define FFB_FBC_BE_MASK 0x00000030
|
||||
/* G plane group enable */
|
||||
#define FFB_FBC_GE_OFF 0x00000004
|
||||
#define FFB_FBC_GE_ON 0x00000008
|
||||
#define FFB_FBC_GE_MASK 0x0000000c
|
||||
/* R plane group enable */
|
||||
#define FFB_FBC_RE_OFF 0x00000001
|
||||
#define FFB_FBC_RE_ON 0x00000002
|
||||
#define FFB_FBC_RE_MASK 0x00000003
|
||||
/* Combined */
|
||||
#define FFB_FBC_RGBE_OFF 0x00000015
|
||||
#define FFB_FBC_RGBE_ON 0x0000002a
|
||||
#define FFB_FBC_RGBE_MASK 0x0000003f
|
||||
|
||||
/* Raster OP */
|
||||
#define FFB_ROP_YZ_MASK 0x008f0000
|
||||
#define FFB_ROP_X_MASK 0x00008f00
|
||||
#define FFB_ROP_RGB_MASK 0x0000008f
|
||||
|
||||
/* Now the rops themselves which get shifted into the
|
||||
* above fields.
|
||||
*/
|
||||
#define FFB_ROP_EDIT_BIT 0x80
|
||||
#define FFB_ROP_ZERO 0x80
|
||||
#define FFB_ROP_NEW_AND_OLD 0x81
|
||||
#define FFB_ROP_NEW_AND_NOLD 0x82
|
||||
#define FFB_ROP_NEW 0x83
|
||||
#define FFB_ROP_NNEW_AND_OLD 0x84
|
||||
#define FFB_ROP_OLD 0x85
|
||||
#define FFB_ROP_NEW_XOR_OLD 0x86
|
||||
#define FFB_ROP_NEW_OR_OLD 0x87
|
||||
#define FFB_ROP_NNEW_AND_NOLD 0x88
|
||||
#define FFB_ROP_NNEW_XOR_NOLD 0x89
|
||||
#define FFB_ROP_NOLD 0x8a
|
||||
#define FFB_ROP_NEW_OR_NOLD 0x8b
|
||||
#define FFB_ROP_NNEW 0x8c
|
||||
#define FFB_ROP_NNEW_OR_OLD 0x8d
|
||||
#define FFB_ROP_NNEW_OR_NOLD 0x8e
|
||||
#define FFB_ROP_ONES 0x8f
|
||||
|
||||
/* FB Compare */
|
||||
#define FFB_CMP_MATCHC_MASK 0x8f000000
|
||||
#define FFB_CMP_MAGNC_MASK 0x00870000
|
||||
#define FFB_CMP_MATCHAB_MASK 0x0000ff00
|
||||
#define FFB_CMP_MAGNAB_MASK 0x000000ff
|
||||
|
||||
/* Compare Match codes */
|
||||
#define FFB_CMP_MATCH_EDIT_BIT 0x80
|
||||
#define FFB_CMP_MATCH_ALWAYS 0x80
|
||||
#define FFB_CMP_MATCH_NEVER 0x81
|
||||
#define FFB_CMP_MATCH_EQ 0x82
|
||||
#define FFB_CMP_MATCH_NE 0x83
|
||||
#define FFB_CMP_MATCH_A_ALWAYS 0xc0
|
||||
#define FFB_CMP_MATCH_B_ALWAYS 0xa0
|
||||
|
||||
/* Compare Magnitude codes */
|
||||
#define FFB_CMP_MAGN_EDIT_BIT 0x80
|
||||
#define FFB_CMP_MAGN_ALWAYS 0x80
|
||||
#define FFB_CMP_MAGN_GT 0x81
|
||||
#define FFB_CMP_MAGN_EQ 0x82
|
||||
#define FFB_CMP_MAGN_GE 0x83
|
||||
#define FFB_CMP_MAGN_NEVER 0x84
|
||||
#define FFB_CMP_MAGN_LE 0x85
|
||||
#define FFB_CMP_MAGN_NE 0x86
|
||||
#define FFB_CMP_MAGN_LT 0x87
|
||||
#define FFB_CMP_MAGN_A_ALWAYS 0xc0
|
||||
#define FFB_CMP_MAGN_B_ALWAYS 0xa0
|
||||
|
||||
/* User Control and Status */
|
||||
#define FFB_UCSR_FIFO_MASK 0x00000fff
|
||||
#define FFB_UCSR_PICK_NO_HIT 0x00020000
|
||||
#define FFB_UCSR_PICK_HIT 0x00030000
|
||||
#define FFB_UCSR_PICK_DISABLE 0x00080000
|
||||
#define FFB_UCSR_PICK_ENABLE 0x000c0000
|
||||
#define FFB_UCSR_FB_BUSY 0x01000000
|
||||
#define FFB_UCSR_RP_BUSY 0x02000000
|
||||
#define FFB_UCSR_ALL_BUSY (FFB_UCSR_RP_BUSY|FFB_UCSR_FB_BUSY)
|
||||
#define FFB_UCSR_READ_ERR 0x40000000
|
||||
#define FFB_UCSR_FIFO_OVFL 0x80000000
|
||||
#define FFB_UCSR_ALL_ERRORS (FFB_UCSR_READ_ERR|FFB_UCSR_FIFO_OVFL)
|
||||
|
||||
/* Mode Enable Register */
|
||||
#define FFB_MER_EIRA 0x00000080 /* Enable read-ahead, increasing */
|
||||
#define FFB_MER_EDRA 0x000000c0 /* Enable read-ahead, decreasing */
|
||||
#define FFB_MER_DRA 0x00000040 /* No read-ahead */
|
||||
|
||||
/* FBram Config 0 */
|
||||
#define FFB_FBCFG0_RFTIME 0xff800000
|
||||
#define FFB_FBCFG0_XMAX 0x007c0000
|
||||
#define FFB_FBCFG0_YMAX 0x0003ffc0
|
||||
#define FFB_FBCFG0_RES_MASK 0x00000030
|
||||
#define FFB_FBCFG0_RES_HIGH 0x00000030 /* 1920x1360 */
|
||||
#define FFB_FBCFG0_RES_STD 0x00000020 /* 1280x1024 */
|
||||
#define FFB_FBCFG0_RES_STEREO 0x00000010 /* 960x580 */
|
||||
#define FFB_FBCFG0_RES_PRTRAIT 0x00000000 /* 1280x2048 */
|
||||
#define FFB_FBCFG0_ITRLACE 0x00000000
|
||||
#define FFB_FBCFG0_SEQUENTIAL 0x00000008
|
||||
#define FFB_FBCFG0_DRENA 0x00000004
|
||||
#define FFB_FBCFG0_BPMODE 0x00000002
|
||||
#define FFB_FBCFG0_RFRSH_RST 0x00000001
|
||||
|
||||
typedef struct _ffb_dac {
|
||||
volatile unsigned int cfg;
|
||||
volatile unsigned int cfgdata;
|
||||
volatile unsigned int cur;
|
||||
volatile unsigned int curdata;
|
||||
} ffb_dac, *ffb_dacPtr;
|
||||
|
||||
/* Writing 2 32-bit registers at a time using 64-bit stores. -DaveM */
|
||||
#if defined(__GNUC__) && defined(USE_VIS)
|
||||
/* 64-bit register writing support.
|
||||
* Note: "lo" means "low address".
|
||||
*/
|
||||
#define FFB_WRITE64_COMMON(__regp, __lo32, __hi32, REG0, REG1) \
|
||||
do { __extension__ register unsigned int __r0 __asm__(""#REG0); \
|
||||
__extension__ register unsigned int __r1 __asm__(""#REG1); \
|
||||
__r0 = (__lo32); \
|
||||
__r1 = (__hi32); \
|
||||
__asm__ __volatile__ ("sllx\t%0, 32, %%g1\n\t" \
|
||||
"srl\t%1, 0, %1\n\t" \
|
||||
"or\t%%g1, %1, %%g1\n\t" \
|
||||
"stx\t%%g1, %2" \
|
||||
: : "r" (__r0), "r" (__r1), "m" (*(__regp)) : "g1"); \
|
||||
} while(0)
|
||||
|
||||
#define FFB_WRITE64P(__regp, __srcp) \
|
||||
do { __asm__ __volatile__ ("ldx\t%0, %%g2;" \
|
||||
"stx\t%%g2, %1" \
|
||||
: : "m" (*(__srcp)), "m" (*(__regp)) \
|
||||
: "g2"); \
|
||||
} while(0)
|
||||
|
||||
#define FFB_WRITE64(__regp, __lo32, __hi32) \
|
||||
FFB_WRITE64_COMMON(__regp, __lo32, __hi32, g2, g3)
|
||||
#define FFB_WRITE64_2(__regp, __lo32, __hi32) \
|
||||
FFB_WRITE64_COMMON(__regp, __lo32, __hi32, g4, g5)
|
||||
#define FFB_WRITE64_3(__regp, __lo32, __hi32) \
|
||||
FFB_WRITE64_COMMON(__regp, __lo32, __hi32, o4, o5)
|
||||
|
||||
#else /* Do not use 64-bit writes. */
|
||||
|
||||
#define FFB_WRITE64(__regp, __lo32, __hi32) \
|
||||
do { volatile unsigned int *__p = (__regp); \
|
||||
*__p = (__lo32); \
|
||||
*(__p + 1) = (__hi32); \
|
||||
} while(0)
|
||||
|
||||
#define FFB_WRITE64P(__regp, __srcp) \
|
||||
do { volatile unsigned int *__p = (__regp); \
|
||||
unsigned int *__q = (__srcp); \
|
||||
*__p = *__q; \
|
||||
*(__p + 1) = *(__q + 1); \
|
||||
} while(0)
|
||||
|
||||
#define FFB_WRITE64_2(__regp, __lo32, __hi32) \
|
||||
FFB_WRITE64(__regp, __lo32, __hi32)
|
||||
#define FFB_WRITE64_3(__regp, __lo32, __hi32) \
|
||||
FFB_WRITE64(__regp, __lo32, __hi32)
|
||||
#endif
|
||||
|
||||
#endif /* FFBREGS_H */
|
||||
@@ -1,34 +0,0 @@
|
||||
# src/mesa/drivers/dri/gamma/Makefile
|
||||
|
||||
TOP = ../../../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
LIBNAME = gamma_dri.so
|
||||
|
||||
# Not yet
|
||||
# MINIGLX_SOURCES = server/gamma_dri.c
|
||||
|
||||
DRIVER_SOURCES = \
|
||||
gamma_context.c \
|
||||
gamma_dd.c \
|
||||
gamma_inithw.c \
|
||||
gamma_lock.c \
|
||||
gamma_render.c \
|
||||
gamma_screen.c \
|
||||
gamma_span.c \
|
||||
gamma_state.c \
|
||||
gamma_tex.c \
|
||||
gamma_texmem.c \
|
||||
gamma_texstate.c \
|
||||
gamma_tris.c \
|
||||
gamma_vb.c \
|
||||
gamma_xmesa.c
|
||||
|
||||
C_SOURCES = \
|
||||
$(COMMON_SOURCES) \
|
||||
$(DRIVER_SOURCES)
|
||||
|
||||
ASM_SOURCES =
|
||||
|
||||
include ../Makefile.template
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,229 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*
|
||||
*/
|
||||
#include "gamma_context.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "vbo/vbo.h"
|
||||
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
|
||||
#include "main/context.h"
|
||||
#include "main/simple_list.h"
|
||||
#include "main/imports.h"
|
||||
#include "main/matrix.h"
|
||||
#include "main/extensions.h"
|
||||
#if defined(USE_X86_ASM)
|
||||
#include "x86/common_x86_asm.h"
|
||||
#endif
|
||||
#include "main/simple_list.h"
|
||||
#include "main/mm.h"
|
||||
|
||||
|
||||
#include "gamma_vb.h"
|
||||
#include "gamma_tris.h"
|
||||
#include "gamma_macros.h"
|
||||
|
||||
extern const struct tnl_pipeline_stage _gamma_render_stage;
|
||||
|
||||
static const struct tnl_pipeline_stage *gamma_pipeline[] = {
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage,
|
||||
&_tnl_fog_coordinate_stage,
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
/* REMOVE: point attenuation stage */
|
||||
#if 1
|
||||
&_gamma_render_stage, /* ADD: unclipped rastersetup-to-dma */
|
||||
#endif
|
||||
&_tnl_render_stage,
|
||||
0,
|
||||
};
|
||||
|
||||
GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
|
||||
__DRIcontext *driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
{
|
||||
GLcontext *ctx, *shareCtx;
|
||||
__DRIscreen *sPriv = driContextPriv->driScreenPriv;
|
||||
gammaContextPtr gmesa;
|
||||
gammaScreenPtr gammascrn;
|
||||
GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+
|
||||
sizeof(drm_sarea_t));
|
||||
struct dd_function_table functions;
|
||||
|
||||
gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) );
|
||||
if (!gmesa)
|
||||
return GL_FALSE;
|
||||
|
||||
/* Init default driver functions then plug in our gamma-specific functions
|
||||
* (the texture functions are especially important)
|
||||
*/
|
||||
_mesa_init_driver_functions( &functions );
|
||||
gammaDDInitTextureFuncs( &functions );
|
||||
|
||||
/* Allocate the Mesa context */
|
||||
if (sharedContextPrivate)
|
||||
shareCtx = ((gammaContextPtr) sharedContextPrivate)->glCtx;
|
||||
else
|
||||
shareCtx = NULL;
|
||||
|
||||
gmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
|
||||
&functions, (void *) gmesa);
|
||||
if (!gmesa->glCtx) {
|
||||
FREE(gmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
gmesa->driContext = driContextPriv;
|
||||
gmesa->driScreen = sPriv;
|
||||
gmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
|
||||
|
||||
gmesa->hHWContext = driContextPriv->hHWContext;
|
||||
gmesa->driHwLock = &sPriv->pSAREA->lock;
|
||||
gmesa->driFd = sPriv->fd;
|
||||
gmesa->sarea = saPriv;
|
||||
|
||||
gammascrn = gmesa->gammaScreen = (gammaScreenPtr)(sPriv->private);
|
||||
|
||||
ctx = gmesa->glCtx;
|
||||
|
||||
ctx->Const.MaxTextureLevels = GAMMA_TEX_MAXLEVELS;
|
||||
ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */
|
||||
ctx->Const.MaxTextureImageUnits = 1;
|
||||
ctx->Const.MaxTextureCoordUnits = 1;
|
||||
|
||||
ctx->Const.MinLineWidth = 0.0;
|
||||
ctx->Const.MaxLineWidth = 255.0;
|
||||
|
||||
ctx->Const.MinLineWidthAA = 0.0;
|
||||
ctx->Const.MaxLineWidthAA = 65536.0;
|
||||
|
||||
ctx->Const.MinPointSize = 0.0;
|
||||
ctx->Const.MaxPointSize = 255.0;
|
||||
|
||||
ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */
|
||||
ctx->Const.MaxPointSizeAA = 16.0;
|
||||
ctx->Const.PointSizeGranularity = 0.25;
|
||||
|
||||
ctx->Const.MaxDrawBuffers = 1;
|
||||
|
||||
gmesa->texHeap = mmInit( 0, gmesa->gammaScreen->textureSize );
|
||||
|
||||
make_empty_list(&gmesa->TexObjList);
|
||||
make_empty_list(&gmesa->SwappedOut);
|
||||
|
||||
gmesa->CurrentTexObj[0] = 0;
|
||||
gmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */
|
||||
|
||||
gmesa->RenderIndex = ~0;
|
||||
|
||||
|
||||
/* Initialize the software rasterizer and helper modules.
|
||||
*/
|
||||
_swrast_CreateContext( ctx );
|
||||
_vbo_CreateContext( ctx );
|
||||
_tnl_CreateContext( ctx );
|
||||
_swsetup_CreateContext( ctx );
|
||||
|
||||
/* Install the customized pipeline:
|
||||
*/
|
||||
_tnl_destroy_pipeline( ctx );
|
||||
_tnl_install_pipeline( ctx, gamma_pipeline );
|
||||
|
||||
/* Configure swrast & TNL to match hardware characteristics:
|
||||
*/
|
||||
_swrast_allow_pixel_fog( ctx, GL_FALSE );
|
||||
_swrast_allow_vertex_fog( ctx, GL_TRUE );
|
||||
_tnl_allow_pixel_fog( ctx, GL_FALSE );
|
||||
_tnl_allow_vertex_fog( ctx, GL_TRUE );
|
||||
|
||||
gammaInitVB( ctx );
|
||||
gammaDDInitExtensions( ctx );
|
||||
/* XXX these should really go right after _mesa_init_driver_functions() */
|
||||
gammaDDInitDriverFuncs( ctx );
|
||||
gammaDDInitStateFuncs( ctx );
|
||||
gammaDDInitSpanFuncs( ctx );
|
||||
gammaDDInitTriFuncs( ctx );
|
||||
gammaDDInitState( gmesa );
|
||||
|
||||
gammaInitTextureObjects( ctx );
|
||||
|
||||
driContextPriv->driverPrivate = (void *)gmesa;
|
||||
|
||||
GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
|
||||
1, &gmesa->bufIndex, &gmesa->bufSize,
|
||||
&gmesa->buf, &gmesa->bufCount, gammascrn);
|
||||
|
||||
#ifdef DO_VALIDATE
|
||||
GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
|
||||
1, &gmesa->WCbufIndex, &gmesa->WCbufSize,
|
||||
&gmesa->WCbuf, &gmesa->WCbufCount, gammascrn);
|
||||
#endif
|
||||
|
||||
switch (glVisual->depthBits) {
|
||||
case 16:
|
||||
gmesa->DeltaMode = DM_Depth16;
|
||||
gmesa->depth_scale = 1.0f / 0xffff;
|
||||
break;
|
||||
case 24:
|
||||
gmesa->DeltaMode = DM_Depth24;
|
||||
gmesa->depth_scale = 1.0f / 0xffffff;
|
||||
break;
|
||||
case 32:
|
||||
gmesa->DeltaMode = DM_Depth32;
|
||||
gmesa->depth_scale = 1.0f / 0xffffffff;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gmesa->DepthSize = glVisual->depthBits;
|
||||
gmesa->Flags = GAMMA_FRONT_BUFFER;
|
||||
gmesa->Flags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);
|
||||
gmesa->Flags |= (gmesa->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0);
|
||||
|
||||
gmesa->EnabledFlags = GAMMA_FRONT_BUFFER;
|
||||
gmesa->EnabledFlags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);
|
||||
|
||||
|
||||
if (gmesa->Flags & GAMMA_BACK_BUFFER) {
|
||||
gmesa->readOffset = gmesa->drawOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
|
||||
} else {
|
||||
gmesa->readOffset = gmesa->drawOffset = 0;
|
||||
}
|
||||
|
||||
gammaInitHW( gmesa );
|
||||
|
||||
driContextPriv->driverPrivate = (void *)gmesa;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
@@ -1,401 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GAMMA_CONTEXT_H_
|
||||
#define _GAMMA_CONTEXT_H_
|
||||
|
||||
#include "dri_util.h"
|
||||
#include "drm.h"
|
||||
#include "drm_sarea.h"
|
||||
#include "main/colormac.h"
|
||||
#include "gamma_regs.h"
|
||||
#include "gamma_screen.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "glint_dri.h"
|
||||
#include "main/mm.h"
|
||||
|
||||
typedef union {
|
||||
unsigned int i;
|
||||
float f;
|
||||
} dmaBufRec, *dmaBuf;
|
||||
|
||||
/* Flags for context */
|
||||
#define GAMMA_FRONT_BUFFER 0x00000001
|
||||
#define GAMMA_BACK_BUFFER 0x00000002
|
||||
#define GAMMA_DEPTH_BUFFER 0x00000004
|
||||
#define GAMMA_STENCIL_BUFFER 0x00000008
|
||||
#define GAMMA_ACCUM_BUFFER 0x00000010
|
||||
|
||||
#define GAMMA_MAX_TEXTURE_SIZE 2048
|
||||
|
||||
/* These are the minimum requirements and should probably be increased */
|
||||
#define MAX_MODELVIEW_STACK 16
|
||||
#define MAX_PROJECTION_STACK 2
|
||||
#define MAX_TEXTURE_STACK 2
|
||||
|
||||
extern void gammaDDUpdateHWState(GLcontext *ctx);
|
||||
extern gammaScreenPtr gammaCreateScreen(__DRIscreen *sPriv);
|
||||
extern void gammaDestroyScreen(__DRIscreen *sPriv);
|
||||
extern GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
|
||||
__DRIcontext *driContextPriv,
|
||||
void *sharedContextPrivate);
|
||||
|
||||
#define GAMMA_UPLOAD_ALL 0xffffffff
|
||||
#define GAMMA_UPLOAD_CLIPRECTS 0x00000002
|
||||
#define GAMMA_UPLOAD_ALPHA 0x00000004
|
||||
#define GAMMA_UPLOAD_BLEND 0x00000008
|
||||
#define GAMMA_UPLOAD_DEPTH 0x00000010
|
||||
#define GAMMA_UPLOAD_VIEWPORT 0x00000020
|
||||
#define GAMMA_UPLOAD_SHADE 0x00000040
|
||||
#define GAMMA_UPLOAD_CLIP 0x00000080
|
||||
#define GAMMA_UPLOAD_MASKS 0x00000100
|
||||
#define GAMMA_UPLOAD_WINDOW 0x00000200 /* defunct */
|
||||
#define GAMMA_UPLOAD_GEOMETRY 0x00000400
|
||||
#define GAMMA_UPLOAD_POLYGON 0x00000800
|
||||
#define GAMMA_UPLOAD_DITHER 0x00001000
|
||||
#define GAMMA_UPLOAD_LOGICOP 0x00002000
|
||||
#define GAMMA_UPLOAD_FOG 0x00004000
|
||||
#define GAMMA_UPLOAD_LIGHT 0x00008000
|
||||
#define GAMMA_UPLOAD_CONTEXT 0x00010000
|
||||
#define GAMMA_UPLOAD_TEX0 0x00020000
|
||||
#define GAMMA_UPLOAD_STIPPLE 0x00040000
|
||||
#define GAMMA_UPLOAD_TRANSFORM 0x00080000
|
||||
#define GAMMA_UPLOAD_LINEMODE 0x00100000
|
||||
#define GAMMA_UPLOAD_POINTMODE 0x00200000
|
||||
#define GAMMA_UPLOAD_TRIMODE 0x00400000
|
||||
|
||||
#define GAMMA_NEW_CLIP 0x00000001
|
||||
#define GAMMA_NEW_WINDOW 0x00000002
|
||||
#define GAMMA_NEW_CONTEXT 0x00000004
|
||||
#define GAMMA_NEW_TEXTURE 0x00000008 /* defunct */
|
||||
#define GAMMA_NEW_ALPHA 0x00000010
|
||||
#define GAMMA_NEW_DEPTH 0x00000020
|
||||
#define GAMMA_NEW_MASKS 0x00000040
|
||||
#define GAMMA_NEW_POLYGON 0x00000080
|
||||
#define GAMMA_NEW_CULL 0x00000100
|
||||
#define GAMMA_NEW_LOGICOP 0x00000200
|
||||
#define GAMMA_NEW_FOG 0x00000400
|
||||
#define GAMMA_NEW_LIGHT 0x00000800
|
||||
#define GAMMA_NEW_STIPPLE 0x00001000
|
||||
#define GAMMA_NEW_ALL 0xffffffff
|
||||
|
||||
#define GAMMA_FALLBACK_TRI 0x00000001
|
||||
#define GAMMA_FALLBACK_TEXTURE 0x00000002
|
||||
|
||||
#define FLUSH_BATCH(gmesa) do { \
|
||||
/*FLUSH_DMA_BUFFER(gmesa);*/ \
|
||||
} while(0)
|
||||
|
||||
struct gamma_context;
|
||||
typedef struct gamma_context gammaContextRec;
|
||||
typedef struct gamma_context *gammaContextPtr;
|
||||
typedef struct gamma_texture_object_t *gammaTextureObjectPtr;
|
||||
|
||||
#define VALID_GAMMA_TEXTURE_OBJECT(tobj) (tobj)
|
||||
|
||||
#define GAMMA_TEX_MAXLEVELS 12 /* 2K x 2K */
|
||||
|
||||
/* For shared texture space managment, these texture objects may also
|
||||
* be used as proxies for regions of texture memory containing other
|
||||
* client's textures. Such proxy textures (not to be confused with GL
|
||||
* proxy textures) are subject to the same LRU aging we use for our
|
||||
* own private textures, and thus we have a mechanism where we can
|
||||
* fairly decide between kicking out our own textures and those of
|
||||
* other clients.
|
||||
*
|
||||
* Non-local texture objects have a valid MemBlock to describe the
|
||||
* region managed by the other client, and can be identified by
|
||||
* 't->globj == 0'
|
||||
*/
|
||||
struct gamma_texture_object_t {
|
||||
struct gamma_texture_object_t *next, *prev;
|
||||
|
||||
GLuint age;
|
||||
struct gl_texture_object *globj;
|
||||
|
||||
int Pitch;
|
||||
int Height;
|
||||
int texelBytes;
|
||||
int totalSize;
|
||||
int bound;
|
||||
|
||||
struct mem_block *MemBlock;
|
||||
char * BufAddr;
|
||||
|
||||
GLuint min_level;
|
||||
GLuint max_level;
|
||||
GLuint dirty_images;
|
||||
|
||||
GLint firstLevel, lastLevel; /* upload tObj->Image[0][first .. lastLevel] */
|
||||
|
||||
struct {
|
||||
const struct gl_texture_image *image;
|
||||
int offset; /* into BufAddr */
|
||||
int height;
|
||||
int internalFormat;
|
||||
} image[GAMMA_TEX_MAXLEVELS];
|
||||
|
||||
uint32_t TextureBaseAddr[GAMMA_TEX_MAXLEVELS];
|
||||
uint32_t TextureAddressMode;
|
||||
uint32_t TextureColorMode;
|
||||
uint32_t TextureFilterMode;
|
||||
uint32_t TextureFormat;
|
||||
uint32_t TextureReadMode;
|
||||
uint32_t TextureBorderColor;
|
||||
};
|
||||
|
||||
#define GAMMA_NO_PALETTE 0x0
|
||||
#define GAMMA_USE_PALETTE 0x1
|
||||
#define GAMMA_UPDATE_PALETTE 0x2
|
||||
#define GAMMA_FALLBACK_PALETTE 0x4
|
||||
|
||||
void gammaUpdateTextureState( GLcontext *ctx );
|
||||
|
||||
void gammaDestroyTexObj( gammaContextPtr gmesa, gammaTextureObjectPtr t );
|
||||
void gammaSwapOutTexObj( gammaContextPtr gmesa, gammaTextureObjectPtr t );
|
||||
void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t );
|
||||
|
||||
void gammaResetGlobalLRU( gammaContextPtr gmesa );
|
||||
void gammaUpdateTexLRU( gammaContextPtr gmesa, gammaTextureObjectPtr t );
|
||||
void gammaTexturesGone( gammaContextPtr gmesa,
|
||||
GLuint start, GLuint end,
|
||||
GLuint in_use );
|
||||
|
||||
void gammaEmitHwState( gammaContextPtr gmesa );
|
||||
void gammaDDInitExtensions( GLcontext *ctx );
|
||||
void gammaDDInitDriverFuncs( GLcontext *ctx );
|
||||
void gammaDDInitSpanFuncs( GLcontext *ctx );
|
||||
void gammaDDInitState( gammaContextPtr gmesa );
|
||||
void gammaInitHW( gammaContextPtr gmesa );
|
||||
void gammaDDInitStateFuncs( GLcontext *ctx );
|
||||
void gammaDDInitTextureFuncs( struct dd_function_table *table );
|
||||
void gammaInitTextureObjects( GLcontext *ctx );
|
||||
void gammaDDInitTriFuncs( GLcontext *ctx );
|
||||
|
||||
void gammaUpdateWindow( GLcontext *ctx );
|
||||
void gammaUpdateViewportOffset( GLcontext *ctx );
|
||||
|
||||
void gammaPrintLocalLRU( gammaContextPtr gmesa );
|
||||
void gammaPrintGlobalLRU( gammaContextPtr gmesa );
|
||||
|
||||
extern void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode );
|
||||
#define FALLBACK( imesa, bit, mode ) gammaFallback( imesa, bit, mode )
|
||||
|
||||
/* Use the templated vertex formats. Only one of these is used in gamma.
|
||||
*/
|
||||
#define TAG(x) gamma##x
|
||||
#include "tnl_dd/t_dd_vertex.h"
|
||||
#undef TAG
|
||||
|
||||
typedef void (*gamma_quad_func)( gammaContextPtr,
|
||||
const gammaVertex *,
|
||||
const gammaVertex *,
|
||||
const gammaVertex *,
|
||||
const gammaVertex * );
|
||||
typedef void (*gamma_tri_func)( gammaContextPtr,
|
||||
const gammaVertex *,
|
||||
const gammaVertex *,
|
||||
const gammaVertex * );
|
||||
typedef void (*gamma_line_func)( gammaContextPtr,
|
||||
const gammaVertex *,
|
||||
const gammaVertex * );
|
||||
typedef void (*gamma_point_func)( gammaContextPtr,
|
||||
const gammaVertex * );
|
||||
|
||||
|
||||
struct gamma_context {
|
||||
GLcontext *glCtx; /* Mesa context */
|
||||
|
||||
__DRIcontext *driContext;
|
||||
__DRIscreen *driScreen;
|
||||
__DRIdrawable *driDrawable;
|
||||
|
||||
GLuint new_gl_state;
|
||||
GLuint new_state;
|
||||
GLuint dirty;
|
||||
|
||||
GLINTSAREADRIPtr sarea;
|
||||
|
||||
/* Mirrors of some DRI state
|
||||
*/
|
||||
drm_context_t hHWContext;
|
||||
drm_hw_lock_t *driHwLock;
|
||||
int driFd;
|
||||
|
||||
GLuint numClipRects; /* Cliprects for the draw buffer */
|
||||
drm_clip_rect_t *pClipRects;
|
||||
|
||||
dmaBuf buf; /* DMA buffer for regular cmds */
|
||||
int bufIndex;
|
||||
int bufSize;
|
||||
int bufCount;
|
||||
|
||||
dmaBuf WCbuf; /* DMA buffer for window changed cmds */
|
||||
int WCbufIndex;
|
||||
int WCbufSize;
|
||||
int WCbufCount;
|
||||
|
||||
gammaScreenPtr gammaScreen; /* Screen private DRI data */
|
||||
|
||||
int drawOffset;
|
||||
int readOffset;
|
||||
|
||||
gamma_point_func draw_point;
|
||||
gamma_line_func draw_line;
|
||||
gamma_tri_func draw_tri;
|
||||
gamma_quad_func draw_quad;
|
||||
|
||||
GLuint Fallback;
|
||||
GLuint RenderIndex;
|
||||
GLuint SetupNewInputs;
|
||||
GLuint SetupIndex;
|
||||
|
||||
GLuint vertex_format;
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_stride_shift;
|
||||
GLubyte *verts;
|
||||
|
||||
GLfloat hw_viewport[16];
|
||||
GLuint hw_primitive;
|
||||
GLenum render_primitive;
|
||||
|
||||
GLfloat depth_scale;
|
||||
|
||||
gammaTextureObjectPtr CurrentTexObj[2];
|
||||
struct gamma_texture_object_t TexObjList;
|
||||
struct gamma_texture_object_t SwappedOut;
|
||||
GLenum TexEnvImageFmt[2];
|
||||
|
||||
struct mem_block *texHeap;
|
||||
|
||||
unsigned int lastSwap;
|
||||
int texAge;
|
||||
int ctxAge;
|
||||
int dirtyAge;
|
||||
unsigned int lastStamp;
|
||||
|
||||
|
||||
uint32_t ClearColor;
|
||||
uint32_t Color;
|
||||
uint32_t DitherMode;
|
||||
uint32_t ClearDepth;
|
||||
uint32_t FogMode;
|
||||
uint32_t AreaStippleMode;
|
||||
uint32_t LBReadFormat;
|
||||
uint32_t LBWriteFormat;
|
||||
uint32_t LineMode;
|
||||
uint32_t PointMode;
|
||||
uint32_t TriangleMode;
|
||||
uint32_t AntialiasMode;
|
||||
GLfloat ViewportScaleX;
|
||||
GLfloat ViewportScaleY;
|
||||
GLfloat ViewportScaleZ;
|
||||
GLfloat ViewportOffsetX;
|
||||
GLfloat ViewportOffsetY;
|
||||
GLfloat ViewportOffsetZ;
|
||||
int MatrixMode;
|
||||
int DepthMode;
|
||||
int TransformMode;
|
||||
int LBReadMode;
|
||||
int FBReadMode;
|
||||
int FBWindowBase;
|
||||
int LBWindowBase;
|
||||
int ColorDDAMode;
|
||||
int GeometryMode;
|
||||
int AlphaTestMode;
|
||||
int AlphaBlendMode;
|
||||
int AB_FBReadMode;
|
||||
int AB_FBReadMode_Save;
|
||||
int DeltaMode;
|
||||
int ColorMaterialMode;
|
||||
int FBHardwareWriteMask;
|
||||
int MaterialMode;
|
||||
int NormalizeMode;
|
||||
int LightingMode;
|
||||
int Light0Mode;
|
||||
int Light1Mode;
|
||||
int Light2Mode;
|
||||
int Light3Mode;
|
||||
int Light4Mode;
|
||||
int Light5Mode;
|
||||
int Light6Mode;
|
||||
int Light7Mode;
|
||||
int Light8Mode;
|
||||
int Light9Mode;
|
||||
int Light10Mode;
|
||||
int Light11Mode;
|
||||
int Light12Mode;
|
||||
int Light13Mode;
|
||||
int Light14Mode;
|
||||
int Light15Mode;
|
||||
int LogicalOpMode;
|
||||
int ScissorMode;
|
||||
int ScissorMaxXY;
|
||||
int ScissorMinXY;
|
||||
int Window; /* GID part probably should be in draw priv */
|
||||
int WindowOrigin;
|
||||
int x, y, w, h; /* Probably should be in drawable priv */
|
||||
int FrameCount; /* Probably should be in drawable priv */
|
||||
int NotClipped; /* Probably should be in drawable priv */
|
||||
int WindowChanged; /* Probably should be in drawabl... */
|
||||
int Flags;
|
||||
int EnabledFlags;
|
||||
int DepthSize;
|
||||
int Begin;
|
||||
GLenum ErrorValue;
|
||||
int Texture1DEnabled;
|
||||
int Texture2DEnabled;
|
||||
|
||||
float ModelView[16];
|
||||
float Proj[16];
|
||||
float ModelViewProj[16];
|
||||
float Texture[16];
|
||||
|
||||
float ModelViewStack[(MAX_MODELVIEW_STACK-1)*16];
|
||||
int ModelViewCount;
|
||||
float ProjStack[(MAX_PROJECTION_STACK-1)*16];
|
||||
int ProjCount;
|
||||
float TextureStack[(MAX_TEXTURE_STACK-1)*16];
|
||||
int TextureCount;
|
||||
};
|
||||
|
||||
static INLINE GLuint gammaPackColor( GLuint cpp,
|
||||
GLubyte r, GLubyte g,
|
||||
GLubyte b, GLubyte a )
|
||||
{
|
||||
switch ( cpp ) {
|
||||
case 2:
|
||||
return PACK_COLOR_565( r, g, b );
|
||||
case 4:
|
||||
return PACK_COLOR_8888( a, r, g, b );
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define GAMMA_CONTEXT(ctx) ((gammaContextPtr)(ctx->DriverCtx))
|
||||
|
||||
#endif /* _GAMMA_CONTEXT_H_ */
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "gamma_lock.h"
|
||||
#include "gamma_macros.h"
|
||||
#if defined(USE_X86_ASM)
|
||||
#include "x86/common_x86_asm.h"
|
||||
#endif
|
||||
|
||||
#include "main/context.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define GAMMA_DATE "20021125"
|
||||
|
||||
|
||||
/* Return the width and height of the current color buffer.
|
||||
*/
|
||||
static void gammaDDGetBufferSize( GLframebuffer *buffer,
|
||||
GLuint *width, GLuint *height )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
|
||||
GAMMAHW_LOCK( gmesa );
|
||||
*width = gmesa->driDrawable->w;
|
||||
*height = gmesa->driDrawable->h;
|
||||
GAMMAHW_UNLOCK( gmesa );
|
||||
}
|
||||
|
||||
|
||||
/* Return various strings for glGetString().
|
||||
*/
|
||||
static const GLubyte *gammaDDGetString( GLcontext *ctx, GLenum name )
|
||||
{
|
||||
static char buffer[128];
|
||||
|
||||
switch ( name ) {
|
||||
case GL_VENDOR:
|
||||
return (GLubyte *)"VA Linux Systems, Inc.";
|
||||
|
||||
case GL_RENDERER:
|
||||
sprintf( buffer, "Mesa DRI Gamma " GAMMA_DATE );
|
||||
|
||||
/* Append any CPU-specific information.
|
||||
*/
|
||||
#ifdef USE_X86_ASM
|
||||
if ( _mesa_x86_cpu_features ) {
|
||||
strncat( buffer, " x86", 4 );
|
||||
}
|
||||
#ifdef USE_MMX_ASM
|
||||
if ( cpu_has_mmx ) {
|
||||
strncat( buffer, "/MMX", 4 );
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_3DNOW_ASM
|
||||
if ( cpu_has_3dnow ) {
|
||||
strncat( buffer, "/3DNow!", 7 );
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_SSE_ASM
|
||||
if ( cpu_has_xmm ) {
|
||||
strncat( buffer, "/SSE", 4 );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return (GLubyte *)buffer;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable the extensions supported by this driver.
|
||||
*/
|
||||
void gammaDDInitExtensions( GLcontext *ctx )
|
||||
{
|
||||
/* None... */
|
||||
}
|
||||
|
||||
/* Initialize the driver's misc functions.
|
||||
*/
|
||||
void gammaDDInitDriverFuncs( GLcontext *ctx )
|
||||
{
|
||||
ctx->Driver.GetBufferSize = gammaDDGetBufferSize;
|
||||
ctx->Driver.GetString = gammaDDGetString;
|
||||
}
|
||||
@@ -1,551 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
* Kevin E. Martin <martin@valinux.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_macros.h"
|
||||
#include "glint_dri.h"
|
||||
|
||||
void gammaInitHW( gammaContextPtr gmesa )
|
||||
{
|
||||
GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gmesa->driScreen->pDevPriv;
|
||||
int i;
|
||||
|
||||
if (gDRIPriv->numMultiDevices == 2) {
|
||||
/* Set up each MX's ScanLineOwnership for OpenGL */
|
||||
CHECK_DMA_BUFFER(gmesa, 5);
|
||||
WRITE(gmesa->buf, BroadcastMask, 1);
|
||||
WRITE(gmesa->buf, ScanLineOwnership, 5); /* Use bottom left as [0,0] */
|
||||
WRITE(gmesa->buf, BroadcastMask, 2);
|
||||
WRITE(gmesa->buf, ScanLineOwnership, 1); /* Use bottom left as [0,0] */
|
||||
/* Broadcast to both MX's */
|
||||
WRITE(gmesa->buf, BroadcastMask, 3);
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
|
||||
gmesa->AlphaBlendMode = (AlphaBlendModeDisable |
|
||||
AB_Src_One |
|
||||
AB_Dst_Zero |
|
||||
AB_NoAlphaBufferPresent |
|
||||
AB_ColorFmt_8888 |
|
||||
AB_ColorOrder_RGB |
|
||||
AB_OpenGLType |
|
||||
AB_AlphaDst_FBData |
|
||||
AB_ColorConversionScale |
|
||||
AB_AlphaConversionScale);
|
||||
|
||||
gmesa->DitherMode = DitherModeEnable | DM_ColorOrder_RGB;
|
||||
|
||||
switch (gmesa->gammaScreen->cpp) {
|
||||
case 2:
|
||||
gmesa->DitherMode |= DM_ColorFmt_5555;
|
||||
gmesa->AlphaBlendMode |= AB_ColorFmt_5555;
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PixelSize, 1);
|
||||
break;
|
||||
case 4:
|
||||
gmesa->DitherMode |= DM_ColorFmt_8888;
|
||||
gmesa->AlphaBlendMode |= AB_ColorFmt_8888;
|
||||
WRITE(gmesa->buf, PixelSize, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* FIXME for stencil, gid, etc */
|
||||
switch (gmesa->DepthSize) {
|
||||
case 16:
|
||||
gmesa->LBReadFormat =
|
||||
(LBRF_DepthWidth16 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos16 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos24 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos32 );
|
||||
gmesa->LBWriteFormat =
|
||||
(LBRF_DepthWidth16 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos16 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos24 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos32 );
|
||||
break;
|
||||
case 24:
|
||||
gmesa->LBReadFormat =
|
||||
(LBRF_DepthWidth24 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos24 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos32 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos36 );
|
||||
gmesa->LBWriteFormat =
|
||||
(LBRF_DepthWidth24 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos24 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos32 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos36 );
|
||||
break;
|
||||
case 32:
|
||||
gmesa->LBReadFormat =
|
||||
(LBRF_DepthWidth32 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos32 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos40 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos44 );
|
||||
gmesa->LBWriteFormat =
|
||||
(LBRF_DepthWidth32 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos32 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos40 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos44 );
|
||||
break;
|
||||
}
|
||||
|
||||
gmesa->FBHardwareWriteMask = 0xffffffff;
|
||||
gmesa->FogMode = FogModeDisable;
|
||||
gmesa->ClearDepth = 0xffffffff;
|
||||
gmesa->AreaStippleMode = AreaStippleModeDisable;
|
||||
gmesa->x = 0;
|
||||
gmesa->y = 0;
|
||||
gmesa->w = 0;
|
||||
gmesa->h = 0;
|
||||
gmesa->FrameCount = 0;
|
||||
gmesa->MatrixMode = GL_MODELVIEW;
|
||||
gmesa->ModelViewCount = 0;
|
||||
gmesa->ProjCount = 0;
|
||||
gmesa->TextureCount = 0;
|
||||
gmesa->PointMode = PM_AntialiasQuality_4x4;
|
||||
gmesa->LineMode = LM_AntialiasQuality_4x4;
|
||||
gmesa->TriangleMode = TM_AntialiasQuality_4x4;
|
||||
gmesa->AntialiasMode = AntialiasModeDisable;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
if (i % 5 == 0)
|
||||
gmesa->ModelView[i] =
|
||||
gmesa->Proj[i] =
|
||||
gmesa->ModelViewProj[i] =
|
||||
gmesa->Texture[i] = 1.0;
|
||||
else
|
||||
gmesa->ModelView[i] =
|
||||
gmesa->Proj[i] =
|
||||
gmesa->ModelViewProj[i] =
|
||||
gmesa->Texture[i] = 0.0;
|
||||
|
||||
gmesa->LBReadMode = (LBReadSrcDisable |
|
||||
LBReadDstDisable |
|
||||
LBDataTypeDefault |
|
||||
LBWindowOriginBot |
|
||||
gDRIPriv->pprod);
|
||||
gmesa->FBReadMode = (FBReadSrcDisable |
|
||||
FBReadDstDisable |
|
||||
FBDataTypeDefault |
|
||||
FBWindowOriginBot |
|
||||
gDRIPriv->pprod);
|
||||
|
||||
if (gDRIPriv->numMultiDevices == 2) {
|
||||
gmesa->LBReadMode |= LBScanLineInt2;
|
||||
gmesa->FBReadMode |= FBScanLineInt2;
|
||||
gmesa->LBWindowBase = gmesa->driScreen->fbWidth *
|
||||
(gmesa->driScreen->fbHeight/2 - 1);
|
||||
gmesa->FBWindowBase = gmesa->driScreen->fbWidth *
|
||||
(gmesa->driScreen->fbHeight/2 - 1);
|
||||
} else {
|
||||
gmesa->LBWindowBase = gmesa->driScreen->fbWidth *
|
||||
(gmesa->driScreen->fbHeight - 1);
|
||||
gmesa->FBWindowBase = gmesa->driScreen->fbWidth *
|
||||
(gmesa->driScreen->fbHeight - 1);
|
||||
}
|
||||
|
||||
gmesa->Begin = (B_AreaStippleDisable |
|
||||
B_LineStippleDisable |
|
||||
B_AntiAliasDisable |
|
||||
B_TextureDisable |
|
||||
B_FogDisable |
|
||||
B_SubPixelCorrectEnable |
|
||||
B_PrimType_Null);
|
||||
|
||||
gmesa->ColorDDAMode = (ColorDDAEnable |
|
||||
ColorDDAGouraud);
|
||||
|
||||
gmesa->GeometryMode = (GM_TextureDisable |
|
||||
GM_FogDisable |
|
||||
GM_FogExp |
|
||||
GM_FrontPolyFill |
|
||||
GM_BackPolyFill |
|
||||
GM_FrontFaceCCW |
|
||||
GM_PolyCullDisable |
|
||||
GM_PolyCullBack |
|
||||
GM_ClipShortLinesDisable |
|
||||
GM_ClipSmallTrisDisable |
|
||||
GM_RenderMode |
|
||||
GM_Feedback2D |
|
||||
GM_CullFaceNormDisable |
|
||||
GM_AutoFaceNormDisable |
|
||||
GM_GouraudShading |
|
||||
GM_UserClipNone |
|
||||
GM_PolyOffsetPointDisable |
|
||||
GM_PolyOffsetLineDisable |
|
||||
GM_PolyOffsetFillDisable |
|
||||
GM_InvertFaceNormCullDisable);
|
||||
|
||||
gmesa->AlphaTestMode = (AlphaTestModeDisable |
|
||||
AT_Always);
|
||||
|
||||
gmesa->AB_FBReadMode_Save = gmesa->AB_FBReadMode = 0;
|
||||
|
||||
gmesa->Window = (WindowEnable | /* For GID testing */
|
||||
W_PassIfEqual |
|
||||
(0 << 5)); /* GID part is set from draw priv (below) */
|
||||
|
||||
gmesa->NotClipped = GL_FALSE;
|
||||
gmesa->WindowChanged = GL_TRUE;
|
||||
|
||||
gmesa->Texture1DEnabled = GL_FALSE;
|
||||
gmesa->Texture2DEnabled = GL_FALSE;
|
||||
|
||||
gmesa->DepthMode |= (DepthModeDisable |
|
||||
DM_WriteMask |
|
||||
DM_Less);
|
||||
|
||||
gmesa->DeltaMode |= (DM_SubPixlCorrectionEnable |
|
||||
DM_SmoothShadingEnable |
|
||||
DM_Target500TXMX);
|
||||
|
||||
gmesa->LightingMode = LightingModeDisable | LightingModeSpecularEnable;
|
||||
gmesa->Light0Mode = LNM_Off;
|
||||
gmesa->Light1Mode = LNM_Off;
|
||||
gmesa->Light2Mode = LNM_Off;
|
||||
gmesa->Light3Mode = LNM_Off;
|
||||
gmesa->Light4Mode = LNM_Off;
|
||||
gmesa->Light5Mode = LNM_Off;
|
||||
gmesa->Light6Mode = LNM_Off;
|
||||
gmesa->Light7Mode = LNM_Off;
|
||||
gmesa->Light8Mode = LNM_Off;
|
||||
gmesa->Light9Mode = LNM_Off;
|
||||
gmesa->Light10Mode = LNM_Off;
|
||||
gmesa->Light11Mode = LNM_Off;
|
||||
gmesa->Light12Mode = LNM_Off;
|
||||
gmesa->Light13Mode = LNM_Off;
|
||||
gmesa->Light14Mode = LNM_Off;
|
||||
gmesa->Light15Mode = LNM_Off;
|
||||
|
||||
gmesa->LogicalOpMode = LogicalOpModeDisable;
|
||||
|
||||
gmesa->MaterialMode = MaterialModeDisable;
|
||||
|
||||
gmesa->ScissorMode = UserScissorDisable | ScreenScissorDisable;
|
||||
|
||||
gmesa->TransformMode = XM_UseModelViewProjMatrix |
|
||||
XM_TexGenModeS_None |
|
||||
XM_TexGenModeT_None |
|
||||
XM_TexGenModeR_None |
|
||||
XM_TexGenModeQ_None;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 20);
|
||||
WRITE(gmesa->buf, LineStippleMode, 0);
|
||||
WRITE(gmesa->buf, RouterMode, 0);
|
||||
WRITE(gmesa->buf, TextureAddressMode, 0);
|
||||
WRITE(gmesa->buf, TextureReadMode, 0);
|
||||
WRITE(gmesa->buf, TextureFilterMode, 0);
|
||||
WRITE(gmesa->buf, TextureColorMode, 0);
|
||||
WRITE(gmesa->buf, StencilMode, 0);
|
||||
WRITE(gmesa->buf, PatternRamMode, 0);
|
||||
WRITE(gmesa->buf, ChromaTestMode, 0);
|
||||
WRITE(gmesa->buf, StatisticMode, 0);
|
||||
WRITE(gmesa->buf, AreaStippleMode, gmesa->AreaStippleMode);
|
||||
WRITE(gmesa->buf, ScissorMode, gmesa->ScissorMode);
|
||||
WRITE(gmesa->buf, FogMode, gmesa->FogMode);
|
||||
WRITE(gmesa->buf, AntialiasMode, gmesa->AntialiasMode);
|
||||
WRITE(gmesa->buf, LogicalOpMode, gmesa->LogicalOpMode);
|
||||
WRITE(gmesa->buf, TriangleMode, gmesa->TriangleMode);
|
||||
WRITE(gmesa->buf, PointMode, gmesa->PointMode);
|
||||
WRITE(gmesa->buf, LineMode, gmesa->LineMode);
|
||||
WRITE(gmesa->buf, LBWriteFormat, gmesa->LBWriteFormat);
|
||||
WRITE(gmesa->buf, LBReadFormat, gmesa->LBReadFormat);
|
||||
|
||||
/* Framebuffer initialization */
|
||||
CHECK_DMA_BUFFER(gmesa, 10);
|
||||
WRITE(gmesa->buf, FBSourceData, 0);
|
||||
WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
|
||||
if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) {
|
||||
if (gDRIPriv->numMultiDevices == 2) {
|
||||
WRITE(gmesa->buf, FBPixelOffset,
|
||||
(gmesa->driScreen->fbHeight/2)*gmesa->driScreen->fbWidth);
|
||||
} else {
|
||||
WRITE(gmesa->buf, FBPixelOffset,
|
||||
gmesa->driScreen->fbHeight*gmesa->driScreen->fbWidth);
|
||||
}
|
||||
} else
|
||||
WRITE(gmesa->buf, FBPixelOffset, 0);
|
||||
WRITE(gmesa->buf, FBSourceOffset, 0);
|
||||
WRITE(gmesa->buf, FBHardwareWriteMask, 0xffffffff);
|
||||
WRITE(gmesa->buf, FBSoftwareWriteMask, 0xffffffff);
|
||||
WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
|
||||
WRITE(gmesa->buf, FBWindowBase, gmesa->FBWindowBase);
|
||||
WRITE(gmesa->buf, ScreenSize, ((gmesa->driScreen->fbHeight << 16) |
|
||||
(gmesa->driScreen->fbWidth)));
|
||||
WRITE(gmesa->buf, WindowOrigin, 0x00000000);
|
||||
|
||||
/* Localbuffer initialization */
|
||||
CHECK_DMA_BUFFER(gmesa, 5);
|
||||
WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
|
||||
WRITE(gmesa->buf, LBSourceOffset, 0);
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
|
||||
WRITE(gmesa->buf, LBWindowOffset, 0);
|
||||
WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Rectangle2DControl, 1);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 11);
|
||||
WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
|
||||
WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
|
||||
WRITE(gmesa->buf, FBBlockColor, 0x00000000);
|
||||
WRITE(gmesa->buf, ConstantColor, 0x00000000);
|
||||
WRITE(gmesa->buf, AlphaTestMode, gmesa->AlphaTestMode);
|
||||
WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode);
|
||||
WRITE(gmesa->buf, DitherMode, gmesa->DitherMode);
|
||||
if (gDRIPriv->numMultiDevices == 2)
|
||||
WRITE(gmesa->buf, RasterizerMode, RM_MultiGLINT | RM_BiasCoordNearHalf);
|
||||
else
|
||||
WRITE(gmesa->buf, RasterizerMode, RM_BiasCoordNearHalf);
|
||||
WRITE(gmesa->buf, GLINTWindow, gmesa->Window);
|
||||
WRITE(gmesa->buf, FastClearDepth, gmesa->ClearDepth);
|
||||
WRITE(gmesa->buf, GLINTDepth, gmesa->ClearDepth);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, EdgeFlag, EdgeFlagEnable);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix0, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix1, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix2, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix3, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix4, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix5, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix6, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix7, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix8, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix9, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix10, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix11, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix12, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix13, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix14, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix15, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix0, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix1, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix2, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix3, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix4, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix5, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix6, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix7, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix8, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix9, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix10, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix11, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix12, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix13, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix14, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix15, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITEF(gmesa->buf, TextureMatrix0, 1.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix1, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix2, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix3, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix4, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix5, 1.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix6, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix7, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix8, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix9, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix10, 1.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix11, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix12, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix13, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix14, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix15, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITEF(gmesa->buf, TexGen0, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen1, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen2, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen3, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen4, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen5, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen6, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen7, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen8, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen9, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen10, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen11, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen12, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen13, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen14, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen15, 0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 9);
|
||||
WRITEF(gmesa->buf, NormalMatrix0, 1.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix1, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix2, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix3, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix4, 1.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix5, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix6, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix7, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix8, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 3);
|
||||
WRITEF(gmesa->buf, FogDensity, 0.0);
|
||||
WRITEF(gmesa->buf, FogEnd, 0.0);
|
||||
WRITEF(gmesa->buf, FogScale, 0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITEF(gmesa->buf, LineClipLengthThreshold, 0.0);
|
||||
WRITEF(gmesa->buf, TriangleClipAreaThreshold, 0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 5);
|
||||
WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);
|
||||
WRITE(gmesa->buf, NormalizeMode, NormalizeModeDisable);
|
||||
WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
|
||||
WRITE(gmesa->buf, ColorMaterialMode, ColorMaterialModeDisable);
|
||||
WRITE(gmesa->buf, MaterialMode, MaterialModeDisable);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITE(gmesa->buf, FrontSpecularExponent, 0); /* fixed point */
|
||||
WRITE(gmesa->buf, BackSpecularExponent, 0); /* fixed point */
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 29);
|
||||
WRITEF(gmesa->buf, FrontAmbientColorRed, 0.2);
|
||||
WRITEF(gmesa->buf, FrontAmbientColorGreen, 0.2);
|
||||
WRITEF(gmesa->buf, FrontAmbientColorBlue, 0.2);
|
||||
WRITEF(gmesa->buf, BackAmbientColorRed, 0.2);
|
||||
WRITEF(gmesa->buf, BackAmbientColorGreen, 0.2);
|
||||
WRITEF(gmesa->buf, BackAmbientColorBlue, 0.2);
|
||||
WRITEF(gmesa->buf, FrontDiffuseColorRed, 0.8);
|
||||
WRITEF(gmesa->buf, FrontDiffuseColorGreen, 0.8);
|
||||
WRITEF(gmesa->buf, FrontDiffuseColorBlue, 0.8);
|
||||
WRITEF(gmesa->buf, BackDiffuseColorRed, 0.8);
|
||||
WRITEF(gmesa->buf, BackDiffuseColorGreen, 0.8);
|
||||
WRITEF(gmesa->buf, BackDiffuseColorBlue, 0.8);
|
||||
WRITEF(gmesa->buf, FrontSpecularColorRed, 0.0);
|
||||
WRITEF(gmesa->buf, FrontSpecularColorGreen, 0.0);
|
||||
WRITEF(gmesa->buf, FrontSpecularColorBlue, 0.0);
|
||||
WRITEF(gmesa->buf, BackSpecularColorRed, 0.0);
|
||||
WRITEF(gmesa->buf, BackSpecularColorGreen, 0.0);
|
||||
WRITEF(gmesa->buf, BackSpecularColorBlue, 0.0);
|
||||
WRITEF(gmesa->buf, FrontEmissiveColorRed, 0.0);
|
||||
WRITEF(gmesa->buf, FrontEmissiveColorGreen, 0.0);
|
||||
WRITEF(gmesa->buf, FrontEmissiveColorBlue, 0.0);
|
||||
WRITEF(gmesa->buf, BackEmissiveColorRed, 0.0);
|
||||
WRITEF(gmesa->buf, BackEmissiveColorGreen, 0.0);
|
||||
WRITEF(gmesa->buf, BackEmissiveColorBlue, 0.0);
|
||||
WRITEF(gmesa->buf, SceneAmbientColorRed, 0.2);
|
||||
WRITEF(gmesa->buf, SceneAmbientColorGreen, 0.2);
|
||||
WRITEF(gmesa->buf, SceneAmbientColorBlue, 0.2);
|
||||
WRITEF(gmesa->buf, FrontAlpha, 1.0);
|
||||
WRITEF(gmesa->buf, BackAlpha, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 7);
|
||||
WRITE(gmesa->buf, PointSize, 1);
|
||||
WRITEF(gmesa->buf, AApointSize, 1.0);
|
||||
WRITE(gmesa->buf, LineWidth, 1);
|
||||
WRITEF(gmesa->buf, AAlineWidth, 1.0);
|
||||
WRITE(gmesa->buf, LineWidthOffset, 0);
|
||||
WRITE(gmesa->buf, TransformMode, gmesa->TransformMode);
|
||||
WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITE(gmesa->buf, Light0Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light1Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light2Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light3Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light4Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light5Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light6Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light7Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light8Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light9Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light10Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light11Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light12Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light13Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light14Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light15Mode, LNM_Off);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 22);
|
||||
WRITEF(gmesa->buf, Light0AmbientIntensityBlue, 0.0);
|
||||
WRITEF(gmesa->buf, Light0AmbientIntensityGreen, 0.0);
|
||||
WRITEF(gmesa->buf, Light0AmbientIntensityRed, 0.0);
|
||||
WRITEF(gmesa->buf, Light0DiffuseIntensityBlue, 1.0);
|
||||
WRITEF(gmesa->buf, Light0DiffuseIntensityGreen, 1.0);
|
||||
WRITEF(gmesa->buf, Light0DiffuseIntensityRed, 1.0);
|
||||
WRITEF(gmesa->buf, Light0SpecularIntensityBlue, 1.0);
|
||||
WRITEF(gmesa->buf, Light0SpecularIntensityGreen, 1.0);
|
||||
WRITEF(gmesa->buf, Light0SpecularIntensityRed, 1.0);
|
||||
WRITEF(gmesa->buf, Light0SpotlightDirectionZ, 0.0);
|
||||
WRITEF(gmesa->buf, Light0SpotlightDirectionY, 0.0);
|
||||
WRITEF(gmesa->buf, Light0SpotlightDirectionX, -1.0);
|
||||
WRITEF(gmesa->buf, Light0SpotlightExponent, 0.0);
|
||||
WRITEF(gmesa->buf, Light0PositionZ, 0.0);
|
||||
WRITEF(gmesa->buf, Light0PositionY, 0.0);
|
||||
WRITEF(gmesa->buf, Light0PositionX, 1.0);
|
||||
WRITEF(gmesa->buf, Light0PositionW, 0.0);
|
||||
WRITEF(gmesa->buf, Light0CosSpotlightCutoffAngle, -1.0);
|
||||
WRITEF(gmesa->buf, Light0ConstantAttenuation, 1.0);
|
||||
WRITEF(gmesa->buf, Light0LinearAttenuation, 0.0);
|
||||
WRITEF(gmesa->buf, Light0QuadraticAttenuation,0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITEF(gmesa->buf, XBias, 0.0);
|
||||
WRITEF(gmesa->buf, YBias, 0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, ViewPortScaleX, gmesa->driScreen->fbWidth/4);
|
||||
WRITEF(gmesa->buf, ViewPortScaleY, gmesa->driScreen->fbHeight/4);
|
||||
WRITEF(gmesa->buf, ViewPortScaleZ, 1.0f);
|
||||
WRITEF(gmesa->buf, ViewPortOffsetX, gmesa->x);
|
||||
WRITEF(gmesa->buf, ViewPortOffsetY, gmesa->y);
|
||||
WRITEF(gmesa->buf, ViewPortOffsetZ, 0.0f);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 3);
|
||||
WRITEF(gmesa->buf, Nz, 1.0);
|
||||
WRITEF(gmesa->buf, Ny, 0.0);
|
||||
WRITEF(gmesa->buf, Nx, 0.0);
|
||||
|
||||
/* Send the initialization commands to the HW */
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_lock.h"
|
||||
#include "drirenderbuffer.h"
|
||||
|
||||
#ifdef DEBUG_LOCKING
|
||||
char *prevLockFile = NULL;
|
||||
int prevLockLine = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/* Update the hardware state. This is called if another context has
|
||||
* grabbed the hardware lock, which includes the X server. This
|
||||
* function also updates the driver's window state after the X server
|
||||
* moves, resizes or restacks a window -- the change will be reflected
|
||||
* in the drawable position and clip rects. Since the X server grabs
|
||||
* the hardware lock when it changes the window state, this routine will
|
||||
* automatically be called after such a change.
|
||||
*/
|
||||
void gammaGetLock( gammaContextPtr gmesa, GLuint flags )
|
||||
{
|
||||
__DRIdrawable *dPriv = gmesa->driDrawable;
|
||||
__DRIscreen *sPriv = gmesa->driScreen;
|
||||
|
||||
drmGetLock( gmesa->driFd, gmesa->hHWContext, flags );
|
||||
|
||||
/* The window might have moved, so we might need to get new clip
|
||||
* rects.
|
||||
*
|
||||
* NOTE: This releases and regrabs the hw lock to allow the X server
|
||||
* to respond to the DRI protocol request for new drawable info.
|
||||
* Since the hardware state depends on having the latest drawable
|
||||
* clip rects, all state checking must be done _after_ this call.
|
||||
*/
|
||||
DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
|
||||
|
||||
if ( gmesa->lastStamp != dPriv->lastStamp ) {
|
||||
driUpdateFramebufferSize(gmesa->glCtx, dPriv);
|
||||
gmesa->lastStamp = dPriv->lastStamp;
|
||||
gmesa->new_state |= GAMMA_NEW_WINDOW | GAMMA_NEW_CLIP;
|
||||
}
|
||||
|
||||
gmesa->numClipRects = dPriv->numClipRects;
|
||||
gmesa->pClipRects = dPriv->pClipRects;
|
||||
|
||||
#if 0
|
||||
gmesa->dirty = ~0;
|
||||
|
||||
if ( sarea->ctxOwner != gmesa->hHWContext ) {
|
||||
sarea->ctxOwner = gmesa->hHWContext;
|
||||
gmesa->dirty = GAMMA_UPLOAD_ALL;
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < gmesa->lastTexHeap ; i++ ) {
|
||||
if ( sarea->texAge[i] != gmesa->lastTexAge[i] ) {
|
||||
gammaAgeTextures( gmesa, i );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
#ifndef __GAMMA_LOCK_H__
|
||||
#define __GAMMA_LOCK_H__
|
||||
|
||||
extern void gammaGetLock( gammaContextPtr gmesa, GLuint flags );
|
||||
|
||||
/* Turn DEBUG_LOCKING on to find locking conflicts.
|
||||
*/
|
||||
#define DEBUG_LOCKING 0
|
||||
|
||||
#if DEBUG_LOCKING
|
||||
extern char *prevLockFile;
|
||||
extern int prevLockLine;
|
||||
|
||||
#define DEBUG_LOCK() \
|
||||
do { \
|
||||
prevLockFile = (__FILE__); \
|
||||
prevLockLine = (__LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_RESET() \
|
||||
do { \
|
||||
prevLockFile = 0; \
|
||||
prevLockLine = 0; \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_CHECK_LOCK() \
|
||||
do { \
|
||||
if ( prevLockFile ) { \
|
||||
fprintf( stderr, \
|
||||
"LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
|
||||
prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
|
||||
exit( 1 ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define DEBUG_LOCK()
|
||||
#define DEBUG_RESET()
|
||||
#define DEBUG_CHECK_LOCK()
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* !!! We may want to separate locks from locks with validation. This
|
||||
* could be used to improve performance for those things commands that
|
||||
* do not do any drawing !!!
|
||||
*/
|
||||
|
||||
/* Lock the hardware and validate our state.
|
||||
*/
|
||||
#define LOCK_HARDWARE( gmesa ) \
|
||||
do { \
|
||||
char __ret = 0; \
|
||||
DEBUG_CHECK_LOCK(); \
|
||||
DRM_CAS( gmesa->driHwLock, gmesa->hHWContext, \
|
||||
(DRM_LOCK_HELD | gmesa->hHWContext), __ret ); \
|
||||
if ( __ret ) \
|
||||
gammaGetLock( gmesa, 0 ); \
|
||||
DEBUG_LOCK(); \
|
||||
} while (0)
|
||||
|
||||
/* Unlock the hardware.
|
||||
*/
|
||||
#define UNLOCK_HARDWARE( gmesa ) \
|
||||
do { \
|
||||
DRM_UNLOCK( gmesa->driFd, \
|
||||
gmesa->driHwLock, \
|
||||
gmesa->hHWContext ); \
|
||||
DEBUG_RESET(); \
|
||||
} while (0)
|
||||
|
||||
#define GAMMAHW_LOCK( gmesa ) \
|
||||
DRM_UNLOCK(gmesa->driFd, gmesa->driHwLock, gmesa->hHWContext); \
|
||||
DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
|
||||
gmesa->driScreen->drawLockID); \
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
|
||||
|
||||
#define GAMMAHW_UNLOCK( gmesa ) \
|
||||
DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
|
||||
gmesa->driScreen->drawLockID); \
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
|
||||
|
||||
#endif /* __GAMMA_LOCK_H__ */
|
||||
@@ -1,323 +0,0 @@
|
||||
/**************************************************************************
|
||||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
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, sub license, 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 NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL PRECISION INSIGHT 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.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Kevin E. Martin <kevin@precisioninsight.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GAMMA_MACROS_H_
|
||||
#define _GAMMA_MACROS_H_
|
||||
|
||||
#define DEBUG_DRMDMA
|
||||
#define DEBUG_ERRORS
|
||||
#define DEBUG_COMMANDS_NOT
|
||||
#define DEBUG_VERBOSE_NOT
|
||||
#define DEBUG_VERBOSE_EXTRA_NOT
|
||||
|
||||
#define RANDOMIZE_COLORS_NOT
|
||||
#define TURN_OFF_CLEARS_NOT
|
||||
#define CULL_ALL_PRIMS_NOT
|
||||
#define TURN_OFF_DEPTH_NOT
|
||||
#define TURN_OFF_BLEND_NOT
|
||||
#define FAST_CLEAR_4_NOT
|
||||
#define FORCE_DEPTH32_NOT
|
||||
#define DONT_SEND_DMA_NOT
|
||||
#define TURN_OFF_FCP_NOT
|
||||
#define TURN_OFF_TEXTURES_NOT
|
||||
#define DO_VALIDATE
|
||||
|
||||
#define GAMMA_DMA_BUFFER_SIZE 4096
|
||||
|
||||
#if 0
|
||||
#define GAMMA_DMA_SEND_FLAGS DRM_DMA_PRIORITY
|
||||
#define GAMMA_DMA_SEND_FLAGS DRM_DMA_BLOCK
|
||||
#else
|
||||
/* MUST use non-blocking dma flags for drawable lock routines */
|
||||
#define GAMMA_DMA_SEND_FLAGS 0
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define GAMMA_DMA_GET_FLAGS \
|
||||
(DRM_DMA_SMALLER_OK | DRM_DMA_LARGER_OK | DRM_DMA_WAIT)
|
||||
#else
|
||||
#define GAMMA_DMA_GET_FLAGS DRM_DMA_WAIT
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_DRMDMA) || defined(DEBUG_COMMANDS) || defined(DEBUG_VERBOSE)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/* Note: The argument to DEBUG_GLCMDS() _must_ be enclosed in parenthesis */
|
||||
#ifdef DEBUG_VERBOSE
|
||||
#define DEBUG_GLCMDS(s) printf s
|
||||
#else
|
||||
#define DEBUG_GLCMDS(s)
|
||||
#endif
|
||||
|
||||
/* Note: The argument to DEBUG_DMACMDS() _must_ be enclosed in parenthesis */
|
||||
#ifdef DEBUG_DRMDMA
|
||||
#define DEBUG_DMACMDS(s) printf s
|
||||
#else
|
||||
#define DEBUG_DMACMDS(s)
|
||||
#endif
|
||||
|
||||
/* Note: The argument to DEBUG_WRITE() _must_ be enclosed in parenthesis */
|
||||
#ifdef DEBUG_COMMANDS
|
||||
#define DEBUG_WRITE(s) printf s
|
||||
#else
|
||||
#define DEBUG_WRITE(s)
|
||||
#endif
|
||||
|
||||
/* Note: The argument to DEBUG_ERROR() _must_ be enclosed in parenthesis */
|
||||
#ifdef DEBUG_ERRORS
|
||||
#define DEBUG_ERROR(s) printf s
|
||||
#else
|
||||
#define DEBUG_ERROR(s)
|
||||
#endif
|
||||
|
||||
#define WRITEV(buf,val1,val2,val3,val4) \
|
||||
do { \
|
||||
buf++->i = 0x9C008300; \
|
||||
buf++->f = val1; \
|
||||
buf++->f = val2; \
|
||||
buf++->f = val3; \
|
||||
buf++->f = val4; \
|
||||
} while (0)
|
||||
|
||||
#define WRITE(buf,reg,val) \
|
||||
do { \
|
||||
buf++->i = Glint##reg##Tag; \
|
||||
buf++->i = val; \
|
||||
DEBUG_WRITE(("WRITE(buf, %s, 0x%08x);\n", #reg, (int)val)); \
|
||||
} while (0)
|
||||
|
||||
#define WRITEF(buf,reg,val) \
|
||||
do { \
|
||||
buf++->i = Glint##reg##Tag; \
|
||||
buf++->f = val; \
|
||||
DEBUG_WRITE(("WRITEF(buf, %s, %f);\n", #reg, (float)val)); \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_WC_DMA_BUFFER(gcp,n) \
|
||||
do { \
|
||||
(gcp)->WCbufCount += (n<<1); \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_DMA_BUFFER(gcp,n) \
|
||||
do { \
|
||||
if ((gcp)->bufCount+(n<<1) >= (gcp)->bufSize) \
|
||||
PROCESS_DMA_BUFFER(gcp); \
|
||||
(gcp)->bufCount += (n<<1); \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_DMA_BUFFER2(gcp,n) \
|
||||
do { \
|
||||
if ((gcp)->bufCount+n >= (gcp)->bufSize) \
|
||||
PROCESS_DMA_BUFFER(gcp); \
|
||||
(gcp)->bufCount += n; \
|
||||
} while (0)
|
||||
|
||||
#define FLUSH_DMA_BUFFER(gcp) \
|
||||
do { \
|
||||
if (gcp->bufCount) \
|
||||
PROCESS_DMA_BUFFER(gcp); \
|
||||
} while (0)
|
||||
|
||||
#ifdef DONT_SEND_DMA
|
||||
#define GET_DMA(fd, hHWCtx, n, idx, size)
|
||||
#define SEND_DMA(fd, hHWCtx,n, idx, cnt)
|
||||
#else
|
||||
#define GET_DMA(fd, hHWCtx, n, idx, size) \
|
||||
do { \
|
||||
drmDMAReq dma; \
|
||||
int retcode, i; \
|
||||
\
|
||||
dma.context = (hHWCtx); \
|
||||
dma.send_count = 0; \
|
||||
dma.send_list = NULL; \
|
||||
dma.send_sizes = NULL; \
|
||||
dma.flags = GAMMA_DMA_GET_FLAGS; \
|
||||
dma.request_count = (n); \
|
||||
dma.request_size = GAMMA_DMA_BUFFER_SIZE; \
|
||||
dma.request_list = (idx); \
|
||||
dma.request_sizes = (size); \
|
||||
\
|
||||
do { \
|
||||
if ((retcode = drmDMA((fd), &dma))) { \
|
||||
DEBUG_DMACMDS(("drmDMA returned %d\n", retcode)); \
|
||||
} \
|
||||
} while (!(dma).granted_count); \
|
||||
\
|
||||
for (i = 0; i < (n); i++) { \
|
||||
(size)[i] >>= 2; /* Convert from bytes to words */ \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SEND_DMA(fd, hHWCtx, n, idx, cnt) \
|
||||
do { \
|
||||
drmDMAReq dma; \
|
||||
int retcode, i; \
|
||||
\
|
||||
for (i = 0; i < (n); i++) { \
|
||||
(cnt)[i] <<= 2; /* Convert from words to bytes */ \
|
||||
} \
|
||||
\
|
||||
dma.context = (hHWCtx); \
|
||||
dma.send_count = 1; \
|
||||
dma.send_list = (idx); \
|
||||
dma.send_sizes = (cnt); \
|
||||
dma.flags = GAMMA_DMA_SEND_FLAGS; \
|
||||
dma.request_count = 0; \
|
||||
dma.request_size = 0; \
|
||||
dma.request_list = NULL; \
|
||||
dma.request_sizes = NULL; \
|
||||
\
|
||||
if ((retcode = drmDMA((fd), &dma))) { \
|
||||
DEBUG_DMACMDS(("drmDMA returned %d\n", retcode)); \
|
||||
} \
|
||||
\
|
||||
for (i = 0; i < (n); i++) { \
|
||||
(cnt)[i] = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define GET_FIRST_DMA(fd, hHWCtx, n, idx, size, buf, cnt, gPriv) \
|
||||
do { \
|
||||
int i; \
|
||||
\
|
||||
GET_DMA(fd, hHWCtx, n, idx, size); \
|
||||
\
|
||||
for (i = 0; i < (n); i++) { \
|
||||
(buf)[i] = (dmaBuf)(gPriv)->bufs->list[(idx)[i]].address; \
|
||||
(cnt)[i] = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PROCESS_DMA_BUFFER_TOP_HALF(gcp) \
|
||||
do { \
|
||||
SEND_DMA((gcp)->driFd, \
|
||||
(gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufCount); \
|
||||
} while (0)
|
||||
|
||||
#define PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp) \
|
||||
do { \
|
||||
GET_DMA((gcp)->driFd, \
|
||||
(gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufSize); \
|
||||
\
|
||||
(gcp)->buf = \
|
||||
(dmaBuf)(gcp)->gammaScreen->bufs->list[(gcp)->bufIndex].address; \
|
||||
} while (0)
|
||||
|
||||
#define PROCESS_DMA_BUFFER(gcp) \
|
||||
do { \
|
||||
VALIDATE_DRAWABLE_INFO(gcp); \
|
||||
PROCESS_DMA_BUFFER_TOP_HALF(gcp); \
|
||||
PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp); \
|
||||
} while (0)
|
||||
|
||||
#ifdef DO_VALIDATE
|
||||
#define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp) \
|
||||
do { \
|
||||
/*__DRIscreen *psp = gcp->driScreen;*/ \
|
||||
__DRIdrawable *pdp = gcp->driDrawable; \
|
||||
\
|
||||
if (*(pdp->pStamp) != pdp->lastStamp) { \
|
||||
int old_index = pdp->index; \
|
||||
while (*(pdp->pStamp) != pdp->lastStamp) { \
|
||||
DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \
|
||||
} \
|
||||
if (pdp->index != old_index) { \
|
||||
gcp->Window &= ~W_GIDMask; \
|
||||
gcp->Window |= (pdp->index << 5); \
|
||||
CHECK_WC_DMA_BUFFER(gcp, 1); \
|
||||
WRITE(gcp->WCbuf, GLINTWindow, gcp->Window|(gcp->FrameCount<<9));\
|
||||
} \
|
||||
\
|
||||
gammaUpdateViewportOffset( gcp->glCtx); \
|
||||
\
|
||||
if (pdp->numClipRects == 1 && \
|
||||
pdp->pClipRects->x1 == pdp->x && \
|
||||
pdp->pClipRects->x2 == (pdp->x+pdp->w) && \
|
||||
pdp->pClipRects->y1 == pdp->y && \
|
||||
pdp->pClipRects->y2 == (pdp->y+pdp->h)) { \
|
||||
CHECK_WC_DMA_BUFFER(gcp, 1); \
|
||||
WRITE(gcp->WCbuf, Rectangle2DControl, 0); \
|
||||
gcp->NotClipped = GL_TRUE; \
|
||||
} else { \
|
||||
CHECK_WC_DMA_BUFFER(gcp, 1); \
|
||||
WRITE(gcp->WCbuf, Rectangle2DControl, 1); \
|
||||
gcp->NotClipped = GL_FALSE; \
|
||||
} \
|
||||
gcp->WindowChanged = GL_TRUE; \
|
||||
\
|
||||
if (gcp->WCbufCount) { \
|
||||
SEND_DMA((gcp)->gammaScreen->driScreen->fd, \
|
||||
(gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \
|
||||
&(gcp)->WCbufCount); \
|
||||
(gcp)->WCbufIndex = -1; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp) \
|
||||
do { \
|
||||
if ((gcp)->WCbufIndex < 0) { \
|
||||
GET_DMA((gcp)->gammaScreen->driScreen->fd, \
|
||||
(gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \
|
||||
&(gcp)->WCbufSize); \
|
||||
\
|
||||
(gcp)->WCbuf = \
|
||||
(dmaBuf)(gcp)->gammaScreen->bufs-> \
|
||||
list[(gcp)->WCbufIndex].address; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define VALIDATE_DRAWABLE_INFO(gcp) \
|
||||
do { \
|
||||
__DRIscreen *psp = gcp->driScreen; \
|
||||
if (gcp->driDrawable) { \
|
||||
DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp); \
|
||||
DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define VALIDATE_DRAWABLE_INFO(gcp)
|
||||
#endif
|
||||
|
||||
#define CALC_LOG2(l2,s) \
|
||||
do { \
|
||||
int __s = s; \
|
||||
l2 = 0; \
|
||||
while (__s > 1) { ++l2; __s >>= 1; } \
|
||||
} while (0)
|
||||
|
||||
#endif /* _GAMMA_MACROS_H_ */
|
||||
@@ -1,658 +0,0 @@
|
||||
/**************************************************************************
|
||||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
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, sub license, 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 NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL PRECISION INSIGHT 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.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Kevin E. Martin <kevin@precisioninsight.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GAMMA_REGS_H_
|
||||
#define _GAMMA_REGS_H_
|
||||
|
||||
#include "gamma_client.h"
|
||||
|
||||
/**************** MX FLAGS ****************/
|
||||
/* FBReadMode */
|
||||
#define FBReadSrcDisable 0x00000000
|
||||
#define FBReadSrcEnable 0x00000200
|
||||
#define FBReadDstDisable 0x00000000
|
||||
#define FBReadDstEnable 0x00000400
|
||||
#define FBDataTypeDefault 0x00000000
|
||||
#define FBDataTypeColor 0x00008000
|
||||
#define FBWindowOriginTop 0x00000000
|
||||
#define FBWindowOriginBot 0x00010000
|
||||
#define FBScanLineInt1 0x00000000
|
||||
#define FBScanLineInt2 0x00800000
|
||||
#define FBScanLineInt4 0x01000000
|
||||
#define FBScanLineInt8 0x01800000
|
||||
#define FBSrcAddrConst 0x00000000
|
||||
#define FBSrcAddrIndex 0x10000000
|
||||
#define FBSrcAddrCoord 0x20000000
|
||||
|
||||
/* LBReadMode */
|
||||
#define LBPartialProdMask 0x000001ff
|
||||
#define LBReadSrcDisable 0x00000000
|
||||
#define LBReadSrcEnable 0x00000200
|
||||
#define LBReadDstDisable 0x00000000
|
||||
#define LBReadDstEnable 0x00000400
|
||||
#define LBDataTypeDefault 0x00000000
|
||||
#define LBDataTypeStencil 0x00010000
|
||||
#define LBDataTypeDepth 0x00020000
|
||||
#define LBWindowOriginTop 0x00000000
|
||||
#define LBWindowOriginBot 0x00040000
|
||||
#define LBScanLineInt1 0x00000000
|
||||
#define LBScanLineInt2 0x00100000
|
||||
#define LBScanLineInt4 0x00200000
|
||||
#define LBScanLineInt8 0x00300000
|
||||
|
||||
/* ColorDDAMode */
|
||||
#define ColorDDADisable 0x00000000
|
||||
#define ColorDDAEnable 0x00000001
|
||||
#define ColorDDAFlat 0x00000000
|
||||
#define ColorDDAGouraud 0x00000002
|
||||
#define ColorDDAShadingMask 0x00000002
|
||||
|
||||
/* AlphaTestMode */
|
||||
#define AlphaTestModeDisable 0x00000000
|
||||
#define AlphaTestModeEnable 0x00000001
|
||||
#define AT_Never 0x00000000
|
||||
#define AT_Less 0x00000002
|
||||
#define AT_Equal 0x00000004
|
||||
#define AT_LessEqual 0x00000006
|
||||
#define AT_Greater 0x00000008
|
||||
#define AT_NotEqual 0x0000000a
|
||||
#define AT_GreaterEqual 0x0000000c
|
||||
#define AT_Always 0x0000000e
|
||||
#define AT_CompareMask 0x0000000e
|
||||
#define AT_RefValueMask 0x00000ff0
|
||||
|
||||
/* AlphaBlendMode */
|
||||
#define AlphaBlendModeDisable 0x00000000
|
||||
#define AlphaBlendModeEnable 0x00000001
|
||||
#define AB_Src_Zero 0x00000000
|
||||
#define AB_Src_One 0x00000002
|
||||
#define AB_Src_DstColor 0x00000004
|
||||
#define AB_Src_OneMinusDstColor 0x00000006
|
||||
#define AB_Src_SrcAlpha 0x00000008
|
||||
#define AB_Src_OneMinusSrcAlpha 0x0000000a
|
||||
#define AB_Src_DstAlpha 0x0000000c
|
||||
#define AB_Src_OneMinusDstAlpha 0x0000000e
|
||||
#define AB_Src_SrcAlphaSaturate 0x00000010
|
||||
#define AB_SrcBlendMask 0x0000001e
|
||||
#define AB_Dst_Zero 0x00000000
|
||||
#define AB_Dst_One 0x00000020
|
||||
#define AB_Dst_SrcColor 0x00000040
|
||||
#define AB_Dst_OneMinusSrcColor 0x00000060
|
||||
#define AB_Dst_SrcAlpha 0x00000080
|
||||
#define AB_Dst_OneMinusSrcAlpha 0x000000a0
|
||||
#define AB_Dst_DstAlpha 0x000000c0
|
||||
#define AB_Dst_OneMinusDstAlpha 0x000000e0
|
||||
#define AB_DstBlendMask 0x000000e0
|
||||
#define AB_ColorFmt_8888 0x00000000
|
||||
#define AB_ColorFmt_5555 0x00000100
|
||||
#define AB_ColorFmt_4444 0x00000200
|
||||
#define AB_ColorFmt_4444Front 0x00000300
|
||||
#define AB_ColorFmt_4444Back 0x00000400
|
||||
#define AB_ColorFmt_332Front 0x00000500
|
||||
#define AB_ColorFmt_332Back 0x00000600
|
||||
#define AB_ColorFmt_121Front 0x00000700
|
||||
#define AB_ColorFmt_121Back 0x00000800
|
||||
#define AB_ColorFmt_555Back 0x00000d00
|
||||
#define AB_ColorFmt_CI8 0x00000e00
|
||||
#define AB_ColorFmt_CI4 0x00000f00
|
||||
#define AB_AlphaBufferPresent 0x00000000
|
||||
#define AB_NoAlphaBufferPresent 0x00001000
|
||||
#define AB_ColorOrder_BGR 0x00000000
|
||||
#define AB_ColorOrder_RGB 0x00002000
|
||||
#define AB_OpenGLType 0x00000000
|
||||
#define AB_QuickDraw3DType 0x00004000
|
||||
#define AB_AlphaDst_FBData 0x00000000
|
||||
#define AB_AlphaDst_FBSourceData 0x00008000
|
||||
#define AB_ColorConversionScale 0x00000000
|
||||
#define AB_ColorConversionShift 0x00010000
|
||||
#define AB_AlphaConversionScale 0x00000000
|
||||
#define AB_AlphaConversionShift 0x00020000
|
||||
|
||||
/* AntialiasMode */
|
||||
#define AntialiasModeDisable 0x00000000
|
||||
#define AntialiasModeEnable 0x00000001
|
||||
|
||||
/* AreaStippleMode */
|
||||
#define AreaStippleModeDisable 0x00000000
|
||||
#define AreaStippleModeEnable 0x00000001
|
||||
#define ASM_X32 0x00000008
|
||||
#define ASM_Y32 0x00000040
|
||||
|
||||
/* DepthMode */
|
||||
#define DepthModeDisable 0x00000000
|
||||
#define DepthModeEnable 0x00000001
|
||||
#define DM_WriteMask 0x00000002
|
||||
#define DM_SourceFragment 0x00000000
|
||||
#define DM_SourceLBData 0x00000004
|
||||
#define DM_SourceDepthRegister 0x00000008
|
||||
#define DM_SourceLBSourceData 0x0000000c
|
||||
#define DM_SourceMask 0x0000000c
|
||||
#define DM_Never 0x00000000
|
||||
#define DM_Less 0x00000010
|
||||
#define DM_Equal 0x00000020
|
||||
#define DM_LessEqual 0x00000030
|
||||
#define DM_Greater 0x00000040
|
||||
#define DM_NotEqual 0x00000050
|
||||
#define DM_GreaterEqual 0x00000060
|
||||
#define DM_Always 0x00000070
|
||||
#define DM_CompareMask 0x00000070
|
||||
|
||||
/* FBWriteMode */
|
||||
#define FBWriteModeDisable 0x00000000
|
||||
#define FBWriteModeEnable 0x00000001
|
||||
#define FBW_UploadColorData 0x00000008
|
||||
|
||||
/* FogMode */
|
||||
#define FogModeDisable 0x00000000
|
||||
#define FogModeEnable 0x00000001
|
||||
|
||||
/* LBWriteMode */
|
||||
#define LBWriteModeDisable 0x00000000
|
||||
#define LBWriteModeEnable 0x00000001
|
||||
#define LBW_UploadNone 0x00000000
|
||||
#define LBW_UploadDepth 0x00000002
|
||||
#define LBW_UploadStencil 0x00000004
|
||||
|
||||
/* LBRead/Write Format */
|
||||
#define LBRF_DepthWidth15 0x03 /* only permedia */
|
||||
#define LBRF_DepthWidth16 0x00
|
||||
#define LBRF_DepthWidth24 0x01
|
||||
#define LBRF_DepthWidth32 0x02
|
||||
#define LBRF_StencilWidth0 (0 << 2)
|
||||
#define LBRF_StencilWidth4 (1 << 2)
|
||||
#define LBRF_StencilWidth8 (2 << 2)
|
||||
#define LBRF_StencilPos16 (0 << 4)
|
||||
#define LBRF_StencilPos20 (1 << 4)
|
||||
#define LBRF_StencilPos24 (2 << 4)
|
||||
#define LBRF_StencilPos28 (3 << 4)
|
||||
#define LBRF_StencilPos32 (4 << 4)
|
||||
#define LBRF_FrameCount0 (0 << 7)
|
||||
#define LBRF_FrameCount4 (1 << 7)
|
||||
#define LBRF_FrameCount8 (2 << 7)
|
||||
#define LBRF_FrameCountPos16 (0 << 9)
|
||||
#define LBRF_FrameCountPos20 (1 << 9)
|
||||
#define LBRF_FrameCountPos24 (2 << 9)
|
||||
#define LBRF_FrameCountPos28 (3 << 9)
|
||||
#define LBRF_FrameCountPos32 (4 << 9)
|
||||
#define LBRF_FrameCountPos36 (5 << 9)
|
||||
#define LBRF_FrameCountPos40 (6 << 9)
|
||||
#define LBRF_GIDWidth0 (0 << 12)
|
||||
#define LBRF_GIDWidth4 (1 << 12)
|
||||
#define LBRF_GIDPos16 (0 << 13)
|
||||
#define LBRF_GIDPos20 (1 << 13)
|
||||
#define LBRF_GIDPos24 (2 << 13)
|
||||
#define LBRF_GIDPos28 (3 << 13)
|
||||
#define LBRF_GIDPos32 (4 << 13)
|
||||
#define LBRF_GIDPos36 (5 << 13)
|
||||
#define LBRF_GIDPos40 (6 << 13)
|
||||
#define LBRF_GIDPos44 (7 << 13)
|
||||
#define LBRF_GIDPos48 (8 << 13)
|
||||
#define LBRF_Compact32 (1 << 17)
|
||||
|
||||
/* StencilMode */
|
||||
#define StencilDisable 0x00000000
|
||||
#define StencilEnable 0x00000001
|
||||
|
||||
/* RouterMode */
|
||||
#define R_Order_TextureDepth 0x00000000
|
||||
#define R_Order_DepthTexture 0x00000001
|
||||
|
||||
/* ScissorMode */
|
||||
#define UserScissorDisable 0x00000000
|
||||
#define UserScissorEnable 0x00000001
|
||||
#define ScreenScissorDisable 0x00000000
|
||||
#define ScreenScissorEnable 0x00000002
|
||||
|
||||
/* DitherMode */
|
||||
#define DitherModeDisable 0x00000000
|
||||
#define DitherModeEnable 0x00000001
|
||||
#define DM_DitherDisable 0x00000000
|
||||
#define DM_DitherEnable 0x00000002
|
||||
#define DM_ColorFmt_8888 0x00000000
|
||||
#define DM_ColorFmt_5555 0x00000004
|
||||
#define DM_ColorFmt_4444 0x00000008
|
||||
#define DM_ColorFmt_4444Front 0x0000000c
|
||||
#define DM_ColorFmt_4444Back 0x00000010
|
||||
#define DM_ColorFmt_332Front 0x00000014
|
||||
#define DM_ColorFmt_332Back 0x00000018
|
||||
#define DM_ColorFmt_121Front 0x0000001c
|
||||
#define DM_ColorFmt_121Back 0x00000020
|
||||
#define DM_ColorFmt_555Back 0x00000024
|
||||
#define DM_ColorFmt_CI8 0x00000028
|
||||
#define DM_ColorFmt_CI4 0x0000002c
|
||||
#define DM_XOffsetMask 0x000000c0
|
||||
#define DM_YOffsetMask 0x00000300
|
||||
#define DM_ColorOrder_BGR 0x00000000
|
||||
#define DM_ColorOrder_RGB 0x00000400
|
||||
#define DM_AlphaDitherDefault 0x00000000
|
||||
#define DM_AlphaDitherNone 0x00004000
|
||||
#define DM_Truncate 0x00000000
|
||||
#define DM_Round 0x00008000
|
||||
|
||||
/* RasterizerMode */
|
||||
#define RM_MirrorBitMask 0x00000001
|
||||
#define RM_InvertBitMask 0x00000002
|
||||
#define RM_FractionAdjNo 0x00000000
|
||||
#define RM_FractionAdjZero 0x00000004
|
||||
#define RM_FractionAdjHalf 0x00000008
|
||||
#define RM_FractionAdjNearHalf 0x0000000c
|
||||
#define RM_BiasCoordZero 0x00000000
|
||||
#define RM_BiasCoordHalf 0x00000010
|
||||
#define RM_BiasCoordNearHalf 0x00000020
|
||||
#define RM_BitMaskByteSwap_ABCD 0x00000000
|
||||
#define RM_BitMaskByteSwap_BADC 0x00000080
|
||||
#define RM_BitMaskByteSwap_CDAB 0x00000100
|
||||
#define RM_BitMaskByteSwap_DCBA 0x00000180
|
||||
#define RM_BitMaskPacked 0x00000000
|
||||
#define RM_BitMaskEveryScanline 0x00000200
|
||||
#define RM_BitMaskOffsetMask 0x00007c00
|
||||
#define RM_HostDataByteSwap_ABCD 0x00000000
|
||||
#define RM_HostDataByteSwap_BADC 0x00008000
|
||||
#define RM_HostDataByteSwap_CDAB 0x00010000
|
||||
#define RM_HostDataByteSwap_DCBA 0x00018000
|
||||
#define RM_SingleGLINT 0x00000000
|
||||
#define RM_MultiGLINT 0x00020000
|
||||
#define RM_YLimitsEnable 0x00040000
|
||||
|
||||
/* Window */
|
||||
#define WindowDisable 0x00000000
|
||||
#define WindowEnable 0x00000001
|
||||
#define W_AlwaysPass 0x00000000
|
||||
#define W_NeverPass 0x00000002
|
||||
#define W_PassIfEqual 0x00000004
|
||||
#define W_PassIfNotEqual 0x00000006
|
||||
#define W_CompareMask 0x00000006
|
||||
#define W_ForceLBUpdate 0x00000008
|
||||
#define W_LBUpdateFromSource 0x00000000
|
||||
#define W_LBUpdateFromRegisters 0x00000010
|
||||
#define W_GIDMask 0x000001e0
|
||||
#define W_FrameCountMask 0x0001fe00
|
||||
#define W_StencilFCP 0x00020000
|
||||
#define W_DepthFCP 0x00040000
|
||||
#define W_OverrideWriteFiltering 0x00080000
|
||||
|
||||
/* TextureAddressMode */
|
||||
#define TextureAddressModeDisable 0x00000000
|
||||
#define TextureAddressModeEnable 0x00000001
|
||||
#define TAM_SWrap_Clamp 0x00000000
|
||||
#define TAM_SWrap_Repeat 0x00000002
|
||||
#define TAM_SWrap_Mirror 0x00000004
|
||||
#define TAM_SWrap_Mask 0x00000006
|
||||
#define TAM_TWrap_Clamp 0x00000000
|
||||
#define TAM_TWrap_Repeat 0x00000008
|
||||
#define TAM_TWrap_Mirror 0x00000010
|
||||
#define TAM_TWrap_Mask 0x00000018
|
||||
#define TAM_Operation_2D 0x00000000
|
||||
#define TAM_Operation_3D 0x00000020
|
||||
#define TAM_InhibitDDAInit 0x00000040
|
||||
#define TAM_LODDisable 0x00000000
|
||||
#define TAM_LODEnable 0x00000080
|
||||
#define TAM_DY_Disable 0x00000000
|
||||
#define TAM_DY_Enable 0x00000100
|
||||
#define TAM_WidthMask 0x00001e00
|
||||
#define TAM_HeightMask 0x0001e000
|
||||
#define TAM_TexMapType_1D 0x00000000
|
||||
#define TAM_TexMapType_2D 0x00020000
|
||||
#define TAM_TexMapType_Mask 0x00020000
|
||||
|
||||
/* TextureReadMode */
|
||||
#define TextureReadModeDisable 0x00000000
|
||||
#define TextureReadModeEnable 0x00000001
|
||||
#define TRM_WidthMask 0x0000001e
|
||||
#define TRM_HeightMask 0x000001e0
|
||||
#define TRM_Depth1 0x00000000
|
||||
#define TRM_Depth2 0x00000200
|
||||
#define TRM_Depth4 0x00000400
|
||||
#define TRM_Depth8 0x00000600
|
||||
#define TRM_Depth16 0x00000800
|
||||
#define TRM_Depth32 0x00000a00
|
||||
#define TRM_DepthMask 0x00000e00
|
||||
#define TRM_Border 0x00001000
|
||||
#define TRM_Patch 0x00002000
|
||||
#define TRM_Mag_Nearest 0x00000000
|
||||
#define TRM_Mag_Linear 0x00004000
|
||||
#define TRM_Mag_Mask 0x00004000
|
||||
#define TRM_Min_Nearest 0x00000000
|
||||
#define TRM_Min_Linear 0x00008000
|
||||
#define TRM_Min_NearestMMNearest 0x00010000
|
||||
#define TRM_Min_NearestMMLinear 0x00018000
|
||||
#define TRM_Min_LinearMMNearest 0x00020000
|
||||
#define TRM_Min_LinearMMLinear 0x00028000
|
||||
#define TRM_Min_Mask 0x00038000
|
||||
#define TRM_UWrap_Clamp 0x00000000
|
||||
#define TRM_UWrap_Repeat 0x00040000
|
||||
#define TRM_UWrap_Mirror 0x00080000
|
||||
#define TRM_UWrap_Mask 0x000c0000
|
||||
#define TRM_VWrap_Clamp 0x00000000
|
||||
#define TRM_VWrap_Repeat 0x00100000
|
||||
#define TRM_VWrap_Mirror 0x00200000
|
||||
#define TRM_VWrap_Mask 0x00300000
|
||||
#define TRM_TexMapType_1D 0x00000000
|
||||
#define TRM_TexMapType_2D 0x00400000
|
||||
#define TRM_TexMapType_Mask 0x00400000
|
||||
#define TRM_MipMapDisable 0x00000000
|
||||
#define TRM_MipMapEnable 0x00800000
|
||||
#define TRM_PrimaryCacheDisable 0x00000000
|
||||
#define TRM_PrimaryCacheEnable 0x01000000
|
||||
#define TRM_FBSourceAddr_None 0x00000000
|
||||
#define TRM_FBSourceAddr_Index 0x02000000
|
||||
#define TRM_FBSourceAddr_Coord 0x04000000
|
||||
#define TRM_BorderClamp 0x08000000
|
||||
|
||||
/* TextureColorMode */
|
||||
#define TextureColorModeDisable 0x00000000
|
||||
#define TextureColorModeEnable 0x00000001
|
||||
#define TCM_Modulate 0x00000000
|
||||
#define TCM_Decal 0x00000002
|
||||
#define TCM_Blend 0x00000004
|
||||
#define TCM_Replace 0x00000006
|
||||
#define TCM_ApplicationMask 0x0000000e
|
||||
#define TCM_OpenGLType 0x00000000
|
||||
#define TCM_QuickDraw3DType 0x00000010
|
||||
#define TCM_KdDDA_Disable 0x00000000
|
||||
#define TCM_KdDDA_Enable 0x00000020
|
||||
#define TCM_KsDDA_Disable 0x00000000
|
||||
#define TCM_KsDDA_Enable 0x00000040
|
||||
#define TCM_BaseFormat_Alpha 0x00000000
|
||||
#define TCM_BaseFormat_Lum 0x00000080
|
||||
#define TCM_BaseFormat_LumAlpha 0x00000100
|
||||
#define TCM_BaseFormat_Intensity 0x00000180
|
||||
#define TCM_BaseFormat_RGB 0x00000200
|
||||
#define TCM_BaseFormat_RGBA 0x00000280
|
||||
#define TCM_BaseFormatMask 0x00000380
|
||||
#define TCM_LoadMode_None 0x00000000
|
||||
#define TCM_LoadMode_Ks 0x00000400
|
||||
#define TCM_LoadMode_Kd 0x00000800
|
||||
|
||||
/* TextureCacheControl */
|
||||
#define TCC_Invalidate 0x00000001
|
||||
#define TCC_Disable 0x00000000
|
||||
#define TCC_Enable 0x00000002
|
||||
|
||||
/* TextureFilterMode */
|
||||
#define TextureFilterModeDisable 0x00000000
|
||||
#define TextureFilterModeEnable 0x00000001
|
||||
#define TFM_AlphaMapEnable 0x00000002
|
||||
#define TFM_AlphaMapSense 0x00000004
|
||||
|
||||
/* TextureFormat */
|
||||
#define TF_LittleEndian 0x00000000
|
||||
#define TF_BigEndian 0x00000001
|
||||
#define TF_16Bit_565 0x00000000
|
||||
#define TF_16Bit_555 0x00000002
|
||||
#define TF_ColorOrder_BGR 0x00000000
|
||||
#define TF_ColorOrder_RGB 0x00000004
|
||||
#define TF_Compnents_1 0x00000000
|
||||
#define TF_Compnents_2 0x00000008
|
||||
#define TF_Compnents_3 0x00000010
|
||||
#define TF_Compnents_4 0x00000018
|
||||
#define TF_CompnentsMask 0x00000018
|
||||
#define TF_OutputFmt_Texel 0x00000000
|
||||
#define TF_OutputFmt_Color 0x00000020
|
||||
#define TF_OutputFmt_BitMask 0x00000040
|
||||
#define TF_OutputFmtMask 0x00000060
|
||||
#define TF_MirrorEnable 0x00000080
|
||||
#define TF_InvertEnable 0x00000100
|
||||
#define TF_ByteSwapEnable 0x00000200
|
||||
#define TF_LUTOffsetMask 0x0003fc00
|
||||
#define TF_OneCompFmt_Lum 0x00000000
|
||||
#define TF_OneCompFmt_Alpha 0x00040000
|
||||
#define TF_OneCompFmt_Intensity 0x00080000
|
||||
#define TF_OneCompFmt_Mask 0x000c0000
|
||||
/**************** MX FLAGS ****************/
|
||||
|
||||
/************** GAMMA FLAGS ***************/
|
||||
/* GeometryMode */
|
||||
#define GM_TextureDisable 0x00000000
|
||||
#define GM_TextureEnable 0x00000001
|
||||
#define GM_FogDisable 0x00000000
|
||||
#define GM_FogEnable 0x00000002
|
||||
#define GM_FogLinear 0x00000000
|
||||
#define GM_FogExp 0x00000004
|
||||
#define GM_FogExpSquared 0x00000008
|
||||
#define GM_FogMask 0x0000000C
|
||||
#define GM_FrontPolyPoint 0x00000000
|
||||
#define GM_FrontPolyLine 0x00000010
|
||||
#define GM_FrontPolyFill 0x00000020
|
||||
#define GM_BackPolyPoint 0x00000000
|
||||
#define GM_BackPolyLine 0x00000040
|
||||
#define GM_BackPolyFill 0x00000080
|
||||
#define GM_FB_PolyMask 0x000000F0
|
||||
#define GM_FrontFaceCW 0x00000000
|
||||
#define GM_FrontFaceCCW 0x00000100
|
||||
#define GM_FFMask 0x00000100
|
||||
#define GM_PolyCullDisable 0x00000000
|
||||
#define GM_PolyCullEnable 0x00000200
|
||||
#define GM_PolyCullFront 0x00000000
|
||||
#define GM_PolyCullBack 0x00000400
|
||||
#define GM_PolyCullBoth 0x00000800
|
||||
#define GM_PolyCullMask 0x00000c00
|
||||
#define GM_ClipShortLinesDisable 0x00000000
|
||||
#define GM_ClipShortLinesEnable 0x00001000
|
||||
#define GM_ClipSmallTrisDisable 0x00000000
|
||||
#define GM_ClipSmallTrisEnable 0x00002000
|
||||
#define GM_RenderMode 0x00000000
|
||||
#define GM_SelectMode 0x00004000
|
||||
#define GM_FeedbackMode 0x00008000
|
||||
#define GM_Feedback2D 0x00000000
|
||||
#define GM_Feedback3D 0x00010000
|
||||
#define GM_Feedback3DColor 0x00020000
|
||||
#define GM_Feedback3DColorTexture 0x00030000
|
||||
#define GM_Feedback4DColorTexture 0x00040000
|
||||
#define GM_CullFaceNormDisable 0x00000000
|
||||
#define GM_CullFaceNormEnable 0x00080000
|
||||
#define GM_AutoFaceNormDisable 0x00000000
|
||||
#define GM_AutoFaceNormEnable 0x00100000
|
||||
#define GM_GouraudShading 0x00000000
|
||||
#define GM_FlatShading 0x00200000
|
||||
#define GM_ShadingMask 0x00200000
|
||||
#define GM_UserClipNone 0x00000000
|
||||
#define GM_UserClip0 0x00400000
|
||||
#define GM_UserClip1 0x00800000
|
||||
#define GM_UserClip2 0x01000000
|
||||
#define GM_UserClip3 0x02000000
|
||||
#define GM_UserClip4 0x04000000
|
||||
#define GM_UserClip5 0x08000000
|
||||
#define GM_PolyOffsetPointDisable 0x00000000
|
||||
#define GM_PolyOffsetPointEnable 0x10000000
|
||||
#define GM_PolyOffsetLineDisable 0x00000000
|
||||
#define GM_PolyOffsetLineEnable 0x20000000
|
||||
#define GM_PolyOffsetFillDisable 0x00000000
|
||||
#define GM_PolyOffsetFillEnable 0x40000000
|
||||
#define GM_InvertFaceNormCullDisable 0x00000000
|
||||
#define GM_InvertFaceNormCullEnable 0x80000000
|
||||
|
||||
/* Begin */
|
||||
#define B_AreaStippleDisable 0x00000000
|
||||
#define B_AreaStippleEnable 0x00000001
|
||||
#define B_LineStippleDisable 0x00000000
|
||||
#define B_LineStippleEnable 0x00000002
|
||||
#define B_AntiAliasDisable 0x00000000
|
||||
#define B_AntiAliasEnable 0x00000100
|
||||
#define B_TextureDisable 0x00000000
|
||||
#define B_TextureEnable 0x00002000
|
||||
#define B_FogDisable 0x00000000
|
||||
#define B_FogEnable 0x00004000
|
||||
#define B_SubPixelCorrectDisable 0x00000000
|
||||
#define B_SubPixelCorrectEnable 0x00010000
|
||||
#define B_PrimType_Null 0x00000000
|
||||
#define B_PrimType_Points 0x10000000
|
||||
#define B_PrimType_Lines 0x20000000
|
||||
#define B_PrimType_LineLoop 0x30000000
|
||||
#define B_PrimType_LineStrip 0x40000000
|
||||
#define B_PrimType_Triangles 0x50000000
|
||||
#define B_PrimType_TriangleStrip 0x60000000
|
||||
#define B_PrimType_TriangleFan 0x70000000
|
||||
#define B_PrimType_Quads 0x80000000
|
||||
#define B_PrimType_QuadStrip 0x90000000
|
||||
#define B_PrimType_Polygon 0xa0000000
|
||||
#define B_PrimType_Mask 0xf0000000
|
||||
|
||||
/* EdgeFlag */
|
||||
#define EdgeFlagDisable 0x00000000
|
||||
#define EdgeFlagEnable 0x00000001
|
||||
|
||||
/* NormalizeMode */
|
||||
#define NormalizeModeDisable 0x00000000
|
||||
#define NormalizeModeEnable 0x00000001
|
||||
#define FaceNormalDisable 0x00000000
|
||||
#define FaceNormalEnable 0x00000002
|
||||
#define InvertAutoFaceNormal 0x00000004
|
||||
|
||||
/* LightingMode */
|
||||
#define LightingModeDisable 0x00000000
|
||||
#define LightingModeEnable 0x00000001
|
||||
#define LightingModeTwoSides 0x00000004
|
||||
#define LightingModeLocalViewer 0x00000008
|
||||
#define LightingModeSpecularEnable 0x00008000
|
||||
|
||||
/* Light0Mode */
|
||||
#define Light0ModeDisable 0x00000000
|
||||
#define Light0ModeEnable 0x00000001
|
||||
#define Light0ModeSpotLight 0x00000002
|
||||
#define Light0ModeAttenuation 0x00000004
|
||||
#define Light0ModeLocal 0x00000008
|
||||
|
||||
/* Light0Mode */
|
||||
#define Light1ModeDisable 0x00000000
|
||||
#define Light1ModeEnable 0x00000001
|
||||
#define Light1ModeSpotLight 0x00000002
|
||||
#define Light1ModeAttenuation 0x00000004
|
||||
#define Light1ModeLocal 0x00000008
|
||||
|
||||
/* ColorMaterialMode */
|
||||
#define ColorMaterialModeDisable 0x00000000
|
||||
#define ColorMaterialModeEnable 0x00000001
|
||||
#define ColorMaterialModeFront 0x00000000
|
||||
#define ColorMaterialModeBack 0x00000002
|
||||
#define ColorMaterialModeFrontAndBack 0x00000004
|
||||
#define ColorMaterialModeEmission 0x00000000
|
||||
#define ColorMaterialModeAmbient 0x00000008
|
||||
#define ColorMaterialModeDiffuse 0x00000010
|
||||
#define ColorMaterialModeSpecular 0x00000018
|
||||
#define ColorMaterialModeAmbAndDiff 0x00000020
|
||||
#define ColorMaterialModeMask 0x0000003e
|
||||
|
||||
/* MaterialMode */
|
||||
#define MaterialModeDisable 0x00000000
|
||||
#define MaterialModeEnable 0x00000001
|
||||
#define MaterialModeTwoSides 0x00000080
|
||||
|
||||
/* DeltaMode */
|
||||
#define DM_Target300SX 0x00000000
|
||||
#define DM_Target500TXMX 0x00000001
|
||||
#define DM_Depth16 0x00000004
|
||||
#define DM_Depth24 0x00000008
|
||||
#define DM_Depth32 0x0000000c
|
||||
#define DM_FogEnable 0x00000010
|
||||
#define DM_TextureEnable 0x00000020
|
||||
#define DM_SmoothShadingEnable 0x00000040
|
||||
#define DM_DepthEnable 0x00000080
|
||||
#define DM_SpecularEnable 0x00000100
|
||||
#define DM_DiffuseEnable 0x00000200
|
||||
#define DM_SubPixlCorrectionEnable 0x00000400
|
||||
#define DM_DiamondExit 0x00000800
|
||||
#define DM_NoDraw 0x00001000
|
||||
#define DM_ClampEnable 0x00002000
|
||||
#define DM_TextureParameterAsGiven 0x00000000
|
||||
#define DM_TextureParameterClamped 0x00004000
|
||||
#define DM_TextureParameterNormalized 0x00008000
|
||||
#define DM_BiasCoords 0x00080000
|
||||
#define DM_ColorDiffuse 0x00100000
|
||||
#define DM_ColorSpecular 0x00200000
|
||||
#define DM_FlatShadingMethod 0x00400000
|
||||
|
||||
/* PointMode */
|
||||
#define PM_AntialiasDisable 0x00000000
|
||||
#define PM_AntialiasEnable 0x00000001
|
||||
#define PM_AntialiasQuality_4x4 0x00000000
|
||||
#define PM_AntialiasQuality_8x8 0x00000002
|
||||
|
||||
/* LogicalOpMode */
|
||||
#define LogicalOpModeDisable 0x00000000
|
||||
#define LogicalOpModeEnable 0x00000001
|
||||
#define LogicalOpModeMask 0x0000001e
|
||||
|
||||
/* LineMode */
|
||||
#define LM_StippleDisable 0x00000000
|
||||
#define LM_StippleEnable 0x00000001
|
||||
#define LM_RepeatFactorMask 0x000003fe
|
||||
#define LM_StippleMask 0x03fffc00
|
||||
#define LM_MirrorDisable 0x00000000
|
||||
#define LM_MirrorEnable 0x04000000
|
||||
#define LM_AntialiasDisable 0x00000000
|
||||
#define LM_AntialiasEnable 0x08000000
|
||||
#define LM_AntialiasQuality_4x4 0x00000000
|
||||
#define LM_AntialiasQuality_8x8 0x10000000
|
||||
|
||||
/* TriangleMode */
|
||||
#define TM_AntialiasDisable 0x00000000
|
||||
#define TM_AntialiasEnable 0x00000001
|
||||
#define TM_AntialiasQuality_4x4 0x00000000
|
||||
#define TM_AntialiasQuality_8x8 0x00000002
|
||||
#define TM_UseTriPacketInterface 0x00000004
|
||||
|
||||
/* TransformMode */
|
||||
#define XM_UseModelViewMatrix 0x00000001
|
||||
#define XM_UseModelViewProjMatrix 0x00000002
|
||||
#define XM_XformNormals 0x00000004
|
||||
#define XM_XformFaceNormals 0x00000008
|
||||
#define XM_XformTexture 0x00000010
|
||||
#define XM_XMask 0x00000013
|
||||
#define XM_TexGenModeS_None 0x00000000
|
||||
#define XM_TexGenModeS_ObjLinear 0x00000020
|
||||
#define XM_TexGenModeS_EyeLinear 0x00000040
|
||||
#define XM_TexGenModeS_SphereMap 0x00000060
|
||||
#define XM_TexGenModeT_None 0x00000000
|
||||
#define XM_TexGenModeT_ObjLinear 0x00000080
|
||||
#define XM_TexGenModeT_EyeLinear 0x00000100
|
||||
#define XM_TexGenModeT_SphereMap 0x00000180
|
||||
#define XM_TexGenModeR_None 0x00000000
|
||||
#define XM_TexGenModeR_ObjLinear 0x00000200
|
||||
#define XM_TexGenModeR_EyeLinear 0x00000400
|
||||
#define XM_TexGenModeR_SphereMap 0x00000600
|
||||
#define XM_TexGenModeQ_None 0x00000000
|
||||
#define XM_TexGenModeQ_ObjLinear 0x00000800
|
||||
#define XM_TexGenModeQ_EyeLinear 0x00001000
|
||||
#define XM_TexGenModeQQSphereMap 0x00001800
|
||||
#define XM_TexGenS 0x00002000
|
||||
#define XM_TexGenT 0x00004000
|
||||
#define XM_TexGenR 0x00008000
|
||||
#define XM_TexGenQ 0x00010000
|
||||
|
||||
/* LightNMode */
|
||||
#define LNM_Off 0x00000000
|
||||
#define LNM_On 0x00000001
|
||||
/************** GAMMA FLAGS ***************/
|
||||
|
||||
#endif /* _GAMMA_REGS_H_ */
|
||||
@@ -1,221 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "main/context.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/imports.h"
|
||||
#include "main/mtypes.h"
|
||||
|
||||
#include "tnl/t_context.h"
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_macros.h"
|
||||
#include "gamma_tris.h"
|
||||
#include "gamma_vb.h"
|
||||
|
||||
|
||||
/* !! Should template this eventually !! */
|
||||
|
||||
static void gamma_emit( GLcontext *ctx, GLuint start, GLuint end)
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLfloat (*coord)[4];
|
||||
GLuint coord_stride;
|
||||
GLfloat (*col)[4];
|
||||
GLuint col_stride;
|
||||
int i;
|
||||
GLuint tc0_stride = 0;
|
||||
GLfloat (*tc0)[4] = 0;
|
||||
GLuint tc0_size = 0;
|
||||
|
||||
col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
|
||||
col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled) {
|
||||
tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0]->stride;
|
||||
tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0]->data;
|
||||
tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0]->size;
|
||||
coord = VB->ClipPtr->data;
|
||||
coord_stride = VB->ClipPtr->stride;
|
||||
} else {
|
||||
coord = VB->NdcPtr->data;
|
||||
coord_stride = VB->NdcPtr->stride;
|
||||
}
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 4) {
|
||||
for (i=start; i < end; i++) {
|
||||
CHECK_DMA_BUFFER(gmesa, 9);
|
||||
WRITEF(gmesa->buf, Tq4, tc0[i][3]);
|
||||
WRITEF(gmesa->buf, Tr4, tc0[i][2]);
|
||||
WRITEF(gmesa->buf, Tt4, tc0[i][0]);
|
||||
WRITEF(gmesa->buf, Ts4, tc0[i][1]);
|
||||
WRITE(gmesa->buf, PackedColor4, *(uint32_t*)col[i]);
|
||||
WRITEF(gmesa->buf, Vw, coord[i][3]);
|
||||
WRITEF(gmesa->buf, Vz, coord[i][2]);
|
||||
WRITEF(gmesa->buf, Vy, coord[i][1]);
|
||||
WRITEF(gmesa->buf, Vx4, coord[i][0]);
|
||||
}
|
||||
} else if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 2) {
|
||||
for (i=start; i < end; i++) {
|
||||
CHECK_DMA_BUFFER(gmesa, 7);
|
||||
WRITEF(gmesa->buf, Tt2, tc0[i][0]);
|
||||
WRITEF(gmesa->buf, Ts2, tc0[i][1]);
|
||||
WRITE(gmesa->buf, PackedColor4, *(uint32_t*)col[i]);
|
||||
WRITEF(gmesa->buf, Vw, coord[i][3]);
|
||||
WRITEF(gmesa->buf, Vz, coord[i][2]);
|
||||
WRITEF(gmesa->buf, Vy, coord[i][1]);
|
||||
WRITEF(gmesa->buf, Vx4, coord[i][0]);
|
||||
}
|
||||
} else {
|
||||
for (i=start; i < end; i++) {
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITE(gmesa->buf, PackedColor4, *(uint32_t*)col[i]);
|
||||
WRITEF(gmesa->buf, Vz, coord[i][2]);
|
||||
WRITEF(gmesa->buf, Vy, coord[i][1]);
|
||||
WRITEF(gmesa->buf, Vx3, coord[i][0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define HAVE_POINTS 1
|
||||
#define HAVE_LINES 1
|
||||
#define HAVE_LINE_STRIPS 1
|
||||
#define HAVE_TRIANGLES 1
|
||||
#define HAVE_TRI_STRIPS 1
|
||||
#define HAVE_TRI_STRIP_1 0
|
||||
#define HAVE_TRI_FANS 1
|
||||
#define HAVE_QUADS 1
|
||||
#define HAVE_QUAD_STRIPS 1
|
||||
#define HAVE_POLYGONS 1
|
||||
|
||||
#define HAVE_ELTS 0
|
||||
|
||||
|
||||
static const GLuint hw_prim[GL_POLYGON+1] = {
|
||||
B_PrimType_Points,
|
||||
B_PrimType_Lines,
|
||||
B_PrimType_LineLoop,
|
||||
B_PrimType_LineStrip,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_TriangleStrip,
|
||||
B_PrimType_TriangleFan,
|
||||
B_PrimType_Quads,
|
||||
B_PrimType_QuadStrip,
|
||||
B_PrimType_Polygon
|
||||
};
|
||||
|
||||
static INLINE void gammaStartPrimitive( gammaContextPtr gmesa, GLenum prim )
|
||||
{
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, gmesa->Begin | hw_prim[prim]);
|
||||
}
|
||||
|
||||
static INLINE void gammaEndPrimitive( gammaContextPtr gmesa )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
|
||||
if ( ctx->Line.SmoothFlag ||
|
||||
ctx->Polygon.SmoothFlag ||
|
||||
ctx->Point.SmoothFlag ) {
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
}
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
#define LOCAL_VARS gammaContextPtr gmesa = GAMMA_CONTEXT(ctx)
|
||||
#define INIT( prim ) gammaStartPrimitive( gmesa, prim )
|
||||
#define FLUSH() gammaEndPrimitive( gmesa )
|
||||
#define GET_CURRENT_VB_MAX_VERTS() \
|
||||
(gmesa->bufSize - gmesa->bufCount) / 2
|
||||
#define GET_SUBSEQUENT_VB_MAX_VERTS() \
|
||||
GAMMA_DMA_BUFFER_SIZE / 2
|
||||
|
||||
#define ALLOC_VERTS( nr ) (void *)0 /* todo: explicit alloc */
|
||||
#define EMIT_VERTS( ctx, j, nr, buf ) (gamma_emit(ctx, j, (j)+(nr)), (void *)0)
|
||||
|
||||
#define TAG(x) gamma_##x
|
||||
#include "tnl_dd/t_dd_dmatmp.h"
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render pipeline stage */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
static GLboolean gamma_run_render( GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i;
|
||||
tnl_render_func *tab;
|
||||
|
||||
/* GH: THIS IS A HACK!!! */
|
||||
if (VB->ClipOrMask || gmesa->RenderIndex != 0)
|
||||
return GL_TRUE; /* don't handle clipping here */
|
||||
|
||||
/* We don't do elts */
|
||||
if (VB->Elts || !gamma_validate_render( ctx, VB ))
|
||||
return GL_TRUE;
|
||||
|
||||
tab = TAG(render_tab_verts);
|
||||
|
||||
tnl->Driver.Render.Start( ctx );
|
||||
|
||||
for (i = 0 ; i < VB->PrimitiveCount ; i++)
|
||||
{
|
||||
GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
|
||||
GLuint start = VB->Primitive[i].start;
|
||||
GLuint length = VB->Primitive[i].count;
|
||||
|
||||
if (!length)
|
||||
continue;
|
||||
|
||||
tab[prim & PRIM_MODE_MASK]( ctx, start, start + length, prim);
|
||||
}
|
||||
|
||||
tnl->Driver.Render.Finish( ctx );
|
||||
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
|
||||
|
||||
const struct tnl_pipeline_stage _gamma_render_stage =
|
||||
{
|
||||
"gamma render",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
gamma_run_render /* run */
|
||||
};
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "glint_dri.h"
|
||||
|
||||
#include "main/imports.h"
|
||||
|
||||
gammaScreenPtr gammaCreateScreen( __DRIscreen *sPriv )
|
||||
{
|
||||
gammaScreenPtr gammaScreen;
|
||||
GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)sPriv->pDevPriv;
|
||||
int i;
|
||||
|
||||
if (sPriv->devPrivSize != sizeof(GLINTDRIRec)) {
|
||||
fprintf(stderr,"\nERROR! sizeof(GLINTDRIRec) does not match passed size from device driver\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Check the DRI externsion version */
|
||||
if ( sPriv->driMajor != 3 || sPriv->driMinor != 1 ) {
|
||||
__driUtilMessage( "Gamma DRI driver expected DRI version 4.0.x "
|
||||
"but got version %d.%d.%d",
|
||||
sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check that the DDX driver version is compatible */
|
||||
if ( sPriv->ddxMajor != 4 ||
|
||||
sPriv->ddxMinor != 0 ||
|
||||
sPriv->ddxPatch < 0 ) {
|
||||
__driUtilMessage( "r128 DRI driver expected DDX driver version 4.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Check that the DRM driver version is compatible */
|
||||
if ( sPriv->drmMajor != 2 ||
|
||||
sPriv->drmMinor != 1 ||
|
||||
sPriv->drmPatch < 0 ) {
|
||||
__driUtilMessage( "r128 DRI driver expected DRM driver version 2.1.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
|
||||
return GL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate the private area */
|
||||
gammaScreen = (gammaScreenPtr) CALLOC( sizeof(*gammaScreen) );
|
||||
if ( !gammaScreen ) return NULL;
|
||||
|
||||
gammaScreen->regionCount = 4; /* Magic number. Can we fix this? */
|
||||
|
||||
gammaScreen->regions = CALLOC(gammaScreen->regionCount *
|
||||
sizeof(gammaRegion));
|
||||
|
||||
gammaScreen->regions[0].handle = gDRIPriv->registers0.handle;
|
||||
gammaScreen->regions[0].size = gDRIPriv->registers0.size;
|
||||
gammaScreen->regions[1].handle = gDRIPriv->registers1.handle;
|
||||
gammaScreen->regions[1].size = gDRIPriv->registers1.size;
|
||||
gammaScreen->regions[2].handle = gDRIPriv->registers2.handle;
|
||||
gammaScreen->regions[2].size = gDRIPriv->registers2.size;
|
||||
gammaScreen->regions[3].handle = gDRIPriv->registers3.handle;
|
||||
gammaScreen->regions[3].size = gDRIPriv->registers3.size;
|
||||
|
||||
/* Next, map all the regions */
|
||||
for (i = 0; i < gammaScreen->regionCount; i++) {
|
||||
if (drmMap(sPriv->fd,
|
||||
gammaScreen->regions[i].handle,
|
||||
gammaScreen->regions[i].size,
|
||||
&gammaScreen->regions[i].map)) {
|
||||
while (--i > 0) {
|
||||
(void)drmUnmap(gammaScreen->regions[i].map,
|
||||
gammaScreen->regions[i].size);
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the list of dma buffers */
|
||||
gammaScreen->bufs = drmMapBufs(sPriv->fd);
|
||||
|
||||
if (!gammaScreen->bufs) {
|
||||
while (gammaScreen->regionCount > 0) {
|
||||
(void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map,
|
||||
gammaScreen->regions[gammaScreen->regionCount].size);
|
||||
gammaScreen->regionCount--;
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
gammaScreen->textureSize = gDRIPriv->textureSize;
|
||||
gammaScreen->logTextureGranularity = gDRIPriv->logTextureGranularity;
|
||||
gammaScreen->cpp = gDRIPriv->cpp;
|
||||
gammaScreen->frontOffset = gDRIPriv->frontOffset;
|
||||
gammaScreen->frontPitch = gDRIPriv->frontPitch;
|
||||
gammaScreen->backOffset = gDRIPriv->backOffset;
|
||||
gammaScreen->backPitch = gDRIPriv->backPitch;
|
||||
gammaScreen->backX = gDRIPriv->backX;
|
||||
gammaScreen->backY = gDRIPriv->backY;
|
||||
gammaScreen->depthOffset = gDRIPriv->depthOffset;
|
||||
gammaScreen->depthPitch = gDRIPriv->depthPitch;
|
||||
|
||||
gammaScreen->driScreen = sPriv;
|
||||
|
||||
return gammaScreen;
|
||||
}
|
||||
|
||||
/* Destroy the device specific screen private data struct.
|
||||
*/
|
||||
void gammaDestroyScreen( __DRIscreen *sPriv )
|
||||
{
|
||||
gammaScreenPtr gammaScreen = (gammaScreenPtr)sPriv->private;
|
||||
|
||||
/* First, unmap the dma buffers */
|
||||
drmUnmapBufs( gammaScreen->bufs );
|
||||
|
||||
/* Next, unmap all the regions */
|
||||
while (gammaScreen->regionCount > 0) {
|
||||
(void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map,
|
||||
gammaScreen->regions[gammaScreen->regionCount].size);
|
||||
gammaScreen->regionCount--;
|
||||
}
|
||||
FREE(gammaScreen->regions);
|
||||
FREE(gammaScreen);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
typedef struct _gammaRegion {
|
||||
drm_handle_t handle;
|
||||
drmSize size;
|
||||
drmAddress map;
|
||||
} gammaRegion, *gammaRegionPtr;
|
||||
|
||||
typedef struct {
|
||||
|
||||
int regionCount; /* Count of register regions */
|
||||
gammaRegion *regions; /* Vector of mapped region info */
|
||||
|
||||
drmBufMapPtr bufs; /* Map of DMA buffers */
|
||||
|
||||
__DRIscreen *driScreen; /* Back pointer to DRI screen */
|
||||
|
||||
int cpp;
|
||||
int frontPitch;
|
||||
int frontOffset;
|
||||
|
||||
int backPitch;
|
||||
int backOffset;
|
||||
int backX;
|
||||
int backY;
|
||||
|
||||
int depthOffset;
|
||||
int depthPitch;
|
||||
|
||||
int textureSize;
|
||||
int logTextureGranularity;
|
||||
} gammaScreenRec, *gammaScreenPtr;
|
||||
@@ -1,315 +0,0 @@
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_lock.h"
|
||||
#include "gamma_macros.h"
|
||||
#include "main/colormac.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define DBG 0
|
||||
|
||||
#define LOCAL_VARS \
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
|
||||
gammaScreenPtr gammascrn = gmesa->gammaScreen; \
|
||||
__DRIscreen *sPriv = gmesa->driScreen; \
|
||||
__DRIdrawable *dPriv = gmesa->driDrawable; \
|
||||
GLuint pitch = sPriv->fbWidth * gammascrn->cpp; \
|
||||
GLuint height = dPriv->h; \
|
||||
char *buf = (char *)(sPriv->pFB + \
|
||||
gmesa->drawOffset + \
|
||||
(dPriv->x * gammascrn->cpp) + \
|
||||
(dPriv->y * pitch)); \
|
||||
GLuint p; \
|
||||
(void) buf; (void) p
|
||||
|
||||
/* FIXME! Depth/Stencil read/writes don't work ! */
|
||||
#define LOCAL_DEPTH_VARS \
|
||||
gammaScreenPtr gammascrn = gmesa->gammaScreen; \
|
||||
__DRIdrawable *dPriv = gmesa->driDrawable; \
|
||||
__DRIscreen *sPriv = gmesa->driScreen; \
|
||||
GLuint pitch = gammascrn->depthPitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
char *buf = (char *)(sPriv->pFB + \
|
||||
gammascrn->depthOffset + \
|
||||
dPriv->x * gammascrn->cpp + \
|
||||
dPriv->y * pitch)
|
||||
|
||||
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
|
||||
|
||||
#define Y_FLIP( _y ) (height - _y - 1)
|
||||
|
||||
#define HW_LOCK() \
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
|
||||
FLUSH_DMA_BUFFER(gmesa); \
|
||||
gammaGetLock( gmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); \
|
||||
GAMMAHW_LOCK( gmesa );
|
||||
|
||||
#define HW_UNLOCK() GAMMAHW_UNLOCK( gmesa )
|
||||
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Color buffer
|
||||
*/
|
||||
|
||||
/* 16 bit, RGB565 color spanline and pixel functions
|
||||
*/
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = PACK_COLOR_565( color[0], color[1], color[2] )
|
||||
|
||||
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
|
||||
*(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \
|
||||
(((int)g & 0xfc) << 3) | \
|
||||
(((int)b & 0xf8) >> 3))
|
||||
|
||||
#define WRITE_PIXEL( _x, _y, p ) \
|
||||
*(GLushort *)(buf + _x*2 + _y*pitch) = p
|
||||
|
||||
#define READ_RGBA( rgba, _x, _y ) \
|
||||
do { \
|
||||
GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \
|
||||
rgba[0] = (p >> 8) & 0xf8; \
|
||||
rgba[1] = (p >> 3) & 0xfc; \
|
||||
rgba[2] = (p << 3) & 0xf8; \
|
||||
rgba[3] = 0xff; \
|
||||
if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \
|
||||
if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \
|
||||
if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; \
|
||||
} while (0)
|
||||
|
||||
#define TAG(x) gamma##x##_RGB565
|
||||
#include "spantmp.h"
|
||||
|
||||
|
||||
/* 32 bit, ARGB8888 color spanline and pixel functions
|
||||
*/
|
||||
|
||||
#undef INIT_MONO_PIXEL
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
|
||||
|
||||
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
|
||||
*(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
|
||||
(g << 8) | \
|
||||
(r << 16) | \
|
||||
(a << 24) )
|
||||
|
||||
#define WRITE_PIXEL( _x, _y, p ) \
|
||||
*(GLuint *)(buf + _x*4 + _y*pitch) = p
|
||||
|
||||
#define READ_RGBA( rgba, _x, _y ) \
|
||||
do { \
|
||||
GLuint p = *(GLuint *)(buf + _x*4 + _y*pitch); \
|
||||
rgba[0] = (p >> 16) & 0xff; \
|
||||
rgba[1] = (p >> 8) & 0xff; \
|
||||
rgba[2] = (p >> 0) & 0xff; \
|
||||
rgba[3] = (p >> 24) & 0xff; \
|
||||
} while (0)
|
||||
|
||||
#define TAG(x) gamma##x##_ARGB8888
|
||||
#include "spantmp.h"
|
||||
|
||||
|
||||
/* 16 bit depthbuffer functions.
|
||||
*/
|
||||
#define VALUE_TYPE GLushort
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
|
||||
|
||||
#define TAG(x) gamma##x##_16
|
||||
#include "depthtmp.h"
|
||||
|
||||
|
||||
#if 0 /* Unused */
|
||||
/* 32 bit depthbuffer functions.
|
||||
*/
|
||||
#define VALUE_TYPE GLuint
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLuint *)(buf + (_x)*4 + (_y)*pitch) = d;
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch);
|
||||
|
||||
#define TAG(x) gamma##x##_32
|
||||
#include "depthtmp.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* 24/8 bit interleaved depth/stencil functions
|
||||
*/
|
||||
#define VALUE_TYPE GLuint
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) { \
|
||||
GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \
|
||||
tmp &= 0xff; \
|
||||
tmp |= (d) & 0xffffff00; \
|
||||
*(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \
|
||||
}
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch) & ~0xff;
|
||||
|
||||
|
||||
#define TAG(x) gamma##x##_24_8
|
||||
#include "depthtmp.h"
|
||||
|
||||
#if 0
|
||||
#define WRITE_STENCIL( _x, _y, d ) { \
|
||||
GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
|
||||
tmp &= 0xffffff00; \
|
||||
tmp |= d & 0xff; \
|
||||
*(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
|
||||
}
|
||||
|
||||
#define READ_STENCIL( d, _x, _y ) \
|
||||
d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff;
|
||||
|
||||
#define TAG(x) gamma##x##_24_8
|
||||
#include "stenciltmp.h"
|
||||
|
||||
static void gammaReadRGBASpan8888( const GLcontext *ctx,
|
||||
GLuint n, GLint x, GLint y,
|
||||
GLubyte rgba[][4])
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
gammaScreenPtr gammascrn = gmesa->gammaScreen;
|
||||
uint32_t dwords1, dwords2, i = 0;
|
||||
char *src = (char *)rgba[0];
|
||||
GLuint read = n * gammascrn->cpp; /* Number of bytes we are expecting */
|
||||
uint32_t data;
|
||||
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode & ~(LBReadSrcEnable | LBReadDstEnable));
|
||||
WRITE(gmesa->buf, ColorDDAMode, ColorDDAEnable);
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable);
|
||||
WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode & ~FBReadSrcEnable) | FBReadDstEnable | FBDataTypeColor);
|
||||
WRITE(gmesa->buf, FilterMode, 0x200); /* Pass FBColorData */
|
||||
WRITE(gmesa->buf, FBWriteMode, FBW_UploadColorData | FBWriteModeDisable);
|
||||
WRITE(gmesa->buf, StartXSub, (x+n)<<16);
|
||||
WRITE(gmesa->buf, StartXDom, x<<16);
|
||||
WRITE(gmesa->buf, StartY, y<<16);
|
||||
WRITE(gmesa->buf, GLINTCount, 1);
|
||||
WRITE(gmesa->buf, dXDom, 0<<16);
|
||||
WRITE(gmesa->buf, dXSub, 0<<16);
|
||||
WRITE(gmesa->buf, dY, 1<<16);
|
||||
WRITE(gmesa->buf, Render, PrimitiveTrapezoid);
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
|
||||
moredata:
|
||||
|
||||
dwords1 = *(volatile uint32_t*)(void *)(((uint8_t*)gammascrn->regions[0].map) + (GlintOutFIFOWords));
|
||||
dwords2 = *(volatile uint32_t*)(void *)(((uint8_t*)gammascrn->regions[2].map) + (GlintOutFIFOWords));
|
||||
|
||||
if (dwords1) {
|
||||
memcpy(src, (char*)gammascrn->regions[1].map + 0x1000, dwords1 << 2);
|
||||
src += dwords1 << 2;
|
||||
read -= dwords1 << 2;
|
||||
}
|
||||
if (dwords2) {
|
||||
memcpy(src, (char*)gammascrn->regions[3].map + 0x1000, dwords2 << 2);
|
||||
src += dwords2 << 2;
|
||||
read -= dwords2 << 2;
|
||||
}
|
||||
|
||||
if (read)
|
||||
goto moredata;
|
||||
|
||||
done:
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
|
||||
WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
|
||||
WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
|
||||
WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
|
||||
WRITE(gmesa->buf, FilterMode, 0x400);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gammaSetBuffer( GLcontext *ctx,
|
||||
GLframebuffer *colorBuffer,
|
||||
GLuint bufferBit )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
|
||||
switch ( bufferBit ) {
|
||||
case BUFFER_BIT_FRONT_LEFT:
|
||||
gmesa->readOffset = 0;
|
||||
break;
|
||||
case BUFFER_BIT_BACK_LEFT:
|
||||
gmesa->readOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(ctx, "Unexpected buffer 0x%x in gammaSetBuffer()", bufferBit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gammaDDInitSpanFuncs( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
|
||||
|
||||
swdd->SetBuffer = gammaSetBuffer;
|
||||
|
||||
switch ( gmesa->gammaScreen->cpp ) {
|
||||
case 2:
|
||||
swdd->WriteRGBASpan = gammaWriteRGBASpan_RGB565;
|
||||
swdd->WriteRGBSpan = gammaWriteRGBSpan_RGB565;
|
||||
swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_RGB565;
|
||||
swdd->WriteRGBAPixels = gammaWriteRGBAPixels_RGB565;
|
||||
swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_RGB565;
|
||||
swdd->ReadRGBASpan = gammaReadRGBASpan_RGB565;
|
||||
swdd->ReadRGBAPixels = gammaReadRGBAPixels_RGB565;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
swdd->WriteRGBASpan = gammaWriteRGBASpan_ARGB8888;
|
||||
swdd->WriteRGBSpan = gammaWriteRGBSpan_ARGB8888;
|
||||
swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_ARGB8888;
|
||||
swdd->WriteRGBAPixels = gammaWriteRGBAPixels_ARGB8888;
|
||||
swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_ARGB8888;
|
||||
#if 1
|
||||
swdd->ReadRGBASpan = gammaReadRGBASpan_ARGB8888;
|
||||
#else
|
||||
swdd->ReadRGBASpan = gammaReadRGBASpan8888;
|
||||
#endif
|
||||
swdd->ReadRGBAPixels = gammaReadRGBAPixels_ARGB8888;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( gmesa->glCtx->Visual.depthBits ) {
|
||||
case 16:
|
||||
swdd->ReadDepthSpan = gammaReadDepthSpan_16;
|
||||
swdd->WriteDepthSpan = gammaWriteDepthSpan_16;
|
||||
swdd->ReadDepthPixels = gammaReadDepthPixels_16;
|
||||
swdd->WriteDepthPixels = gammaWriteDepthPixels_16;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
swdd->ReadDepthSpan = gammaReadDepthSpan_24_8;
|
||||
swdd->WriteDepthSpan = gammaWriteDepthSpan_24_8;
|
||||
swdd->ReadDepthPixels = gammaReadDepthPixels_24_8;
|
||||
swdd->WriteDepthPixels = gammaWriteDepthPixels_24_8;
|
||||
|
||||
#if 0
|
||||
swdd->ReadStencilSpan = gammaReadStencilSpan_24_8;
|
||||
swdd->WriteStencilSpan = gammaWriteStencilSpan_24_8;
|
||||
swdd->ReadStencilPixels = gammaReadStencilPixels_24_8;
|
||||
swdd->WriteStencilPixels = gammaWriteStencilPixels_24_8;
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,434 +0,0 @@
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "main/colormac.h"
|
||||
#include "main/imports.h"
|
||||
#include "main/simple_list.h"
|
||||
#include "main/enums.h"
|
||||
#include "main/mm.h"
|
||||
#include "main/texstore.h"
|
||||
#include "main/teximage.h"
|
||||
#include "main/texobj.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#include "gamma_context.h"
|
||||
|
||||
|
||||
/*
|
||||
* Compute the 'S2.4' lod bias factor from the floating point OpenGL bias.
|
||||
*/
|
||||
#if 0
|
||||
static GLuint gammaComputeLodBias(GLfloat bias)
|
||||
{
|
||||
return bias;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gammaSetTexWrapping(gammaTextureObjectPtr t,
|
||||
GLenum wraps, GLenum wrapt)
|
||||
{
|
||||
uint32_t t1 = t->TextureAddressMode;
|
||||
uint32_t t2 = t->TextureReadMode;
|
||||
|
||||
t1 &= ~(TAM_SWrap_Mask | TAM_TWrap_Mask);
|
||||
t2 &= ~(TRM_UWrap_Mask | TRM_VWrap_Mask);
|
||||
|
||||
if (wraps != GL_CLAMP) {
|
||||
t1 |= TAM_SWrap_Repeat;
|
||||
t2 |= TRM_UWrap_Repeat;
|
||||
}
|
||||
|
||||
if (wrapt != GL_CLAMP) {
|
||||
t1 |= TAM_TWrap_Repeat;
|
||||
t2 |= TRM_VWrap_Repeat;
|
||||
}
|
||||
|
||||
t->TextureAddressMode = t1;
|
||||
t->TextureReadMode = t2;
|
||||
}
|
||||
|
||||
|
||||
static void gammaSetTexFilter(gammaContextPtr gmesa,
|
||||
gammaTextureObjectPtr t,
|
||||
GLenum minf, GLenum magf,
|
||||
GLfloat bias)
|
||||
{
|
||||
uint32_t t1 = t->TextureAddressMode;
|
||||
uint32_t t2 = t->TextureReadMode;
|
||||
|
||||
t2 &= ~(TRM_Mag_Mask | TRM_Min_Mask);
|
||||
|
||||
switch (minf) {
|
||||
case GL_NEAREST:
|
||||
t1 &= ~TAM_LODEnable;
|
||||
t2 &= ~TRM_MipMapEnable;
|
||||
t2 |= TRM_Min_Nearest;
|
||||
break;
|
||||
case GL_LINEAR:
|
||||
t1 &= ~TAM_LODEnable;
|
||||
t2 &= ~TRM_MipMapEnable;
|
||||
t2 |= TRM_Min_Linear;
|
||||
break;
|
||||
case GL_NEAREST_MIPMAP_NEAREST:
|
||||
t2 |= TRM_Min_NearestMMNearest;
|
||||
break;
|
||||
case GL_LINEAR_MIPMAP_NEAREST:
|
||||
t2 |= TRM_Min_LinearMMNearest;
|
||||
break;
|
||||
case GL_NEAREST_MIPMAP_LINEAR:
|
||||
t2 |= TRM_Min_NearestMMLinear;
|
||||
break;
|
||||
case GL_LINEAR_MIPMAP_LINEAR:
|
||||
t2 |= TRM_Min_LinearMMLinear;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (magf) {
|
||||
case GL_NEAREST:
|
||||
t2 |= TRM_Mag_Nearest;
|
||||
break;
|
||||
case GL_LINEAR:
|
||||
t2 |= TRM_Mag_Linear;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
t->TextureAddressMode = t1;
|
||||
t->TextureReadMode = t2;
|
||||
}
|
||||
|
||||
|
||||
static void gammaSetTexBorderColor(gammaContextPtr gmesa,
|
||||
gammaTextureObjectPtr t,
|
||||
const GLfloat color[4])
|
||||
{
|
||||
GLubyte c[4];
|
||||
CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
|
||||
t->TextureBorderColor = PACK_COLOR_8888(c[0], c[1], c[2], c[3]);
|
||||
}
|
||||
|
||||
|
||||
static void gammaTexParameter( GLcontext *ctx, GLenum target,
|
||||
struct gl_texture_object *tObj,
|
||||
GLenum pname, const GLfloat *params )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
|
||||
if (!t)
|
||||
return;
|
||||
|
||||
/* Can't do the update now as we don't know whether to flush
|
||||
* vertices or not. Setting gmesa->new_state means that
|
||||
* gammaUpdateTextureState() will be called before any triangles are
|
||||
* rendered. If a statechange has occurred, it will be detected at
|
||||
* that point, and buffered vertices flushed.
|
||||
*/
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_MIN_FILTER:
|
||||
case GL_TEXTURE_MAG_FILTER:
|
||||
{
|
||||
GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
|
||||
gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_WRAP_S:
|
||||
case GL_TEXTURE_WRAP_T:
|
||||
gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_BORDER_COLOR:
|
||||
gammaSetTexBorderColor( gmesa, t, tObj->BorderColor.f );
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_BASE_LEVEL:
|
||||
case GL_TEXTURE_MAX_LEVEL:
|
||||
case GL_TEXTURE_MIN_LOD:
|
||||
case GL_TEXTURE_MAX_LOD:
|
||||
/* This isn't the most efficient solution but there doesn't appear to
|
||||
* be a nice alternative for Radeon. Since there's no LOD clamping,
|
||||
* we just have to rely on loading the right subset of mipmap levels
|
||||
* to simulate a clamped LOD.
|
||||
*/
|
||||
gammaSwapOutTexObj( gmesa, t );
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (t == gmesa->CurrentTexObj[0])
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX0;
|
||||
|
||||
#if 0
|
||||
if (t == gmesa->CurrentTexObj[1]) {
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void gammaTexEnv( GLcontext *ctx, GLenum target,
|
||||
GLenum pname, const GLfloat *param )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
GLuint unit = ctx->Texture.CurrentUnit;
|
||||
|
||||
/* Only one env color. Need a fallback if env colors are different
|
||||
* and texture setup references env color in both units.
|
||||
*/
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_ENV_COLOR: {
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||
GLfloat *fc = texUnit->EnvColor;
|
||||
GLuint r, g, b, a, col;
|
||||
CLAMPED_FLOAT_TO_UBYTE(r, fc[0]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(g, fc[1]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(b, fc[2]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(a, fc[3]);
|
||||
|
||||
col = ((a << 24) |
|
||||
(r << 16) |
|
||||
(g << 8) |
|
||||
(b << 0));
|
||||
|
||||
break;
|
||||
}
|
||||
case GL_TEXTURE_ENV_MODE:
|
||||
gmesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_LOD_BIAS_EXT:
|
||||
#if 0 /* ?!?!?! */
|
||||
{
|
||||
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
|
||||
(void) t;
|
||||
/* XXX Looks like there's something missing here */
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void gammaTexImage1D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint internalFormat,
|
||||
GLint width, GLint border,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *pack,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
|
||||
if (t) {
|
||||
gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
|
||||
}
|
||||
_mesa_store_teximage1d( ctx, target, level, internalFormat,
|
||||
width, border, format, type,
|
||||
pixels, pack, texObj, texImage );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void gammaTexSubImage1D( GLcontext *ctx,
|
||||
GLenum target,
|
||||
GLint level,
|
||||
GLint xoffset,
|
||||
GLsizei width,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *pack,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
|
||||
if (t) {
|
||||
gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
|
||||
}
|
||||
_mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
|
||||
format, type, pixels, pack, texObj,
|
||||
texImage);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gammaTexImage2D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint internalFormat,
|
||||
GLint width, GLint height, GLint border,
|
||||
GLenum format, GLenum type, const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
|
||||
if (t) {
|
||||
gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
|
||||
}
|
||||
_mesa_store_teximage2d( ctx, target, level, internalFormat,
|
||||
width, height, border, format, type,
|
||||
pixels, packing, texObj, texImage );
|
||||
}
|
||||
|
||||
static void gammaTexSubImage2D( GLcontext *ctx,
|
||||
GLenum target,
|
||||
GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
|
||||
if (t) {
|
||||
gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
|
||||
}
|
||||
_mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
|
||||
height, format, type, pixels, packing, texObj,
|
||||
texImage);
|
||||
}
|
||||
|
||||
static void gammaBindTexture( GLcontext *ctx, GLenum target,
|
||||
struct gl_texture_object *tObj )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
|
||||
|
||||
if (!t) {
|
||||
GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
|
||||
t = CALLOC_STRUCT(gamma_texture_object_t);
|
||||
|
||||
/* Initialize non-image-dependent parts of the state:
|
||||
*/
|
||||
t->globj = tObj;
|
||||
|
||||
t->TextureAddressMode = TextureAddressModeEnable | TAM_Operation_3D |
|
||||
TAM_DY_Enable | TAM_LODEnable;
|
||||
t->TextureReadMode = TextureReadModeEnable | TRM_PrimaryCacheEnable |
|
||||
TRM_MipMapEnable | TRM_BorderClamp | TRM_Border;
|
||||
t->TextureColorMode = TextureColorModeEnable;
|
||||
t->TextureFilterMode = TextureFilterModeEnable;
|
||||
|
||||
if (target == GL_TEXTURE_2D) {
|
||||
t->TextureAddressMode |= TAM_TexMapType_2D;
|
||||
t->TextureReadMode |= TRM_TexMapType_2D;
|
||||
}
|
||||
else if (target == GL_TEXTURE_1D) {
|
||||
t->TextureAddressMode |= TAM_TexMapType_1D;
|
||||
t->TextureReadMode |= TRM_TexMapType_1D;
|
||||
}
|
||||
|
||||
t->TextureColorMode = TextureColorModeEnable;
|
||||
|
||||
t->TextureFilterMode = TextureFilterModeEnable;
|
||||
|
||||
#ifdef MESA_LITTLE_ENDIAN
|
||||
t->TextureFormat = (TF_LittleEndian |
|
||||
#else
|
||||
t->TextureFormat = (TF_BigEndian |
|
||||
#endif
|
||||
TF_ColorOrder_RGB |
|
||||
TF_OutputFmt_Texel);
|
||||
|
||||
t->dirty_images = ~0;
|
||||
|
||||
tObj->DriverData = t;
|
||||
make_empty_list( t );
|
||||
|
||||
gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
|
||||
gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
|
||||
gammaSetTexBorderColor( gmesa, t, tObj->BorderColor.f );
|
||||
}
|
||||
}
|
||||
|
||||
static void gammaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
|
||||
|
||||
if (t) {
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
#if 0
|
||||
if (gmesa)
|
||||
GAMMA_FIREVERTICES( gmesa );
|
||||
#endif
|
||||
gammaDestroyTexObj( gmesa, t );
|
||||
tObj->DriverData = 0;
|
||||
}
|
||||
/* Free mipmap images and the texture object itself */
|
||||
_mesa_delete_texture_object(ctx, tObj);
|
||||
}
|
||||
|
||||
static GLboolean gammaIsTextureResident( GLcontext *ctx,
|
||||
struct gl_texture_object *tObj )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
|
||||
return t && t->MemBlock;
|
||||
}
|
||||
|
||||
#ifdef UNUSED
|
||||
/**
|
||||
* Allocate a new texture object.
|
||||
* Called via ctx->Driver.NewTextureObject.
|
||||
* Note: this function will be called during context creation to
|
||||
* allocate the default texture objects.
|
||||
* Note: we could use containment here to 'derive' the driver-specific
|
||||
* texture object from the core mesa gl_texture_object. Not done at this time.
|
||||
*/
|
||||
static struct gl_texture_object *
|
||||
gammaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
|
||||
{
|
||||
struct gl_texture_object *obj;
|
||||
obj = _mesa_new_texture_object(ctx, name, target);
|
||||
return obj;
|
||||
}
|
||||
#endif
|
||||
|
||||
void gammaInitTextureObjects( GLcontext *ctx )
|
||||
{
|
||||
struct gl_texture_object *texObj;
|
||||
GLuint tmp = ctx->Texture.CurrentUnit;
|
||||
|
||||
ctx->Texture.CurrentUnit = 0;
|
||||
|
||||
texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_1D_INDEX];
|
||||
gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
|
||||
|
||||
texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];
|
||||
gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
|
||||
|
||||
#if 0
|
||||
ctx->Texture.CurrentUnit = 1;
|
||||
|
||||
texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_1D_INDEX];
|
||||
gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
|
||||
|
||||
texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_2D_INDEX];
|
||||
gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
|
||||
#endif
|
||||
|
||||
ctx->Texture.CurrentUnit = tmp;
|
||||
}
|
||||
|
||||
|
||||
void gammaDDInitTextureFuncs( struct dd_function_table *functions )
|
||||
{
|
||||
functions->TexEnv = gammaTexEnv;
|
||||
functions->TexImage2D = gammaTexImage2D;
|
||||
functions->TexSubImage2D = gammaTexSubImage2D;
|
||||
functions->BindTexture = gammaBindTexture;
|
||||
functions->DeleteTexture = gammaDeleteTexture;
|
||||
functions->TexParameter = gammaTexParameter;
|
||||
functions->IsTextureResident = gammaIsTextureResident;
|
||||
}
|
||||
@@ -1,535 +0,0 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "main/colormac.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "main/simple_list.h"
|
||||
#include "main/enums.h"
|
||||
|
||||
#include "main/mm.h"
|
||||
#include "glint_dri.h"
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_lock.h"
|
||||
#include "gamma_macros.h"
|
||||
|
||||
void gammaDestroyTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t)
|
||||
{
|
||||
if (!t) return;
|
||||
|
||||
/* This is sad - need to sync *in case* we upload a texture
|
||||
* to this newly free memory...
|
||||
*/
|
||||
if (t->MemBlock) {
|
||||
mmFreeMem(t->MemBlock);
|
||||
t->MemBlock = 0;
|
||||
|
||||
if (gmesa && t->age > gmesa->dirtyAge)
|
||||
gmesa->dirtyAge = t->age;
|
||||
}
|
||||
|
||||
if (t->globj)
|
||||
t->globj->DriverData = 0;
|
||||
|
||||
if (gmesa) {
|
||||
if (gmesa->CurrentTexObj[0] == t) {
|
||||
gmesa->CurrentTexObj[0] = 0;
|
||||
gmesa->dirty &= ~GAMMA_UPLOAD_TEX0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (gmesa->CurrentTexObj[1] == t) {
|
||||
gmesa->CurrentTexObj[1] = 0;
|
||||
gmesa->dirty &= ~GAMMA_UPLOAD_TEX1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
remove_from_list(t);
|
||||
free(t);
|
||||
}
|
||||
|
||||
|
||||
void gammaSwapOutTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t)
|
||||
{
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
if (t->MemBlock) {
|
||||
mmFreeMem(t->MemBlock);
|
||||
t->MemBlock = 0;
|
||||
|
||||
if (t->age > gmesa->dirtyAge)
|
||||
gmesa->dirtyAge = t->age;
|
||||
}
|
||||
|
||||
t->dirty_images = ~0;
|
||||
move_to_tail(&(gmesa->SwappedOut), t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Upload an image from mesa's internal copy.
|
||||
*/
|
||||
static void gammaUploadTexLevel( gammaContextPtr gmesa, gammaTextureObjectPtr t, int level )
|
||||
{
|
||||
const struct gl_texture_image *image = t->image[level].image;
|
||||
int i,j;
|
||||
int l2d;
|
||||
#if 0
|
||||
int offset = 0;
|
||||
#endif
|
||||
int words, depthLog2;
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
l2d = 5; /* 32bits per texel == 1<<5 */
|
||||
|
||||
if (level == 0) {
|
||||
t->TextureAddressMode &= ~(TAM_WidthMask | TAM_HeightMask);
|
||||
t->TextureAddressMode |= (image->WidthLog2 << 9) |
|
||||
(image->HeightLog2 << 13);
|
||||
t->TextureReadMode &= ~(TRM_WidthMask | TRM_HeightMask |
|
||||
TRM_DepthMask | TRM_Border |
|
||||
TRM_Patch);
|
||||
t->TextureReadMode |= (image->WidthLog2 << 1) |
|
||||
(image->HeightLog2 << 5) |
|
||||
(l2d << 9);
|
||||
t->TextureFormat &= ~(TF_CompnentsMask | TF_OneCompFmt_Mask);
|
||||
}
|
||||
|
||||
t->TextureBaseAddr[level] = /* ??? */
|
||||
(unsigned long)(t->image[level].offset + t->BufAddr) << 5;
|
||||
|
||||
CALC_LOG2(depthLog2, 1<<l2d);
|
||||
words = (image->Width * image->Height) >> (5-depthLog2);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 3);
|
||||
WRITE(gmesa->buf, LBWindowBase, t->TextureBaseAddr[level] >> 5);
|
||||
WRITE(gmesa->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));
|
||||
WRITE(gmesa->buf, WaitForCompletion, 0);
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
|
||||
switch (t->image[level].internalFormat) {
|
||||
case GL_RGB:
|
||||
case 3:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_3;
|
||||
|
||||
#if 0 /* This is the texture download code we SHOULD be using */
|
||||
/* In the routines below, but this causes an DMA overrun - WHY ? */
|
||||
while (offset < words) {
|
||||
int count = gmesa->bufSize;
|
||||
int i;
|
||||
count -= 3;
|
||||
if (count > words-offset) count = words-offset;
|
||||
|
||||
gmesa->buf->i = GlintTextureDownloadOffsetTag;
|
||||
gmesa->buf++;
|
||||
gmesa->buf->i = offset;
|
||||
gmesa->buf++;
|
||||
gmesa->buf->i = (GlintTextureDataTag | ((count-1) << 16));
|
||||
gmesa->buf++;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
gmesa->buf->i = PACK_COLOR_565(src[0],src[1],src[2]);
|
||||
gmesa->buf++;
|
||||
src += 3;
|
||||
}
|
||||
|
||||
gmesa->bufCount = count+3; /* texture data + 3 values */
|
||||
offset += count;
|
||||
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
#else
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_565(src[0],src[1],src[2]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src += 3;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_RGBA:
|
||||
case 4:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_4;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_8888(src[0],src[1],src[2],src[3]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src += 4;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_LUMINANCE:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Lum;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_888(src[0],src[0],src[0]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src ++;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_INTENSITY:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Intensity;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_8888(src[0],src[0],src[0],src[0]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src ++;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_2;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_8888(src[0],src[0],src[0],src[1]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src += 2;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_ALPHA:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Alpha;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_8888(255,255,255,src[0]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src += 1;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
/* TODO: Translate color indices *now*:
|
||||
*/
|
||||
case GL_COLOR_INDEX:
|
||||
{
|
||||
GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
|
||||
for (i = 0 ; i < image->Width ; i++) {
|
||||
dst[i] = src[0];
|
||||
src += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Not supported texture format %s\n",
|
||||
_mesa_lookup_enum_by_nr(image->Format));
|
||||
}
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITE(gmesa->buf, WaitForCompletion, 0);
|
||||
WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase);
|
||||
}
|
||||
|
||||
void gammaPrintLocalLRU( gammaContextPtr gmesa )
|
||||
{
|
||||
gammaTextureObjectPtr t;
|
||||
int sz = 1 << (gmesa->gammaScreen->logTextureGranularity);
|
||||
|
||||
foreach( t, &gmesa->TexObjList ) {
|
||||
if (!t->globj)
|
||||
fprintf(stderr, "Placeholder %d at %x sz %x\n",
|
||||
t->MemBlock->ofs / sz,
|
||||
t->MemBlock->ofs,
|
||||
t->MemBlock->size);
|
||||
else
|
||||
fprintf(stderr, "Texture at %x sz %x\n",
|
||||
t->MemBlock->ofs,
|
||||
t->MemBlock->size);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void gammaPrintGlobalLRU( gammaContextPtr gmesa )
|
||||
{
|
||||
int i, j;
|
||||
GAMMATextureRegionPtr list = gmesa->sarea->texList;
|
||||
|
||||
for (i = 0, j = GAMMA_NR_TEX_REGIONS ; i < GAMMA_NR_TEX_REGIONS ; i++) {
|
||||
fprintf(stderr, "list[%d] age %d next %d prev %d\n",
|
||||
j, list[j].age, list[j].next, list[j].prev);
|
||||
j = list[j].next;
|
||||
if (j == GAMMA_NR_TEX_REGIONS) break;
|
||||
}
|
||||
|
||||
if (j != GAMMA_NR_TEX_REGIONS)
|
||||
fprintf(stderr, "Loop detected in global LRU\n");
|
||||
}
|
||||
|
||||
|
||||
void gammaResetGlobalLRU( gammaContextPtr gmesa )
|
||||
{
|
||||
GAMMATextureRegionPtr list = gmesa->sarea->texList;
|
||||
int sz = 1 << gmesa->gammaScreen->logTextureGranularity;
|
||||
int i;
|
||||
|
||||
/* (Re)initialize the global circular LRU list. The last element
|
||||
* in the array (GAMMA_NR_TEX_REGIONS) is the sentinal. Keeping it
|
||||
* at the end of the array allows it to be addressed rationally
|
||||
* when looking up objects at a particular location in texture
|
||||
* memory.
|
||||
*/
|
||||
for (i = 0 ; (i+1) * sz <= gmesa->gammaScreen->textureSize ; i++) {
|
||||
list[i].prev = i-1;
|
||||
list[i].next = i+1;
|
||||
list[i].age = 0;
|
||||
}
|
||||
|
||||
i--;
|
||||
list[0].prev = GAMMA_NR_TEX_REGIONS;
|
||||
list[i].prev = i-1;
|
||||
list[i].next = GAMMA_NR_TEX_REGIONS;
|
||||
list[GAMMA_NR_TEX_REGIONS].prev = i;
|
||||
list[GAMMA_NR_TEX_REGIONS].next = 0;
|
||||
gmesa->sarea->texAge = 0;
|
||||
}
|
||||
|
||||
|
||||
void gammaUpdateTexLRU( gammaContextPtr gmesa, gammaTextureObjectPtr t )
|
||||
{
|
||||
int i;
|
||||
int logsz = gmesa->gammaScreen->logTextureGranularity;
|
||||
int start = t->MemBlock->ofs >> logsz;
|
||||
int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
|
||||
GAMMATextureRegionPtr list = gmesa->sarea->texList;
|
||||
|
||||
gmesa->texAge = ++gmesa->sarea->texAge;
|
||||
|
||||
/* Update our local LRU
|
||||
*/
|
||||
move_to_head( &(gmesa->TexObjList), t );
|
||||
|
||||
/* Update the global LRU
|
||||
*/
|
||||
for (i = start ; i <= end ; i++) {
|
||||
|
||||
list[i].in_use = 1;
|
||||
list[i].age = gmesa->texAge;
|
||||
|
||||
/* remove_from_list(i)
|
||||
*/
|
||||
list[(unsigned)list[i].next].prev = list[i].prev;
|
||||
list[(unsigned)list[i].prev].next = list[i].next;
|
||||
|
||||
/* insert_at_head(list, i)
|
||||
*/
|
||||
list[i].prev = GAMMA_NR_TEX_REGIONS;
|
||||
list[i].next = list[GAMMA_NR_TEX_REGIONS].next;
|
||||
list[(unsigned)list[GAMMA_NR_TEX_REGIONS].next].prev = i;
|
||||
list[GAMMA_NR_TEX_REGIONS].next = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Called for every shared texture region which has increased in age
|
||||
* since we last held the lock.
|
||||
*
|
||||
* Figures out which of our textures have been ejected by other clients,
|
||||
* and pushes a placeholder texture onto the LRU list to represent
|
||||
* the other client's textures.
|
||||
*/
|
||||
void gammaTexturesGone( gammaContextPtr gmesa,
|
||||
GLuint offset,
|
||||
GLuint size,
|
||||
GLuint in_use )
|
||||
{
|
||||
gammaTextureObjectPtr t, tmp;
|
||||
|
||||
foreach_s ( t, tmp, &gmesa->TexObjList ) {
|
||||
|
||||
if (t->MemBlock->ofs >= offset + size ||
|
||||
t->MemBlock->ofs + t->MemBlock->size <= offset)
|
||||
continue;
|
||||
|
||||
/* It overlaps - kick it off. Need to hold onto the currently bound
|
||||
* objects, however.
|
||||
*/
|
||||
gammaSwapOutTexObj( gmesa, t );
|
||||
}
|
||||
|
||||
if (in_use) {
|
||||
t = (gammaTextureObjectPtr) calloc(1,sizeof(*t));
|
||||
if (!t) return;
|
||||
|
||||
t->MemBlock = mmAllocMem( gmesa->texHeap, size, 0, offset);
|
||||
insert_at_head( &gmesa->TexObjList, t );
|
||||
}
|
||||
|
||||
/* Reload any lost textures referenced by current vertex buffer.
|
||||
*/
|
||||
#if 0
|
||||
if (gmesa->vertex_buffer) {
|
||||
int i, j;
|
||||
|
||||
fprintf(stderr, "\n\nreload tex\n");
|
||||
|
||||
for (i = 0 ; i < gmesa->statenr ; i++) {
|
||||
for (j = 0 ; j < 2 ; j++) {
|
||||
gammaTextureObjectPtr t = gmesa->state_tex[j][i];
|
||||
if (t) {
|
||||
if (t->MemBlock == 0)
|
||||
gammaUploadTexImages( gmesa, t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Hard to do this with the lock held:
|
||||
*/
|
||||
/* GAMMA_FIREVERTICES( gmesa ); */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* This is called with the lock held. May have to eject our own and/or
|
||||
* other client's texture objects to make room for the upload.
|
||||
*/
|
||||
void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t )
|
||||
{
|
||||
int i;
|
||||
int ofs;
|
||||
int numLevels;
|
||||
|
||||
/* /fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
#if 0
|
||||
LOCK_HARDWARE( gmesa );
|
||||
#endif
|
||||
|
||||
/* Do we need to eject LRU texture objects?
|
||||
*/
|
||||
if (!t->MemBlock) {
|
||||
while (1)
|
||||
{
|
||||
t->MemBlock = mmAllocMem( gmesa->texHeap, t->totalSize, 12, 0 );
|
||||
if (t->MemBlock)
|
||||
break;
|
||||
|
||||
if (gmesa->TexObjList.prev == gmesa->CurrentTexObj[0] ||
|
||||
gmesa->TexObjList.prev == gmesa->CurrentTexObj[1]) {
|
||||
fprintf(stderr, "Hit bound texture in upload\n");
|
||||
gammaPrintLocalLRU( gmesa );
|
||||
return;
|
||||
}
|
||||
|
||||
if (gmesa->TexObjList.prev == &(gmesa->TexObjList)) {
|
||||
fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
|
||||
mmDumpMemInfo( gmesa->texHeap );
|
||||
return;
|
||||
}
|
||||
|
||||
gammaSwapOutTexObj( gmesa, gmesa->TexObjList.prev );
|
||||
}
|
||||
|
||||
ofs = t->MemBlock->ofs;
|
||||
t->BufAddr = (char *)(unsigned long)(gmesa->LBWindowBase + ofs); /* ??? */
|
||||
|
||||
if (t == gmesa->CurrentTexObj[0])
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX0;
|
||||
|
||||
#if 0
|
||||
if (t == gmesa->CurrentTexObj[1])
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX1;
|
||||
#endif
|
||||
|
||||
gammaUpdateTexLRU( gmesa, t );
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (gmesa->dirtyAge >= GET_DISPATCH_AGE(gmesa))
|
||||
gammaWaitAgeLocked( gmesa, gmesa->dirtyAge );
|
||||
#endif
|
||||
|
||||
numLevels = t->lastLevel - t->firstLevel + 1;
|
||||
for (i = 0 ; i < numLevels ; i++)
|
||||
if (t->dirty_images & (1<<i))
|
||||
gammaUploadTexLevel( gmesa, t, i );
|
||||
|
||||
t->dirty_images = 0;
|
||||
|
||||
#if 0
|
||||
UNLOCK_HARDWARE( gmesa );
|
||||
#endif
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "main/simple_list.h"
|
||||
#include "main/enums.h"
|
||||
|
||||
#include "main/mm.h"
|
||||
#include "gamma_context.h"
|
||||
|
||||
static void gammaSetTexImages( gammaContextPtr gmesa,
|
||||
struct gl_texture_object *tObj )
|
||||
{
|
||||
GLuint height, width, pitch, i, log_pitch;
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
|
||||
const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
|
||||
GLint firstLevel, lastLevel, numLevels;
|
||||
GLint log2Width, log2Height;
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
t->texelBytes = 2;
|
||||
|
||||
/* Compute which mipmap levels we really want to send to the hardware.
|
||||
* This depends on the base image size, GL_TEXTURE_MIN_LOD,
|
||||
* GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
|
||||
* Yes, this looks overly complicated, but it's all needed.
|
||||
*/
|
||||
if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) {
|
||||
firstLevel = lastLevel = tObj->BaseLevel;
|
||||
}
|
||||
else {
|
||||
firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
|
||||
firstLevel = MAX2(firstLevel, tObj->BaseLevel);
|
||||
lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
|
||||
lastLevel = MAX2(lastLevel, tObj->BaseLevel);
|
||||
lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
|
||||
lastLevel = MIN2(lastLevel, tObj->MaxLevel);
|
||||
lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
|
||||
}
|
||||
|
||||
/* save these values */
|
||||
t->firstLevel = firstLevel;
|
||||
t->lastLevel = lastLevel;
|
||||
|
||||
numLevels = lastLevel - firstLevel + 1;
|
||||
|
||||
log2Width = tObj->Image[0][firstLevel]->WidthLog2;
|
||||
log2Height = tObj->Image[0][firstLevel]->HeightLog2;
|
||||
|
||||
|
||||
/* Figure out the amount of memory required to hold all the mipmap
|
||||
* levels. Choose the smallest pitch to accomodate the largest
|
||||
* mipmap:
|
||||
*/
|
||||
width = tObj->Image[0][firstLevel]->Width * t->texelBytes;
|
||||
for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
|
||||
log_pitch++;
|
||||
|
||||
/* All images must be loaded at this pitch. Count the number of
|
||||
* lines required:
|
||||
*/
|
||||
for ( height = i = 0 ; i < numLevels ; i++ ) {
|
||||
t->image[i].image = tObj->Image[0][firstLevel + i];
|
||||
t->image[i].offset = height * pitch;
|
||||
t->image[i].internalFormat = baseImage->Format;
|
||||
height += t->image[i].image->Height;
|
||||
t->TextureBaseAddr[i] = /* ??? */
|
||||
(unsigned long)(t->image[i].offset + t->BufAddr) << 5;
|
||||
|
||||
}
|
||||
|
||||
t->Pitch = pitch;
|
||||
t->totalSize = height*pitch;
|
||||
t->max_level = i-1;
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* | GAMMA_UPLOAD_TEX1*/;
|
||||
|
||||
gammaUploadTexImages( gmesa, t );
|
||||
}
|
||||
|
||||
static void gammaUpdateTexEnv( GLcontext *ctx, GLuint unit )
|
||||
{
|
||||
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||
const struct gl_texture_object *tObj = texUnit->_Current;
|
||||
const GLuint format = tObj->Image[0][tObj->BaseLevel]->Format;
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
|
||||
GLuint tc;
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
tc = t->TextureColorMode & ~(TCM_BaseFormatMask | TCM_ApplicationMask);
|
||||
|
||||
switch (format) {
|
||||
case GL_RGB:
|
||||
tc |= TCM_BaseFormat_RGB;
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
tc |= TCM_BaseFormat_Lum;
|
||||
break;
|
||||
case GL_ALPHA:
|
||||
tc |= TCM_BaseFormat_Alpha;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
tc |= TCM_BaseFormat_LumAlpha;
|
||||
break;
|
||||
case GL_INTENSITY:
|
||||
tc |= TCM_BaseFormat_Intensity;
|
||||
break;
|
||||
case GL_RGBA:
|
||||
tc |= TCM_BaseFormat_RGBA;
|
||||
break;
|
||||
case GL_COLOR_INDEX:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (texUnit->EnvMode) {
|
||||
case GL_REPLACE:
|
||||
tc |= TCM_Replace;
|
||||
break;
|
||||
case GL_MODULATE:
|
||||
tc |= TCM_Modulate;
|
||||
break;
|
||||
case GL_ADD:
|
||||
/* do nothing ???*/
|
||||
break;
|
||||
case GL_DECAL:
|
||||
tc |= TCM_Decal;
|
||||
break;
|
||||
case GL_BLEND:
|
||||
tc |= TCM_Blend;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unknown tex env mode");
|
||||
return;
|
||||
}
|
||||
|
||||
t->TextureColorMode = tc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void gammaUpdateTexUnit( GLcontext *ctx, GLuint unit )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT)
|
||||
{
|
||||
struct gl_texture_object *tObj = texUnit->_Current;
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
|
||||
|
||||
/* Upload teximages (not pipelined)
|
||||
*/
|
||||
if (t->dirty_images) {
|
||||
gammaSetTexImages( gmesa, tObj );
|
||||
if (!t->MemBlock) {
|
||||
FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (tObj->Image[0][tObj->BaseLevel]->Border > 0) {
|
||||
FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Update state if this is a different texture object to last
|
||||
* time.
|
||||
*/
|
||||
if (gmesa->CurrentTexObj[unit] != t) {
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* << unit */;
|
||||
gmesa->CurrentTexObj[unit] = t;
|
||||
gammaUpdateTexLRU( gmesa, t ); /* done too often */
|
||||
}
|
||||
|
||||
/* Update texture environment if texture object image format or
|
||||
* texture environment state has changed.
|
||||
*/
|
||||
if (tObj->Image[0][tObj->BaseLevel]->Format != gmesa->TexEnvImageFmt[unit]) {
|
||||
gmesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->Format;
|
||||
gammaUpdateTexEnv( ctx, unit );
|
||||
}
|
||||
}
|
||||
else if (texUnit->_ReallyEnabled) {
|
||||
FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
|
||||
}
|
||||
else /*if (gmesa->CurrentTexObj[unit])*/ {
|
||||
gmesa->CurrentTexObj[unit] = 0;
|
||||
gmesa->TexEnvImageFmt[unit] = 0;
|
||||
gmesa->dirty &= ~(GAMMA_UPLOAD_TEX0<<unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gammaUpdateTextureState( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_FALSE );
|
||||
gammaUpdateTexUnit( ctx, 0 );
|
||||
#if 0
|
||||
gammaUpdateTexUnit( ctx, 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,660 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
* Keith Whitwell, <keith@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*/
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_macros.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "gamma_tris.h"
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/colormac.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Build hardware rasterization functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define GAMMA_RAST_ALPHA_BIT 0x01
|
||||
#define GAMMA_RAST_TEX_BIT 0x02
|
||||
#define GAMMA_RAST_FLAT_BIT 0x04
|
||||
|
||||
static gamma_point_func gamma_point_tab[0x8];
|
||||
static gamma_line_func gamma_line_tab[0x8];
|
||||
static gamma_tri_func gamma_tri_tab[0x8];
|
||||
static gamma_quad_func gamma_quad_tab[0x8];
|
||||
|
||||
#define IND (0)
|
||||
#define TAG(x) x
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_ALPHA_BIT)
|
||||
#define TAG(x) x##_alpha
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_TEX_BIT)
|
||||
#define TAG(x) x##_tex
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT)
|
||||
#define TAG(x) x##_alpha_tex
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_FLAT_BIT)
|
||||
#define TAG(x) x##_flat
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_FLAT_BIT)
|
||||
#define TAG(x) x##_alpha_flat
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT)
|
||||
#define TAG(x) x##_tex_flat
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT)
|
||||
#define TAG(x) x##_alpha_tex_flat
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
|
||||
static void init_rast_tab( void )
|
||||
{
|
||||
gamma_init();
|
||||
gamma_init_alpha();
|
||||
gamma_init_tex();
|
||||
gamma_init_alpha_tex();
|
||||
gamma_init_flat();
|
||||
gamma_init_alpha_flat();
|
||||
gamma_init_tex_flat();
|
||||
gamma_init_alpha_tex_flat();
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Rasterization fallback helpers *
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
/* This code is hit only when a mix of accelerated and unaccelerated
|
||||
* primitives are being drawn, and only for the unaccelerated
|
||||
* primitives.
|
||||
*/
|
||||
static void
|
||||
gamma_fallback_quad( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1,
|
||||
const gammaVertex *v2,
|
||||
const gammaVertex *v3 )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
SWvertex v[4];
|
||||
gamma_translate_vertex( ctx, v0, &v[0] );
|
||||
gamma_translate_vertex( ctx, v1, &v[1] );
|
||||
gamma_translate_vertex( ctx, v2, &v[2] );
|
||||
gamma_translate_vertex( ctx, v3, &v[3] );
|
||||
_swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] );
|
||||
}
|
||||
|
||||
static void
|
||||
gamma_fallback_tri( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1,
|
||||
const gammaVertex *v2 )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
SWvertex v[3];
|
||||
gamma_translate_vertex( ctx, v0, &v[0] );
|
||||
gamma_translate_vertex( ctx, v1, &v[1] );
|
||||
gamma_translate_vertex( ctx, v2, &v[2] );
|
||||
_swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
|
||||
}
|
||||
|
||||
static void
|
||||
gamma_fallback_line( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1 )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
SWvertex v[2];
|
||||
gamma_translate_vertex( ctx, v0, &v[0] );
|
||||
gamma_translate_vertex( ctx, v1, &v[1] );
|
||||
_swrast_Line( ctx, &v[0], &v[1] );
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void
|
||||
gamma_fallback_point( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0 )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
SWvertex v[1];
|
||||
gamma_translate_vertex( ctx, v0, &v[0] );
|
||||
_swrast_Point( ctx, &v[0] );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Choose rasterization functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define _GAMMA_NEW_RASTER_STATE (_NEW_FOG | \
|
||||
_NEW_TEXTURE | \
|
||||
_DD_NEW_TRI_SMOOTH | \
|
||||
_DD_NEW_LINE_SMOOTH | \
|
||||
_DD_NEW_POINT_SMOOTH | \
|
||||
_DD_NEW_TRI_STIPPLE | \
|
||||
_DD_NEW_LINE_STIPPLE)
|
||||
|
||||
#define LINE_FALLBACK (0)
|
||||
#define TRI_FALLBACK (0)
|
||||
|
||||
static void gammaChooseRasterState(GLcontext *ctx)
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
GLuint ind = 0;
|
||||
|
||||
if ( ctx->Line.SmoothFlag ||
|
||||
ctx->Polygon.SmoothFlag ||
|
||||
ctx->Point.SmoothFlag )
|
||||
gmesa->Begin |= B_AntiAliasEnable;
|
||||
else
|
||||
gmesa->Begin &= ~B_AntiAliasEnable;
|
||||
|
||||
if ( ctx->Texture.Unit[0]._ReallyEnabled ) {
|
||||
ind |= GAMMA_RAST_TEX_BIT;
|
||||
gmesa->Begin |= B_TextureEnable;
|
||||
} else
|
||||
gmesa->Begin &= ~B_TextureEnable;
|
||||
|
||||
if (flags & DD_LINE_STIPPLE)
|
||||
gmesa->Begin |= B_LineStippleEnable;
|
||||
else
|
||||
gmesa->Begin &= ~B_LineStippleEnable;
|
||||
|
||||
if (flags & DD_TRI_STIPPLE)
|
||||
gmesa->Begin |= B_AreaStippleEnable;
|
||||
else
|
||||
gmesa->Begin &= ~B_AreaStippleEnable;
|
||||
|
||||
if (ctx->Fog.Enabled)
|
||||
gmesa->Begin |= B_FogEnable;
|
||||
else
|
||||
gmesa->Begin &= ~B_FogEnable;
|
||||
|
||||
if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
|
||||
ind |= GAMMA_RAST_ALPHA_BIT;
|
||||
|
||||
if ( flags & DD_FLATSHADE )
|
||||
ind |= GAMMA_RAST_FLAT_BIT;
|
||||
|
||||
gmesa->draw_line = gamma_line_tab[ind];
|
||||
gmesa->draw_tri = gamma_tri_tab[ind];
|
||||
gmesa->draw_quad = gamma_quad_tab[ind];
|
||||
gmesa->draw_point = gamma_point_tab[ind];
|
||||
|
||||
/* Hook in fallbacks for specific primitives. CURRENTLY DISABLED
|
||||
*/
|
||||
if (flags & LINE_FALLBACK)
|
||||
gmesa->draw_line = gamma_fallback_line;
|
||||
|
||||
if (flags & TRI_FALLBACK) {
|
||||
gmesa->draw_tri = gamma_fallback_tri;
|
||||
gmesa->draw_quad = gamma_fallback_quad;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Macros for t_dd_tritmp.h to draw basic primitives *
|
||||
***********************************************************************/
|
||||
|
||||
#define TRI( a, b, c ) \
|
||||
do { \
|
||||
gmesa->draw_tri( gmesa, a, b, c ); \
|
||||
} while (0)
|
||||
|
||||
#define QUAD( a, b, c, d ) \
|
||||
do { \
|
||||
gmesa->draw_quad( gmesa, a, b, c, d ); \
|
||||
} while (0)
|
||||
|
||||
#define LINE( v0, v1 ) \
|
||||
do { \
|
||||
gmesa->draw_line( gmesa, v0, v1 ); \
|
||||
} while (0)
|
||||
|
||||
#define POINT( v0 ) \
|
||||
do { \
|
||||
gmesa->draw_point( gmesa, v0 ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Build render functions from dd templates *
|
||||
***********************************************************************/
|
||||
|
||||
#define GAMMA_OFFSET_BIT 0x01
|
||||
#define GAMMA_TWOSIDE_BIT 0x02
|
||||
#define GAMMA_UNFILLED_BIT 0x04
|
||||
#define GAMMA_FALLBACK_BIT 0x08
|
||||
#define GAMMA_MAX_TRIFUNC 0x10
|
||||
|
||||
|
||||
static struct {
|
||||
tnl_points_func points;
|
||||
tnl_line_func line;
|
||||
tnl_triangle_func triangle;
|
||||
tnl_quad_func quad;
|
||||
} rast_tab[GAMMA_MAX_TRIFUNC];
|
||||
|
||||
|
||||
#define DO_FALLBACK (IND & GAMMA_FALLBACK_BIT)
|
||||
#define DO_OFFSET 0 /* (IND & GAMMA_OFFSET_BIT) */
|
||||
#define DO_UNFILLED 0 /* (IND & GAMMA_UNFILLED_BIT) */
|
||||
#define DO_TWOSIDE (IND & GAMMA_TWOSIDE_BIT)
|
||||
#define DO_FLAT 0
|
||||
#define DO_TRI 1
|
||||
#define DO_QUAD 1
|
||||
#define DO_LINE 1
|
||||
#define DO_POINTS 1
|
||||
#define DO_FULL_QUAD 1
|
||||
|
||||
#define HAVE_RGBA 1
|
||||
#define HAVE_SPEC 0
|
||||
#define HAVE_BACK_COLORS 0
|
||||
#define HAVE_HW_FLATSHADE 1
|
||||
#define VERTEX gammaVertex
|
||||
#define TAB rast_tab
|
||||
|
||||
#define DEPTH_SCALE 1.0
|
||||
#define UNFILLED_TRI unfilled_tri
|
||||
#define UNFILLED_QUAD unfilled_quad
|
||||
#define VERT_X(_v) _v->v.x
|
||||
#define VERT_Y(_v) _v->v.y
|
||||
#define VERT_Z(_v) _v->v.z
|
||||
#define AREA_IS_CCW( a ) (a > 0)
|
||||
#define GET_VERTEX(e) (gmesa->verts + (e * gmesa->vertex_size * sizeof(int)))
|
||||
|
||||
#define VERT_SET_RGBA( v, c ) \
|
||||
do { \
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][0], (c)[0]); \
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][1], (c)[1]); \
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][2], (c)[2]); \
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][3], (c)[3]); \
|
||||
} while (0)
|
||||
#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
|
||||
#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
|
||||
#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
|
||||
|
||||
#define LOCAL_VARS(n) \
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
|
||||
GLuint color[n] = { 0 }; \
|
||||
(void) color;
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Helpers for rendering unfilled primitives *
|
||||
***********************************************************************/
|
||||
|
||||
static const GLuint hw_prim[GL_POLYGON+1] = {
|
||||
B_PrimType_Points,
|
||||
B_PrimType_Lines,
|
||||
B_PrimType_Lines,
|
||||
B_PrimType_Lines,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles
|
||||
};
|
||||
|
||||
static void gammaResetLineStipple( GLcontext *ctx );
|
||||
static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim );
|
||||
static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim );
|
||||
|
||||
#define RASTERIZE(x) if (gmesa->hw_primitive != hw_prim[x]) \
|
||||
gammaRasterPrimitive( ctx, hw_prim[x] )
|
||||
#define RENDER_PRIMITIVE gmesa->render_primitive
|
||||
#define TAG(x) x
|
||||
#define IND GAMMA_FALLBACK_BIT
|
||||
#include "tnl_dd/t_dd_unfilled.h"
|
||||
#undef IND
|
||||
|
||||
/***********************************************************************
|
||||
* Generate GL render functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define IND (0)
|
||||
#define TAG(x) x
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_OFFSET_BIT)
|
||||
#define TAG(x) x##_offset
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_TWOSIDE_BIT)
|
||||
#define TAG(x) x##_twoside
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT)
|
||||
#define TAG(x) x##_twoside_offset
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_UNFILLED_BIT)
|
||||
#define TAG(x) x##_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)
|
||||
#define TAG(x) x##_offset_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_TWOSIDE_BIT|GAMMA_UNFILLED_BIT)
|
||||
#define TAG(x) x##_twoside_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)
|
||||
#define TAG(x) x##_twoside_offset_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
|
||||
|
||||
static void init_render_tab( void )
|
||||
{
|
||||
init();
|
||||
init_offset();
|
||||
init_twoside();
|
||||
init_twoside_offset();
|
||||
init_unfilled();
|
||||
init_offset_unfilled();
|
||||
init_twoside_unfilled();
|
||||
init_twoside_offset_unfilled();
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render unclipped begin/end objects */
|
||||
/**********************************************************************/
|
||||
|
||||
#define VERT(x) (gammaVertex *)(gammaverts + (x * size * sizeof(int)))
|
||||
#define RENDER_POINTS( start, count ) \
|
||||
for ( ; start < count ; start++) \
|
||||
gmesa->draw_point( gmesa, VERT(start) )
|
||||
#define RENDER_LINE( v0, v1 ) \
|
||||
gmesa->draw_line( gmesa, VERT(v0), VERT(v1) )
|
||||
#define RENDER_TRI( v0, v1, v2 ) \
|
||||
gmesa->draw_tri( gmesa, VERT(v0), VERT(v1), VERT(v2) )
|
||||
#define RENDER_QUAD( v0, v1, v2, v3 ) \
|
||||
gmesa->draw_quad( gmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
|
||||
#define INIT(x) gammaRenderPrimitive( ctx, x );
|
||||
#undef LOCAL_VARS
|
||||
#define LOCAL_VARS \
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
|
||||
const GLuint size = gmesa->vertex_size; \
|
||||
const char *gammaverts = (char *)gmesa->verts; \
|
||||
const GLboolean stipple = ctx->Line.StippleFlag; \
|
||||
(void) stipple;
|
||||
#define RESET_STIPPLE if ( stipple ) gammaResetLineStipple( ctx );
|
||||
#define RESET_OCCLUSION
|
||||
#define PRESERVE_VB_DEFS
|
||||
#define ELT(x) (x)
|
||||
#define TAG(x) gamma_##x##_verts
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render clipped primitives */
|
||||
/**********************************************************************/
|
||||
|
||||
static void gammaRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
|
||||
GLuint n )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint prim = gmesa->render_primitive;
|
||||
|
||||
/* Render the new vertices as an unclipped polygon.
|
||||
*/
|
||||
{
|
||||
GLuint *tmp = VB->Elts;
|
||||
VB->Elts = (GLuint *)elts;
|
||||
tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
|
||||
VB->Elts = tmp;
|
||||
}
|
||||
|
||||
/* Restore the render primitive
|
||||
*/
|
||||
if (prim != GL_POLYGON)
|
||||
tnl->Driver.Render.PrimitiveNotify( ctx, prim );
|
||||
}
|
||||
|
||||
static void gammaRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.Render.Line( ctx, ii, jj );
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Choose render functions */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
|
||||
#define _GAMMA_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED | \
|
||||
_DD_NEW_TRI_LIGHT_TWOSIDE | \
|
||||
_DD_NEW_TRI_OFFSET)
|
||||
|
||||
#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
|
||||
|
||||
static void gammaChooseRenderState(GLcontext *ctx)
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
GLuint index = 0;
|
||||
|
||||
if (flags & ANY_RASTER_FLAGS) {
|
||||
if (flags & DD_TRI_LIGHT_TWOSIDE) index |= GAMMA_TWOSIDE_BIT;
|
||||
if (flags & DD_TRI_OFFSET) index |= GAMMA_OFFSET_BIT;
|
||||
if (flags & DD_TRI_UNFILLED) index |= GAMMA_UNFILLED_BIT;
|
||||
}
|
||||
|
||||
if (gmesa->RenderIndex != index) {
|
||||
gmesa->RenderIndex = index;
|
||||
|
||||
tnl->Driver.Render.Points = rast_tab[index].points;
|
||||
tnl->Driver.Render.Line = rast_tab[index].line;
|
||||
tnl->Driver.Render.Triangle = rast_tab[index].triangle;
|
||||
tnl->Driver.Render.Quad = rast_tab[index].quad;
|
||||
|
||||
if (gmesa->RenderIndex == 0)
|
||||
tnl->Driver.Render.PrimTabVerts = gamma_render_tab_verts;
|
||||
else
|
||||
tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
|
||||
tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
|
||||
tnl->Driver.Render.ClippedLine = gammaRenderClippedLine;
|
||||
tnl->Driver.Render.ClippedPolygon = gammaRenderClippedPoly;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* High level hooks for t_vb_render.c */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Determine the rasterized primitive when not drawing unfilled
|
||||
* polygons.
|
||||
*
|
||||
* Used only for the default render stage which always decomposes
|
||||
* primitives to trianges/lines/points. For the accelerated stage,
|
||||
* which renders strips as strips, the equivalent calculations are
|
||||
* performed in gammarender.c.
|
||||
*/
|
||||
|
||||
static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
if (gmesa->hw_primitive != hwprim)
|
||||
gmesa->hw_primitive = hwprim;
|
||||
}
|
||||
|
||||
static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
gmesa->render_primitive = prim;
|
||||
}
|
||||
|
||||
static void gammaRunPipeline( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
|
||||
if ( gmesa->new_state )
|
||||
gammaDDUpdateHWState( ctx );
|
||||
|
||||
if (gmesa->new_gl_state) {
|
||||
if (gmesa->new_gl_state & _NEW_TEXTURE)
|
||||
gammaUpdateTextureState( ctx );
|
||||
|
||||
if (!gmesa->Fallback) {
|
||||
if (gmesa->new_gl_state & _GAMMA_NEW_VERTEX)
|
||||
gammaChooseVertexState( ctx );
|
||||
|
||||
if (gmesa->new_gl_state & _GAMMA_NEW_RASTER_STATE)
|
||||
gammaChooseRasterState( ctx );
|
||||
|
||||
if (gmesa->new_gl_state & _GAMMA_NEW_RENDERSTATE)
|
||||
gammaChooseRenderState( ctx );
|
||||
}
|
||||
|
||||
gmesa->new_gl_state = 0;
|
||||
}
|
||||
|
||||
_tnl_run_pipeline( ctx );
|
||||
}
|
||||
|
||||
static void gammaRenderStart( GLcontext *ctx )
|
||||
{
|
||||
/* Check for projective texturing. Make sure all texcoord
|
||||
* pointers point to something. (fix in mesa?)
|
||||
*/
|
||||
gammaCheckTexSizes( ctx );
|
||||
}
|
||||
|
||||
static void gammaRenderFinish( GLcontext *ctx )
|
||||
{
|
||||
if (0)
|
||||
_swrast_flush( ctx ); /* never needed */
|
||||
}
|
||||
|
||||
static void gammaResetLineStipple( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
|
||||
/* Reset the hardware stipple counter.
|
||||
*/
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, UpdateLineStippleCounters, 0);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Transition to/from hardware rasterization. */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint oldfallback = gmesa->Fallback;
|
||||
|
||||
if (mode) {
|
||||
gmesa->Fallback |= bit;
|
||||
if (oldfallback == 0) {
|
||||
_swsetup_Wakeup( ctx );
|
||||
_tnl_need_projected_coords( ctx, GL_TRUE );
|
||||
gmesa->RenderIndex = ~0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
gmesa->Fallback &= ~bit;
|
||||
if (oldfallback == bit) {
|
||||
_swrast_flush( ctx );
|
||||
tnl->Driver.Render.Start = gammaRenderStart;
|
||||
tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive;
|
||||
tnl->Driver.Render.Finish = gammaRenderFinish;
|
||||
tnl->Driver.Render.BuildVertices = gammaBuildVertices;
|
||||
tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple;
|
||||
gmesa->new_gl_state |= (_GAMMA_NEW_RENDERSTATE|
|
||||
_GAMMA_NEW_RASTER_STATE|
|
||||
_GAMMA_NEW_VERTEX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Initialization. */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
void gammaDDInitTriFuncs( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
static int firsttime = 1;
|
||||
|
||||
if (firsttime) {
|
||||
init_rast_tab();
|
||||
init_render_tab();
|
||||
firsttime = 0;
|
||||
}
|
||||
|
||||
gmesa->RenderIndex = ~0;
|
||||
|
||||
tnl->Driver.RunPipeline = gammaRunPipeline;
|
||||
tnl->Driver.Render.Start = gammaRenderStart;
|
||||
tnl->Driver.Render.Finish = gammaRenderFinish;
|
||||
tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive;
|
||||
tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple;
|
||||
tnl->Driver.Render.BuildVertices = gammaBuildVertices;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
* Keith Whitwell, <keith@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*/
|
||||
|
||||
#ifndef _GAMMA_TRIS_H
|
||||
#define _GAMMA_TRIS_H
|
||||
|
||||
extern void gammaDDTrifuncInit(void);
|
||||
extern void gammaDDChooseTriRenderState(GLcontext *);
|
||||
|
||||
|
||||
|
||||
#endif /* !(_GAMMA_TRIS_H) */
|
||||
@@ -1,496 +0,0 @@
|
||||
|
||||
static void TAG(gamma_point)( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0 )
|
||||
{
|
||||
uint32_t vColor;
|
||||
uint32_t vBegin;
|
||||
|
||||
vBegin = gmesa->Begin | B_PrimType_Points;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, vBegin);
|
||||
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v0->v.color.alpha << 24) |
|
||||
(v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v0->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v0->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
#endif
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
static void TAG(gamma_line)( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1 )
|
||||
{
|
||||
uint32_t vColor;
|
||||
uint32_t vBegin;
|
||||
|
||||
vBegin = gmesa->Begin | B_PrimType_Lines;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, vBegin);
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v0->v.color.alpha << 24) |
|
||||
(v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#else
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v1->v.color.alpha << 24) |
|
||||
(v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v0->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v0->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v1->v.color.alpha << 24) |
|
||||
(v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v1->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v1->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
#endif
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
static void TAG(gamma_triangle)( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1,
|
||||
const gammaVertex *v2 )
|
||||
{
|
||||
uint32_t vColor;
|
||||
uint32_t vBegin;
|
||||
|
||||
vBegin = gmesa->Begin | B_PrimType_Triangles;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, vBegin);
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v0->v.color.alpha << 24) |
|
||||
(v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#else
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v2->v.color.alpha << 24) |
|
||||
(v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v0->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v0->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v1->v.color.alpha << 24) |
|
||||
(v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v1->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v1->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v2->v.color.alpha << 24) |
|
||||
(v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v2->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v2->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v2->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v2->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v2->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v2->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v2->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v2->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v2->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v2->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
#endif
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
static void TAG(gamma_quad)( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1,
|
||||
const gammaVertex *v2,
|
||||
const gammaVertex *v3 )
|
||||
{
|
||||
uint32_t vColor;
|
||||
uint32_t vBegin;
|
||||
|
||||
vBegin = gmesa->Begin | B_PrimType_Quads;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, vBegin);
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v0->v.color.alpha << 24) |
|
||||
(v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#else
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v3->v.color.alpha << 24) |
|
||||
(v3->v.color.blue << 16) |
|
||||
(v3->v.color.green << 8) |
|
||||
(v3->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v3->v.color.blue << 16) |
|
||||
(v3->v.color.green << 8) |
|
||||
(v3->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v0->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v0->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v1->v.color.alpha << 24) |
|
||||
(v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v1->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v1->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v2->v.color.alpha << 24) |
|
||||
(v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v2->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v2->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v2->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v2->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v2->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v2->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v2->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v2->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v2->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v2->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v3->v.color.alpha << 24) |
|
||||
(v3->v.color.blue << 16) |
|
||||
(v3->v.color.green << 8) |
|
||||
(v3->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v3->v.color.blue << 16) |
|
||||
(v3->v.color.green << 8) |
|
||||
(v3->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v3->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v3->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v3->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v3->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v3->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v3->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v3->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v3->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v3->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v3->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
#endif
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
static void TAG(gamma_init)(void)
|
||||
{
|
||||
gamma_point_tab[IND] = TAG(gamma_point);
|
||||
gamma_line_tab[IND] = TAG(gamma_line);
|
||||
gamma_tri_tab[IND] = TAG(gamma_triangle);
|
||||
gamma_quad_tab[IND] = TAG(gamma_quad);
|
||||
}
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
||||
@@ -1,361 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
* Keith Whitwell, <keith@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*/
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "main/imports.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/colormac.h"
|
||||
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/tnl.h"
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "gamma_tris.h"
|
||||
|
||||
|
||||
#define GAMMA_TEX0_BIT 0x1
|
||||
#define GAMMA_RGBA_BIT 0x2
|
||||
#define GAMMA_XYZW_BIT 0x4
|
||||
#define GAMMA_PTEX_BIT 0x8
|
||||
#define GAMMA_FOG_BIT 0x10
|
||||
#define GAMMA_SPEC_BIT 0x20
|
||||
#define GAMMA_MAX_SETUP 0x40
|
||||
|
||||
static struct {
|
||||
void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
|
||||
tnl_interp_func interp;
|
||||
tnl_copy_pv_func copy_pv;
|
||||
GLboolean (*check_tex_sizes)( GLcontext *ctx );
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_format;
|
||||
} setup_tab[GAMMA_MAX_SETUP];
|
||||
|
||||
#define TINY_VERTEX_FORMAT 1
|
||||
#define NOTEX_VERTEX_FORMAT 2
|
||||
#define TEX0_VERTEX_FORMAT 3
|
||||
#define TEX1_VERTEX_FORMAT 0
|
||||
#define PROJ_TEX1_VERTEX_FORMAT 0
|
||||
#define TEX2_VERTEX_FORMAT 0
|
||||
#define TEX3_VERTEX_FORMAT 0
|
||||
#define PROJ_TEX3_VERTEX_FORMAT 0
|
||||
|
||||
#define DO_XYZW (IND & GAMMA_XYZW_BIT)
|
||||
#define DO_RGBA (IND & GAMMA_RGBA_BIT)
|
||||
#define DO_SPEC (IND & GAMMA_SPEC_BIT)
|
||||
#define DO_FOG (IND & GAMMA_FOG_BIT)
|
||||
#define DO_TEX0 (IND & GAMMA_TEX0_BIT)
|
||||
#define DO_TEX1 0
|
||||
#define DO_TEX2 0
|
||||
#define DO_TEX3 0
|
||||
#define DO_PTEX (IND & GAMMA_PTEX_BIT)
|
||||
|
||||
#define VERTEX gammaVertex
|
||||
#define VERTEX_COLOR gamma_color_t
|
||||
#define GET_VIEWPORT_MAT() 0
|
||||
#define GET_TEXSOURCE(n) n
|
||||
#define GET_VERTEX_FORMAT() GAMMA_CONTEXT(ctx)->vertex_format
|
||||
#define GET_VERTEX_STORE() GAMMA_CONTEXT(ctx)->verts
|
||||
#define GET_VERTEX_SIZE() GAMMA_CONTEXT(ctx)->vertex_size * sizeof(GLuint)
|
||||
#define INVALIDATE_STORED_VERTICES()
|
||||
|
||||
#define HAVE_HW_VIEWPORT 1
|
||||
#define HAVE_HW_DIVIDE 1
|
||||
#define HAVE_RGBA_COLOR 0 /* we're BGRA */
|
||||
#define HAVE_TINY_VERTICES 1
|
||||
#define HAVE_NOTEX_VERTICES 1
|
||||
#define HAVE_TEX0_VERTICES 1
|
||||
#define HAVE_TEX1_VERTICES 0
|
||||
#define HAVE_TEX2_VERTICES 0
|
||||
#define HAVE_TEX3_VERTICES 0
|
||||
#define HAVE_PTEX_VERTICES 1
|
||||
|
||||
#define PTEX_FALLBACK() /* never needed */
|
||||
|
||||
#define INTERP_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].interp
|
||||
#define COPY_PV_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].copy_pv
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Generate pv-copying and translation functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define TAG(x) gamma_##x
|
||||
#include "tnl_dd/t_dd_vb.c"
|
||||
|
||||
/***********************************************************************
|
||||
* Generate vertex emit and interp functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT)
|
||||
#define TAG(x) x##_wg
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT)
|
||||
#define TAG(x) x##_wgs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT|GAMMA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgpt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT|\
|
||||
GAMMA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgspt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT)
|
||||
#define TAG(x) x##_wgf
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT)
|
||||
#define TAG(x) x##_wgfs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgft0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT|\
|
||||
GAMMA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfpt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|\
|
||||
GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgfst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|\
|
||||
GAMMA_TEX0_BIT|GAMMA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfspt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_t0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_FOG_BIT)
|
||||
#define TAG(x) x##_f
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_FOG_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_ft0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT)
|
||||
#define TAG(x) x##_g
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_SPEC_BIT)
|
||||
#define TAG(x) x##_gs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_gt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_gst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT)
|
||||
#define TAG(x) x##_gf
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT)
|
||||
#define TAG(x) x##_gfs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_gft0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_gfst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
static void init_setup_tab( void )
|
||||
{
|
||||
init_wg();
|
||||
init_wgs();
|
||||
init_wgt0();
|
||||
init_wgpt0();
|
||||
init_wgst0();
|
||||
init_wgspt0();
|
||||
init_wgf();
|
||||
init_wgfs();
|
||||
init_wgft0();
|
||||
init_wgfpt0();
|
||||
init_wgfst0();
|
||||
init_wgfspt0();
|
||||
init_t0();
|
||||
init_f();
|
||||
init_ft0();
|
||||
init_g();
|
||||
init_gs();
|
||||
init_gt0();
|
||||
init_gst0();
|
||||
init_gf();
|
||||
init_gfs();
|
||||
init_gft0();
|
||||
init_gfst0();
|
||||
}
|
||||
|
||||
void gammaCheckTexSizes( GLcontext *ctx )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
|
||||
if (!setup_tab[gmesa->SetupIndex].check_tex_sizes(ctx)) {
|
||||
/* Invalidate stored verts
|
||||
*/
|
||||
gmesa->SetupNewInputs = ~0;
|
||||
gmesa->SetupIndex |= GAMMA_PTEX_BIT;
|
||||
|
||||
if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
|
||||
tnl->Driver.Render.Interp = setup_tab[gmesa->SetupIndex].interp;
|
||||
tnl->Driver.Render.CopyPV = setup_tab[gmesa->SetupIndex].copy_pv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gammaBuildVertices( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint newinputs )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
GLuint stride = gmesa->vertex_size * sizeof(int);
|
||||
GLubyte *v = ((GLubyte *)gmesa->verts + (start * stride));
|
||||
|
||||
newinputs |= gmesa->SetupNewInputs;
|
||||
gmesa->SetupNewInputs = 0;
|
||||
|
||||
if (!newinputs)
|
||||
return;
|
||||
|
||||
if (newinputs & VERT_BIT_POS) {
|
||||
setup_tab[gmesa->SetupIndex].emit( ctx, start, count, v, stride );
|
||||
} else {
|
||||
GLuint ind = 0;
|
||||
|
||||
if (newinputs & VERT_BIT_COLOR0)
|
||||
ind |= GAMMA_RGBA_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_COLOR1)
|
||||
ind |= GAMMA_SPEC_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_TEX0)
|
||||
ind |= GAMMA_TEX0_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_FOG)
|
||||
ind |= GAMMA_FOG_BIT;
|
||||
|
||||
if (gmesa->SetupIndex & GAMMA_PTEX_BIT)
|
||||
ind = ~0;
|
||||
|
||||
ind &= gmesa->SetupIndex;
|
||||
|
||||
if (ind) {
|
||||
setup_tab[ind].emit( ctx, start, count, v, stride );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gammaChooseVertexState( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint ind = GAMMA_XYZW_BIT|GAMMA_RGBA_BIT;
|
||||
|
||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
|
||||
ind |= GAMMA_SPEC_BIT;
|
||||
|
||||
if (ctx->Fog.Enabled)
|
||||
ind |= GAMMA_FOG_BIT;
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled) {
|
||||
_tnl_need_projected_coords( ctx, GL_FALSE );
|
||||
ind |= GAMMA_TEX0_BIT;
|
||||
} else
|
||||
_tnl_need_projected_coords( ctx, GL_FALSE );
|
||||
|
||||
gmesa->SetupIndex = ind;
|
||||
|
||||
if (setup_tab[ind].vertex_format != gmesa->vertex_format) {
|
||||
gmesa->vertex_format = setup_tab[ind].vertex_format;
|
||||
gmesa->vertex_size = setup_tab[ind].vertex_size;
|
||||
}
|
||||
|
||||
if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
|
||||
tnl->Driver.Render.Interp = gamma_interp_extras;
|
||||
tnl->Driver.Render.CopyPV = gamma_copy_pv_extras;
|
||||
} else {
|
||||
tnl->Driver.Render.Interp = setup_tab[ind].interp;
|
||||
tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gammaInitVB( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
|
||||
|
||||
gmesa->verts = (GLubyte *)_mesa_align_malloc(size * 4 * 16, 32);
|
||||
|
||||
{
|
||||
static int firsttime = 1;
|
||||
if (firsttime) {
|
||||
init_setup_tab();
|
||||
firsttime = 0;
|
||||
gmesa->vertex_size = 16; /* FIXME - only one vertex setup */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gammaFreeVB( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
if (gmesa->verts) {
|
||||
_mesa_align_free(gmesa->verts);
|
||||
gmesa->verts = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
* Keith Whitwell, <keith@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*/
|
||||
|
||||
#ifndef GAMMAVB_INC
|
||||
#define GAMMAVB_INC
|
||||
|
||||
#include "main/mtypes.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define _GAMMA_NEW_VERTEX (_NEW_TEXTURE | \
|
||||
_DD_NEW_TRI_UNFILLED | \
|
||||
_DD_NEW_TRI_LIGHT_TWOSIDE)
|
||||
|
||||
|
||||
extern void gammaChooseVertexState( GLcontext *ctx );
|
||||
extern void gammaCheckTexSizes( GLcontext *ctx );
|
||||
extern void gammaBuildVertices( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint newinputs );
|
||||
|
||||
|
||||
extern void gamma_import_float_colors( GLcontext *ctx );
|
||||
extern void gamma_import_float_spec_colors( GLcontext *ctx );
|
||||
|
||||
extern void gamma_translate_vertex( GLcontext *ctx,
|
||||
const gammaVertex *src,
|
||||
SWvertex *dst );
|
||||
|
||||
extern void gammaInitVB( GLcontext *ctx );
|
||||
extern void gammaFreeVB( GLcontext *ctx );
|
||||
|
||||
extern void gamma_print_vertex( GLcontext *ctx, const gammaVertex *v );
|
||||
extern void gammaPrintSetupFlags(char *msg, GLuint flags );
|
||||
|
||||
#endif
|
||||
@@ -1,273 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Alan Hourihane not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Alan Hourihane makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Authors: Alan Hourihane, <alanh@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver
|
||||
*/
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_macros.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "main/context.h"
|
||||
#include "main/matrix.h"
|
||||
#include "glint_dri.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "vbo/vbo.h"
|
||||
|
||||
static GLboolean
|
||||
gammaInitDriver(__DRIscreen *sPriv)
|
||||
{
|
||||
sPriv->private = (void *) gammaCreateScreen( sPriv );
|
||||
|
||||
if (!sPriv->private) {
|
||||
gammaDestroyScreen( sPriv );
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gammaDestroyContext(__DRIcontext *driContextPriv)
|
||||
{
|
||||
gammaContextPtr gmesa = (gammaContextPtr)driContextPriv->driverPrivate;
|
||||
|
||||
if (gmesa) {
|
||||
_swsetup_DestroyContext( gmesa->glCtx );
|
||||
_tnl_DestroyContext( gmesa->glCtx );
|
||||
_vbo_DestroyContext( gmesa->glCtx );
|
||||
_swrast_DestroyContext( gmesa->glCtx );
|
||||
|
||||
gammaFreeVB( gmesa->glCtx );
|
||||
|
||||
/* free the Mesa context */
|
||||
gmesa->glCtx->DriverCtx = NULL;
|
||||
_mesa_destroy_context(gmesa->glCtx);
|
||||
|
||||
FREE(gmesa);
|
||||
driContextPriv->driverPrivate = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
gammaCreateBuffer( __DRIscreen *driScrnPriv,
|
||||
__DRIdrawable *driDrawPriv,
|
||||
const __GLcontextModes *mesaVis,
|
||||
GLboolean isPixmap )
|
||||
{
|
||||
if (isPixmap) {
|
||||
return GL_FALSE; /* not implemented */
|
||||
}
|
||||
else {
|
||||
driDrawPriv->driverPrivate = (void *)
|
||||
_mesa_create_framebuffer(mesaVis,
|
||||
GL_FALSE, /* software depth buffer? */
|
||||
mesaVis->stencilBits > 0,
|
||||
mesaVis->accumRedBits > 0,
|
||||
mesaVis->alphaBits > 0
|
||||
);
|
||||
return (driDrawPriv->driverPrivate != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gammaDestroyBuffer(__DRIdrawable *driDrawPriv)
|
||||
{
|
||||
_mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gammaSwapBuffers( __DRIdrawable *dPriv )
|
||||
{
|
||||
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
|
||||
gammaContextPtr gmesa;
|
||||
__DRIscreen *driScrnPriv;
|
||||
GLcontext *ctx;
|
||||
|
||||
gmesa = (gammaContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
ctx = gmesa->glCtx;
|
||||
driScrnPriv = gmesa->driScreen;
|
||||
|
||||
_mesa_notifySwapBuffers(ctx);
|
||||
|
||||
VALIDATE_DRAWABLE_INFO(gmesa);
|
||||
|
||||
/* Flush any partially filled buffers */
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
|
||||
DRM_SPINLOCK(&driScrnPriv->pSAREA->drawable_lock,
|
||||
driScrnPriv->drawLockID);
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
|
||||
|
||||
if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) {
|
||||
int src, dst, x0, y0, x1, h;
|
||||
int i;
|
||||
int nRect = dPriv->numClipRects;
|
||||
drm_clip_rect_t *pRect = dPriv->pClipRects;
|
||||
__DRIscreen *driScrnPriv = gmesa->driScreen;
|
||||
GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode |
|
||||
FBReadSrcEnable));
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable);
|
||||
|
||||
for (i = 0; i < nRect; i++, pRect++) {
|
||||
x0 = pRect->x1;
|
||||
x1 = pRect->x2;
|
||||
h = pRect->y2 - pRect->y1;
|
||||
|
||||
y0 = driScrnPriv->fbHeight - (pRect->y1+h);
|
||||
if (gDRIPriv->numMultiDevices == 2)
|
||||
src = (y0/2)*driScrnPriv->fbWidth+x0;
|
||||
else
|
||||
src = y0*driScrnPriv->fbWidth+x0;
|
||||
|
||||
y0 += driScrnPriv->fbHeight;
|
||||
if (gDRIPriv->numMultiDevices == 2)
|
||||
dst = (y0/2)*driScrnPriv->fbWidth+x0;
|
||||
else
|
||||
dst = y0*driScrnPriv->fbWidth+x0;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 9);
|
||||
WRITE(gmesa->buf, StartXDom, x0<<16); /* X0dest */
|
||||
WRITE(gmesa->buf, StartY, y0<<16); /* Y0dest */
|
||||
WRITE(gmesa->buf, StartXSub, x1<<16); /* X1dest */
|
||||
WRITE(gmesa->buf, GLINTCount, h); /* H */
|
||||
WRITE(gmesa->buf, dY, 1<<16); /* ydir */
|
||||
WRITE(gmesa->buf, dXDom, 0<<16);
|
||||
WRITE(gmesa->buf, dXSub, 0<<16);
|
||||
WRITE(gmesa->buf, FBSourceOffset, (dst-src));
|
||||
WRITE(gmesa->buf, Render, 0x00040048); /* NOT_DONE */
|
||||
}
|
||||
|
||||
/*
|
||||
** NOTE: FBSourceOffset (above) is backwards from what is
|
||||
** described in the manual (i.e., dst-src instead of src-dst)
|
||||
** due to our using the bottom-left window origin instead of the
|
||||
** top-left window origin.
|
||||
*/
|
||||
|
||||
/* Restore FBReadMode */
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode |
|
||||
gmesa->AB_FBReadMode));
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
|
||||
}
|
||||
|
||||
if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER)
|
||||
PROCESS_DMA_BUFFER_TOP_HALF(gmesa);
|
||||
|
||||
DRM_SPINUNLOCK(&driScrnPriv->pSAREA->drawable_lock,
|
||||
driScrnPriv->drawLockID);
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
|
||||
|
||||
if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER)
|
||||
PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa);
|
||||
} else {
|
||||
_mesa_problem(NULL, "gammaSwapBuffers: drawable has no context!\n");
|
||||
}
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
gammaMakeCurrent(__DRIcontext *driContextPriv,
|
||||
__DRIdrawable *driDrawPriv,
|
||||
__DRIdrawable *driReadPriv)
|
||||
{
|
||||
if (driContextPriv) {
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
gammaContextPtr oldGammaCtx = ctx ? GAMMA_CONTEXT(ctx) : NULL;
|
||||
gammaContextPtr newGammaCtx = (gammaContextPtr) driContextPriv->driverPrivate;
|
||||
|
||||
if ( newGammaCtx != oldGammaCtx ) {
|
||||
newGammaCtx->dirty = ~0;
|
||||
}
|
||||
|
||||
if (newGammaCtx->driDrawable != driDrawPriv) {
|
||||
newGammaCtx->driDrawable = driDrawPriv;
|
||||
gammaUpdateWindow ( newGammaCtx->glCtx );
|
||||
gammaUpdateViewportOffset( newGammaCtx->glCtx );
|
||||
}
|
||||
|
||||
#if 0
|
||||
newGammaCtx->Window &= ~W_GIDMask;
|
||||
newGammaCtx->Window |= (driDrawPriv->index << 5);
|
||||
CHECK_DMA_BUFFER(newGammaCtx,1);
|
||||
WRITE(newGammaCtx->buf, GLINTWindow, newGammaCtx->Window);
|
||||
#endif
|
||||
|
||||
newGammaCtx->new_state |= GAMMA_NEW_WINDOW; /* FIXME */
|
||||
|
||||
_mesa_make_current2( newGammaCtx->glCtx,
|
||||
(GLframebuffer *) driDrawPriv->driverPrivate,
|
||||
(GLframebuffer *) driReadPriv->driverPrivate );
|
||||
} else {
|
||||
_mesa_make_current( 0, 0 );
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
gammaUnbindContext( __DRIcontext *driContextPriv )
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
gammaInitDriver,
|
||||
gammaDestroyScreen,
|
||||
gammaCreateContext,
|
||||
gammaDestroyContext,
|
||||
gammaCreateBuffer,
|
||||
gammaDestroyBuffer,
|
||||
gammaSwapBuffers,
|
||||
gammaMakeCurrent,
|
||||
gammaUnbindContext
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This is the bootstrap function for the driver.
|
||||
* The __driCreateScreen name is the symbol that libGL.so fetches.
|
||||
* Return: pointer to a __DRIscreen.
|
||||
*/
|
||||
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
|
||||
int numConfigs, __GLXvisualConfig *config)
|
||||
{
|
||||
__DRIscreen *psp;
|
||||
psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &gammaAPI);
|
||||
return (void *) psp;
|
||||
}
|
||||
|
||||
/* This is the table of extensions that the loader will dlsym() for. */
|
||||
PUBLIC const __DRIextension *__driDriverExtensions[] = {
|
||||
&driCoreExtension.base,
|
||||
&driLegacyExtension.base,
|
||||
NULL
|
||||
};
|
||||
@@ -1,63 +0,0 @@
|
||||
/* glint_common.h -- common header definitions for Gamma 2D/3D/DRM suite
|
||||
*
|
||||
* Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* 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
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Converted to common header format:
|
||||
* Jens Owen <jens@tungstengraphics.com>
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GLINT_COMMON_H_
|
||||
#define _GLINT_COMMON_H_
|
||||
|
||||
/*
|
||||
* WARNING: If you change any of these defines, make sure to change
|
||||
* the kernel include file as well (gamma_drm.h)
|
||||
*/
|
||||
|
||||
/* Driver specific DRM command indices
|
||||
* NOTE: these are not OS specific, but they are driver specific
|
||||
*/
|
||||
#define DRM_GAMMA_INIT 0x00
|
||||
#define DRM_GAMMA_COPY 0x01
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
GAMMA_INIT_DMA = 0x01,
|
||||
GAMMA_CLEANUP_DMA = 0x02
|
||||
} func;
|
||||
int sarea_priv_offset;
|
||||
int pcimode;
|
||||
unsigned int mmio0;
|
||||
unsigned int mmio1;
|
||||
unsigned int mmio2;
|
||||
unsigned int mmio3;
|
||||
unsigned int buffers_offset;
|
||||
int num_rast;
|
||||
} drmGAMMAInit;
|
||||
|
||||
extern int drmGAMMAInitDMA( int fd, drmGAMMAInit *info );
|
||||
extern int drmGAMMACleanupDMA( int fd );
|
||||
|
||||
#endif
|
||||
@@ -1,122 +0,0 @@
|
||||
/**************************************************************************
|
||||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
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, sub license, 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 NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL PRECISION INSIGHT 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.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Author:
|
||||
* Jens Owen <jens@tungstengraphics.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GLINT_DRI_H_
|
||||
#define _GLINT_DRI_H_
|
||||
|
||||
#include "xf86drm.h"
|
||||
#include "glint_common.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned int GDeltaMode;
|
||||
unsigned int GDepthMode;
|
||||
unsigned int GGeometryMode;
|
||||
unsigned int GTransformMode;
|
||||
} GAMMAContextRegionRec, *GAMMAContextRegionPtr;
|
||||
|
||||
typedef struct {
|
||||
unsigned char next, prev; /* indices to form a circular LRU */
|
||||
unsigned char in_use; /* owned by a client, or free? */
|
||||
int age; /* tracked by clients to update local LRU's */
|
||||
} GAMMATextureRegionRec, *GAMMATextureRegionPtr;
|
||||
|
||||
typedef struct {
|
||||
GAMMAContextRegionRec context_state;
|
||||
|
||||
unsigned int dirty;
|
||||
|
||||
/* Maintain an LRU of contiguous regions of texture space. If
|
||||
* you think you own a region of texture memory, and it has an
|
||||
* age different to the one you set, then you are mistaken and
|
||||
* it has been stolen by another client. If global texAge
|
||||
* hasn't changed, there is no need to walk the list.
|
||||
*
|
||||
* These regions can be used as a proxy for the fine-grained
|
||||
* texture information of other clients - by maintaining them
|
||||
* in the same lru which is used to age their own textures,
|
||||
* clients have an approximate lru for the whole of global
|
||||
* texture space, and can make informed decisions as to which
|
||||
* areas to kick out. There is no need to choose whether to
|
||||
* kick out your own texture or someone else's - simply eject
|
||||
* them all in LRU order.
|
||||
*/
|
||||
|
||||
#define GAMMA_NR_TEX_REGIONS 64
|
||||
GAMMATextureRegionRec texList[GAMMA_NR_TEX_REGIONS+1];
|
||||
/* Last elt is sentinal */
|
||||
int texAge; /* last time texture was uploaded */
|
||||
int last_enqueue; /* last time a buffer was enqueued */
|
||||
int last_dispatch; /* age of the most recently dispatched buffer */
|
||||
int last_quiescent; /* */
|
||||
int ctxOwner; /* last context to upload state */
|
||||
|
||||
int vertex_prim;
|
||||
} GLINTSAREADRIRec, *GLINTSAREADRIPtr;
|
||||
|
||||
/*
|
||||
* Glint specific record passed back to client driver
|
||||
* via DRIGetDeviceInfo request
|
||||
*/
|
||||
typedef struct {
|
||||
drmRegion registers0;
|
||||
drmRegion registers1;
|
||||
drmRegion registers2;
|
||||
drmRegion registers3;
|
||||
int numMultiDevices;
|
||||
int pprod;
|
||||
int cpp;
|
||||
int frontOffset;
|
||||
int frontPitch;
|
||||
int backOffset;
|
||||
int backPitch;
|
||||
int backX;
|
||||
int backY;
|
||||
int depthOffset;
|
||||
int depthPitch;
|
||||
int textureSize;
|
||||
int logTextureGranularity;
|
||||
} GLINTDRIRec, *GLINTDRIPtr;
|
||||
|
||||
#define GLINT_DRI_BUF_COUNT 256
|
||||
#define GLINT_DRI_BUF_SIZE 4096
|
||||
|
||||
#define GAMMA_NR_TEX_REGIONS 64
|
||||
|
||||
#define DMA_WRITE(val,reg) \
|
||||
do { \
|
||||
pGlint->buf2D++ = Glint##reg##Tag; \
|
||||
pGlint->buf2D++ = val; \
|
||||
} while (0)
|
||||
|
||||
#endif /* _GLINT_DRI_H_ */
|
||||
Reference in New Issue
Block a user