Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1

This commit is contained in:
Ben Skeggs 2008-02-29 13:24:31 +11:00
commit 8c77e6f674
197 changed files with 31104 additions and 29429 deletions

4
.gitattributes vendored Executable file
View file

@ -0,0 +1,4 @@
*.dsp -crlf
*.dsw -crlf
*.sln -crlf
*.vcproj -crlf

View file

@ -1,13 +1,5 @@
#######################################################################
# Top-level SConstruct
import os
import os.path
import sys
#######################################################################
# Configuration options
#
# For example, invoke scons as
#
@ -28,19 +20,21 @@ import sys
# to get the full list of options. See scons manpage for more info.
#
platform_map = {
'linux2': 'linux',
'win32': 'winddk',
}
import os
import os.path
import sys
default_platform = platform_map.get(sys.platform, sys.platform)
import common
if default_platform in ('linux', 'freebsd', 'darwin'):
#######################################################################
# Configuration options
if common.default_platform in ('linux', 'freebsd', 'darwin'):
default_statetrackers = 'mesa'
default_drivers = 'softpipe,failover,i915simple,i965simple'
default_winsys = 'xlib'
default_dri = 'yes'
elif default_platform in ('winddk',):
elif common.default_platform in ('winddk',):
default_statetrackers = 'none'
default_drivers = 'softpipe,i915simple'
default_winsys = 'none'
@ -50,36 +44,13 @@ else:
default_winsys = 'all'
default_dri = 'no'
# TODO: auto-detect defaults
opts = Options('config.py')
opts.Add(BoolOption('debug', 'build debug version', False))
opts.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
allowed_values=('generic', 'x86', 'x86-64')))
opts.Add(EnumOption('platform', 'target platform', default_platform,
allowed_values=('linux', 'cell', 'winddk')))
opts = common.Options()
opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers,
[
'mesa',
],
))
['mesa']))
opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
[
'softpipe',
'failover',
'i915simple',
'i965simple',
'cell',
],
))
['softpipe', 'failover', 'i915simple', 'i965simple', 'cell']))
opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
[
'xlib',
'intel',
],
))
opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
['xlib', 'intel']))
env = Environment(
options = opts,
@ -151,17 +122,17 @@ if msvc:
cflags = [
'/Od', # disable optimizations
'/Oy-', # disable frame pointer omission
'/Zi', # enable enable debugging information
]
else:
cflags = [
'/Ox', # maximum optimizations
'/Os', # favor code space
'/Zi', # enable enable debugging information
]
env.Append(CFLAGS = cflags)
env.Append(CXXFLAGS = cflags)
# Put debugging information in a separate .pdb file for each object file as
# descrived in the scons manpage
env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
# Defines
if debug:
@ -249,64 +220,20 @@ if platform not in ('winddk',):
'Xfixes',
])
# Convenience library support
common.createConvenienceLibBuilder(env)
Export('env')
#######################################################################
# Convenience Library Builder
# based on the stock StaticLibrary and SharedLibrary builders
def createConvenienceLibBuilder(env):
"""This is a utility function that creates the ConvenienceLibrary
Builder in an Environment if it is not there already.
If it is already there, we return the existing one.
"""
try:
convenience_lib = env['BUILDERS']['ConvenienceLibrary']
except KeyError:
action_list = [ Action("$ARCOM", "$ARCOMSTR") ]
if env.Detect('ranlib'):
ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR")
action_list.append(ranlib_action)
convenience_lib = Builder(action = action_list,
emitter = '$LIBEMITTER',
prefix = '$LIBPREFIX',
suffix = '$LIBSUFFIX',
src_suffix = '$SHOBJSUFFIX',
src_builder = 'SharedObject')
env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
env['BUILDERS']['Library'] = convenience_lib
return convenience_lib
createConvenienceLibBuilder(env)
#######################################################################
# Invoke SConscripts
# Put build output in a separate dir, which depends on the current configuration
# See also http://www.scons.org/wiki/AdvancedBuildExample
build_topdir = 'build'
build_subdir = platform
if dri:
build_subdir += "-dri"
if llvm:
build_subdir += "-llvm"
if x86:
build_subdir += "-x86"
if debug:
build_subdir += "-debug"
build_dir = os.path.join(build_topdir, build_subdir)
# TODO: Build several variants at the same time?
# http://www.scons.org/wiki/SimultaneousVariantBuilds
SConscript(
'src/SConscript',
build_dir = build_dir,
build_dir = common.make_build_dir(env),
duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
)

116
common.py Normal file
View file

@ -0,0 +1,116 @@
#######################################################################
# Common SCons code
import os
import os.path
import sys
import platform as _platform
#######################################################################
# Defaults
_platform_map = {
'linux2': 'linux',
'win32': 'winddk',
}
default_platform = sys.platform
default_platform = _platform_map.get(default_platform, default_platform)
_machine_map = {
'x86': 'x86',
'i386': 'x86',
'i486': 'x86',
'i586': 'x86',
'i686': 'x86',
'x86_64': 'x86_64',
}
if 'PROCESSOR_ARCHITECTURE' in os.environ:
default_machine = os.environ['PROCESSOR_ARCHITECTURE']
else:
default_machine = _platform.machine()
default_machine = _machine_map.get(default_machine, 'generic')
if default_platform in ('linux', 'freebsd', 'darwin'):
default_dri = 'yes'
elif default_platform in ('winddk',):
default_dri = 'no'
else:
default_dri = 'no'
#######################################################################
# Common options
def Options():
from SCons.Options import Options
from SCons.Options.BoolOption import BoolOption
from SCons.Options.EnumOption import EnumOption
opts = Options('config.py')
opts.Add(BoolOption('debug', 'build debug version', 'no'))
opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
allowed_values=('generic', 'x86', 'x86_64')))
opts.Add(EnumOption('platform', 'target platform', default_platform,
allowed_values=('linux', 'cell', 'winddk')))
opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
return opts
#######################################################################
# Convenience Library Builder
# based on the stock StaticLibrary and SharedLibrary builders
import SCons.Action
import SCons.Builder
def createConvenienceLibBuilder(env):
"""This is a utility function that creates the ConvenienceLibrary
Builder in an Environment if it is not there already.
If it is already there, we return the existing one.
"""
try:
convenience_lib = env['BUILDERS']['ConvenienceLibrary']
except KeyError:
action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
if env.Detect('ranlib'):
ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
action_list.append(ranlib_action)
convenience_lib = SCons.Builder.Builder(action = action_list,
emitter = '$LIBEMITTER',
prefix = '$LIBPREFIX',
suffix = '$LIBSUFFIX',
src_suffix = '$SHOBJSUFFIX',
src_builder = 'SharedObject')
env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
env['BUILDERS']['Library'] = convenience_lib
return convenience_lib
#######################################################################
# Build
def make_build_dir(env):
# Put build output in a separate dir, which depends on the current configuration
# See also http://www.scons.org/wiki/AdvancedBuildExample
build_topdir = 'build'
build_subdir = env['platform']
if env['dri']:
build_subdir += "-dri"
if env['llvm']:
build_subdir += "-llvm"
if env['machine'] != 'generic':
build_subdir += '-' + env['machine']
if env['debug']:
build_subdir += "-debug"
build_dir = os.path.join(build_topdir, build_subdir)
# Place the .sconsign file on the builddir too, to avoid issues with different scons
# versions building the same source file
env.SConsignFile(os.path.join(build_dir, '.sconsign'))
return build_dir

View file

@ -1,163 +1,163 @@
File: docs/README.WIN32
Last updated: Apr 25, 2007 - Karl Schultz - kschultz@users.sourceforge.net
Quick Start
----- -----
Unzip the MesaLib, MesaGLUT, and MesaDemos ZIP files into the same
directory. The libs and demos build separately, so if you do not care
about the demos or GLUT, you only need to unzip MesaLib. If you unzip
more than one ZIP file, they all need to be unzipped into the same
directory. Don't worry, you will not overwrite anything.
The Windows build system uses Microsoft Visual Studio. Project files
for a specific version of Visual Studio are in their own directory in
the top-level "windows" directory. For example, Visual Studio 8 files
are in windows/VC8.
Support has been dropped for versions of Visual Studio prior to 8. The
main reason is because Microsoft now provides a free compiler and
developer environment. Visual Studio Express can be found at
http://msdn.microsoft.com/vstudio/express/visualc/default.aspx
You'll also need the Platform SDK. Instructions for obtaining and
using the SDK with Visual Studio Express can be found at
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
If you are stuck using VC6 or VC7, you may start with these project
files, but you may need to modify them to reflect changes in the
Mesa source code tree. If you sucessfully update the project files,
please submit them to the author of this document so that they may
be included in the next distribution.
The project files to build the core Mesa library, Windows Mesa
drivers, OSMesa, and GLU are in the mesa directory. The project files
to build GLUT and some demo programs are in the progs directory.
Makefiles are no longer shipped or supported, but can be generated
from the projects using Visual Studio.
Windows Drivers
------- -------
At this time, only the GDI driver is known to work. Most of the demos
in progs/demos should work with this driver.
Source code also exists in the tree for other drivers in
src/mesa/drivers/windows, but the status of this code is unknown.
The GDI driver operates basically by writing pixel spans into a DIB
section and then blitting the DIB to the window. The driver was
recently cleaned up and rewitten and so may have bugs or may be
missing some functionality. The older versions of the CVS source may
be useful in figuring out any problems, or report them to me.
To build Mesa with the GDI driver, build the mesa, gdi, and glu
projects in the Visual Studio workspace found at
windows/VC8/mesa/mesa.sln
The osmesa DLL can also be built with the osmesa project.
The build system creates a lib top-level directory and copies
resulting LIB and DLL files to this lib directory. The files are:
OPENGL32.LIB, GLU32.LIB, OSMESA32.LIB
OPENGL32.DLL, GLU32.DLL, OSMESA32.DLL
If the MesaDemos ZIP file was extracted, the DLL files are also copied
to the demos directory. This facilitates running the demos as described
below.
GLUT and Demos
---- --- -----
A Visual Studio workspace can be found at
windows/VC8/progs/progs.sln
It can be used to build GLUT and a few demos. The GLUT lib and DLL
are copied to the top-level lib directory, along with the Mesa libs.
The demo build system expects to find the LIB files in the top level
lib directory, so you must build the Mesa libs first. The demo
executables are placed in the demos directory, because some of them
rely on data files found there. Also, the Mesa lib DLL's were copied
there by the Mesa lib build process. Therefore, you should be able to
simply run the demo executables from the demo directory.
If you want to run the demos from the Visual Studio, you may have to
change the startup directory and explicitly state where the executables are.
You may also build all the demo programs by using a makefile. Go to
the progs/demos directory and make sure you have executed VCVARS32.BAT
or whatever setup script is appropriate for your compiler. Then,
nmake -f Makefile.win
should build all the demos.
Build System Notes
----- ------ -----
VC6 (not actively supported)
---
Visual Studio 6 does not recognize files with the .cc extension as C++
language files, without a lot of unnatural tweaking. So, the VC6
build process uses custom build steps to compile these files in the
GLU library.
Two additional configurations are provided, Debug x86 and Release x86
that activate the shader code compilation by defining SLANG_86. It is
unknown if and how this works.
VC7 (not actively supported)
---
The above-mentioned .cc problem does not exist in this version.
VC8
---
No notes.
General
-------
After building, you can copy the above DLL files to a place in your
PATH such as $SystemRoot/SYSTEM32. If you don't like putting things
in a system directory, place them in the same directory as the
executable(s). Be careful about accidentially overwriting files of
the same name in the SYSTEM32 directory.
The DLL files are built so that the external entry points use the
stdcall calling convention.
Static LIB files are not built. The LIB files that are built with are
the linker import files associated with the DLL files.
The si-glu sources are used to build the GLU libs. This was done
mainly to get the better tessellator code.
To build "mangled" Mesa, add the preprocessor define USE_MGL_NAMESPACE
to the project settings. You will also need to edit src/mesa.def to
change all the gl* symbols to mgl*. Because this is easy to do with a
global replace operation in a text editor, no additional mangled
version of mesa.def is maintained or shipped.
If you have a Windows-related build problem or question, it is
probably better to direct it to me (kschultz@users.sourceforge.net),
rather than directly to the other Mesa developers. I will help you as
much as I can. I also monitor the Mesa mailing lists and will answer
questions in this area there as well.
Karl Schultz
File: docs/README.WIN32
Last updated: Apr 25, 2007 - Karl Schultz - kschultz@users.sourceforge.net
Quick Start
----- -----
Unzip the MesaLib, MesaGLUT, and MesaDemos ZIP files into the same
directory. The libs and demos build separately, so if you do not care
about the demos or GLUT, you only need to unzip MesaLib. If you unzip
more than one ZIP file, they all need to be unzipped into the same
directory. Don't worry, you will not overwrite anything.
The Windows build system uses Microsoft Visual Studio. Project files
for a specific version of Visual Studio are in their own directory in
the top-level "windows" directory. For example, Visual Studio 8 files
are in windows/VC8.
Support has been dropped for versions of Visual Studio prior to 8. The
main reason is because Microsoft now provides a free compiler and
developer environment. Visual Studio Express can be found at
http://msdn.microsoft.com/vstudio/express/visualc/default.aspx
You'll also need the Platform SDK. Instructions for obtaining and
using the SDK with Visual Studio Express can be found at
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
If you are stuck using VC6 or VC7, you may start with these project
files, but you may need to modify them to reflect changes in the
Mesa source code tree. If you sucessfully update the project files,
please submit them to the author of this document so that they may
be included in the next distribution.
The project files to build the core Mesa library, Windows Mesa
drivers, OSMesa, and GLU are in the mesa directory. The project files
to build GLUT and some demo programs are in the progs directory.
Makefiles are no longer shipped or supported, but can be generated
from the projects using Visual Studio.
Windows Drivers
------- -------
At this time, only the GDI driver is known to work. Most of the demos
in progs/demos should work with this driver.
Source code also exists in the tree for other drivers in
src/mesa/drivers/windows, but the status of this code is unknown.
The GDI driver operates basically by writing pixel spans into a DIB
section and then blitting the DIB to the window. The driver was
recently cleaned up and rewitten and so may have bugs or may be
missing some functionality. The older versions of the CVS source may
be useful in figuring out any problems, or report them to me.
To build Mesa with the GDI driver, build the mesa, gdi, and glu
projects in the Visual Studio workspace found at
windows/VC8/mesa/mesa.sln
The osmesa DLL can also be built with the osmesa project.
The build system creates a lib top-level directory and copies
resulting LIB and DLL files to this lib directory. The files are:
OPENGL32.LIB, GLU32.LIB, OSMESA32.LIB
OPENGL32.DLL, GLU32.DLL, OSMESA32.DLL
If the MesaDemos ZIP file was extracted, the DLL files are also copied
to the demos directory. This facilitates running the demos as described
below.
GLUT and Demos
---- --- -----
A Visual Studio workspace can be found at
windows/VC8/progs/progs.sln
It can be used to build GLUT and a few demos. The GLUT lib and DLL
are copied to the top-level lib directory, along with the Mesa libs.
The demo build system expects to find the LIB files in the top level
lib directory, so you must build the Mesa libs first. The demo
executables are placed in the demos directory, because some of them
rely on data files found there. Also, the Mesa lib DLL's were copied
there by the Mesa lib build process. Therefore, you should be able to
simply run the demo executables from the demo directory.
If you want to run the demos from the Visual Studio, you may have to
change the startup directory and explicitly state where the executables are.
You may also build all the demo programs by using a makefile. Go to
the progs/demos directory and make sure you have executed VCVARS32.BAT
or whatever setup script is appropriate for your compiler. Then,
nmake -f Makefile.win
should build all the demos.
Build System Notes
----- ------ -----
VC6 (not actively supported)
---
Visual Studio 6 does not recognize files with the .cc extension as C++
language files, without a lot of unnatural tweaking. So, the VC6
build process uses custom build steps to compile these files in the
GLU library.
Two additional configurations are provided, Debug x86 and Release x86
that activate the shader code compilation by defining SLANG_86. It is
unknown if and how this works.
VC7 (not actively supported)
---
The above-mentioned .cc problem does not exist in this version.
VC8
---
No notes.
General
-------
After building, you can copy the above DLL files to a place in your
PATH such as $SystemRoot/SYSTEM32. If you don't like putting things
in a system directory, place them in the same directory as the
executable(s). Be careful about accidentially overwriting files of
the same name in the SYSTEM32 directory.
The DLL files are built so that the external entry points use the
stdcall calling convention.
Static LIB files are not built. The LIB files that are built with are
the linker import files associated with the DLL files.
The si-glu sources are used to build the GLU libs. This was done
mainly to get the better tessellator code.
To build "mangled" Mesa, add the preprocessor define USE_MGL_NAMESPACE
to the project settings. You will also need to edit src/mesa.def to
change all the gl* symbols to mgl*. Because this is easy to do with a
global replace operation in a text editor, no additional mangled
version of mesa.def is maintained or shipped.
If you have a Windows-related build problem or question, it is
probably better to direct it to me (kschultz@users.sourceforge.net),
rather than directly to the other Mesa developers. I will help you as
much as I can. I also monitor the Mesa mailing lists and will answer
questions in this area there as well.
Karl Schultz

View file

@ -1,33 +1,33 @@
default: full
all: full subset
%.tag: %.doxy
doxygen $<
FULL = \
main.doxy \
math.doxy \
vbo.doxy \
glapi.doxy \
shader.doxy \
swrast.doxy \
swrast_setup.doxy \
tnl.doxy \
tnl_dd.doxy
full: $(FULL:.doxy=.tag)
$(foreach FILE,$(FULL),doxygen $(FILE);)
SUBSET = \
main.doxy \
math.doxy \
miniglx.doxy
subset: $(SUBSET:.doxy=.tag)
$(foreach FILE,$(SUBSET),doxygen $(FILE);)
clean:
rm -rf $(FULL:.doxy=) $(SUBSET:.doxy=)
rm -rf *.tag
default: full
all: full subset
%.tag: %.doxy
doxygen $<
FULL = \
main.doxy \
math.doxy \
vbo.doxy \
glapi.doxy \
shader.doxy \
swrast.doxy \
swrast_setup.doxy \
tnl.doxy \
tnl_dd.doxy
full: $(FULL:.doxy=.tag)
$(foreach FILE,$(FULL),doxygen $(FILE);)
SUBSET = \
main.doxy \
math.doxy \
miniglx.doxy
subset: $(SUBSET:.doxy=.tag)
$(foreach FILE,$(SUBSET),doxygen $(FILE);)
clean:
rm -rf $(FULL:.doxy=) $(SUBSET:.doxy=)
rm -rf *.tag

View file

@ -1,19 +1,19 @@
doxygen tnl_dd.doxy
doxygen vbo.doxy
doxygen math.doxy
doxygen swrast.doxy
doxygen swrast_setup.doxy
doxygen tnl.doxy
doxygen core.doxy
doxygen glapi.doxy
doxygen shader.doxy
echo Building again, to resolve tags
doxygen tnl_dd.doxy
doxygen vbo.doxy
doxygen math.doxy
doxygen swrast.doxy
doxygen swrast_setup.doxy
doxygen tnl.doxy
doxygen glapi.doxy
doxygen shader.doxy
doxygen tnl_dd.doxy
doxygen vbo.doxy
doxygen math.doxy
doxygen swrast.doxy
doxygen swrast_setup.doxy
doxygen tnl.doxy
doxygen core.doxy
doxygen glapi.doxy
doxygen shader.doxy
echo Building again, to resolve tags
doxygen tnl_dd.doxy
doxygen vbo.doxy
doxygen math.doxy
doxygen swrast.doxy
doxygen swrast_setup.doxy
doxygen tnl.doxy
doxygen glapi.doxy
doxygen shader.doxy

View file

@ -1,79 +1,79 @@
/****************************************************************************
*
* Mesa bindings for SciTech MGL
*
* Copyright (C) 1996 SciTech Software.
* All rights reserved.
*
* Filename: mglmesa.h
* Version: Revision: 1.1.1.1
*
* Language: ANSI C
* Environment: Any
*
* Description: Header file for the Mesa/OpenGL interface bindings for the
* SciTech MGL graphics library. Uses the MGL internal
* device context structures to get direct access to the
* high performance MGL rasterization functions for maximum
* performance. Utilizes the VESA VBE/AF Accelerator Functions
* via the MGL's accelerated device driver functions, as well
* as basic DirectDraw accelerated functions provided by the
* MGL.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
****************************************************************************/
#ifndef __MGLMESA_H
#define __MGLMESA_H
#include "mgraph.h"
/*------------------------- Function Prototypes ---------------------------*/
#ifdef __cplusplus
extern "C" { /* Use "C" linkage when in C++ mode */
#endif
#ifndef __WINDOWS__
#define GLAPIENTRY
#endif
#ifdef __WINDOWS__
bool GLAPIENTRY MGLMesaInitDLL(MGLCallbacks *cb,char *version);
#endif
void GLAPIENTRY MGLMesaChooseVisual(MGLDC *dc,MGLVisual *visual);
bool GLAPIENTRY MGLMesaSetVisual(MGLDC *dc,MGLVisual *visual);
bool GLAPIENTRY MGLMesaCreateContext(MGLDC *dc,bool forceMemDC);
void GLAPIENTRY MGLMesaDestroyContext(MGLDC *dc);
void GLAPIENTRY MGLMesaMakeCurrent(MGLDC *dc);
void GLAPIENTRY MGLMesaSwapBuffers(MGLDC *dc,bool waitVRT);
/* Palette manipulation support. The reason we provide palette manipulation
* routines is so that when rendering in double buffered modes with a
* software backbuffer, the palette for the backbuffer is kept consistent
* with the hardware front buffer.
*/
void GLAPIENTRY MGLMesaSetPaletteEntry(MGLDC *dc,int entry,uchar red,uchar green,uchar blue);
void GLAPIENTRY MGLMesaSetPalette(MGLDC *dc,palette_t *pal,int numColors,int startIndex);
void GLAPIENTRY MGLMesaRealizePalette(MGLDC *dc,int numColors,int startIndex,int waitVRT);
#ifdef __cplusplus
} /* End of "C" linkage for C++ */
#endif /* __cplusplus */
#endif /* __MGLMESA_H */
/****************************************************************************
*
* Mesa bindings for SciTech MGL
*
* Copyright (C) 1996 SciTech Software.
* All rights reserved.
*
* Filename: mglmesa.h
* Version: Revision: 1.1.1.1
*
* Language: ANSI C
* Environment: Any
*
* Description: Header file for the Mesa/OpenGL interface bindings for the
* SciTech MGL graphics library. Uses the MGL internal
* device context structures to get direct access to the
* high performance MGL rasterization functions for maximum
* performance. Utilizes the VESA VBE/AF Accelerator Functions
* via the MGL's accelerated device driver functions, as well
* as basic DirectDraw accelerated functions provided by the
* MGL.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
****************************************************************************/
#ifndef __MGLMESA_H
#define __MGLMESA_H
#include "mgraph.h"
/*------------------------- Function Prototypes ---------------------------*/
#ifdef __cplusplus
extern "C" { /* Use "C" linkage when in C++ mode */
#endif
#ifndef __WINDOWS__
#define GLAPIENTRY
#endif
#ifdef __WINDOWS__
bool GLAPIENTRY MGLMesaInitDLL(MGLCallbacks *cb,char *version);
#endif
void GLAPIENTRY MGLMesaChooseVisual(MGLDC *dc,MGLVisual *visual);
bool GLAPIENTRY MGLMesaSetVisual(MGLDC *dc,MGLVisual *visual);
bool GLAPIENTRY MGLMesaCreateContext(MGLDC *dc,bool forceMemDC);
void GLAPIENTRY MGLMesaDestroyContext(MGLDC *dc);
void GLAPIENTRY MGLMesaMakeCurrent(MGLDC *dc);
void GLAPIENTRY MGLMesaSwapBuffers(MGLDC *dc,bool waitVRT);
/* Palette manipulation support. The reason we provide palette manipulation
* routines is so that when rendering in double buffered modes with a
* software backbuffer, the palette for the backbuffer is kept consistent
* with the hardware front buffer.
*/
void GLAPIENTRY MGLMesaSetPaletteEntry(MGLDC *dc,int entry,uchar red,uchar green,uchar blue);
void GLAPIENTRY MGLMesaSetPalette(MGLDC *dc,palette_t *pal,int numColors,int startIndex);
void GLAPIENTRY MGLMesaRealizePalette(MGLDC *dc,int numColors,int startIndex,int waitVRT);
#ifdef __cplusplus
} /* End of "C" linkage for C++ */
#endif /* __cplusplus */
#endif /* __MGLMESA_H */

View file

@ -1,119 +1,119 @@
BACKGROUND = 0.000 0.500 0.700
ANAME = AXLE1
ARADIUS = 1.000
AAXIS = 2
APOSITION = -7.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 6.000
AMOTORED = 1
AANGULARVELOCITY = 90.000
ADIRECTION = 1
ANAME = AXLE2
ARADIUS = 1.000
AAXIS = 2
APOSITION = -3.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 12.000
AMOTORED = 0
ANAME = AXLE3
ARADIUS = 1.000
AAXIS = 2
APOSITION = 1.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 6.000
AMOTORED = 0
ANAME = AXLE4
ARADIUS = 1.000
AAXIS = 2
APOSITION = 8.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 18.000
AMOTORED = 0
ANAME = AXLE5
ARADIUS = 1.000
AAXIS = 1
APOSITION = 8.000 -8.200 -7.400
ACOLOR = 0.800 0.500 0.200
ALENGTH = 12.000
AMOTORED = 0
GNAME = GEAR1
GTYPE = NORMAL
GRADIUS = 2.200
GWIDTH = 3.000
GTEETH = 40
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE1
GPOSITION = 0.000
GNAME = GEAR2
GTYPE = NORMAL
GRADIUS = 2.200
GWIDTH = 3.000
GTEETH = 30
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE2
GPOSITION = 0.000
GNAME = GEAR3
GTYPE = NORMAL
GRADIUS = 2.200
GWIDTH = 3.000
GTEETH = 20
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE3
GPOSITION = 0.000
GNAME = GEAR4
GTYPE = NORMAL
GRADIUS = 1.700
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE2
GPOSITION = 5.000
GNAME = GEAR5
GTYPE = NORMAL
GRADIUS = 3.000
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE4
GPOSITION = 5.000
GNAME = GEAR6
GTYPE = BEVEL
GFACE = 0
GRADIUS = 4.000
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 1.700
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE4
GPOSITION = -4.000
GNAME = GEAR7
GTYPE = BEVEL
GFACE = 0
GRADIUS = 4.000
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 1.700
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE5
GPOSITION = 5.000
BELTNAME = BELT1
GEAR1NAME = GEAR5
GEAR2NAME = GEAR4
BACKGROUND = 0.000 0.500 0.700
ANAME = AXLE1
ARADIUS = 1.000
AAXIS = 2
APOSITION = -7.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 6.000
AMOTORED = 1
AANGULARVELOCITY = 90.000
ADIRECTION = 1
ANAME = AXLE2
ARADIUS = 1.000
AAXIS = 2
APOSITION = -3.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 12.000
AMOTORED = 0
ANAME = AXLE3
ARADIUS = 1.000
AAXIS = 2
APOSITION = 1.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 6.000
AMOTORED = 0
ANAME = AXLE4
ARADIUS = 1.000
AAXIS = 2
APOSITION = 8.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 18.000
AMOTORED = 0
ANAME = AXLE5
ARADIUS = 1.000
AAXIS = 1
APOSITION = 8.000 -8.200 -7.400
ACOLOR = 0.800 0.500 0.200
ALENGTH = 12.000
AMOTORED = 0
GNAME = GEAR1
GTYPE = NORMAL
GRADIUS = 2.200
GWIDTH = 3.000
GTEETH = 40
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE1
GPOSITION = 0.000
GNAME = GEAR2
GTYPE = NORMAL
GRADIUS = 2.200
GWIDTH = 3.000
GTEETH = 30
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE2
GPOSITION = 0.000
GNAME = GEAR3
GTYPE = NORMAL
GRADIUS = 2.200
GWIDTH = 3.000
GTEETH = 20
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE3
GPOSITION = 0.000
GNAME = GEAR4
GTYPE = NORMAL
GRADIUS = 1.700
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE2
GPOSITION = 5.000
GNAME = GEAR5
GTYPE = NORMAL
GRADIUS = 3.000
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE4
GPOSITION = 5.000
GNAME = GEAR6
GTYPE = BEVEL
GFACE = 0
GRADIUS = 4.000
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 1.700
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE4
GPOSITION = -4.000
GNAME = GEAR7
GTYPE = BEVEL
GFACE = 0
GRADIUS = 4.000
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 1.700
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE5
GPOSITION = 5.000
BELTNAME = BELT1
GEAR1NAME = GEAR5
GEAR2NAME = GEAR4

View file

@ -1,132 +1,132 @@
Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216
Named object: "Object01"
Tri-mesh, Vertices: 20 Faces: 36
Vertex list:
Vertex 0: X: -210 Y: -432.781738 Z: 180.000031
Vertex 1: X: -610.810303 Y: 144.260559 Z: 103.580154
Vertex 2: X: 56.586655 Y: 144.260544 Z: -128.902023
Vertex 3: X: -75.776352 Y: 144.260605 Z: 565.321838
Vertex 4: X: -462.815979 Y: -347.937683 Z: 131.797302
Vertex 5: X: -616.506042 Y: -126.67173 Z: 102.494209
Vertex 6: X: -41.847229 Y: -347.937683 Z: -14.843644
Vertex 7: X: 60.375015 Y: -126.671753 Z: -133.291641
Vertex 8: X: -125.336807 Y: -347.937653 Z: 423.046448
Vertex 9: X: -73.868958 Y: -126.671692 Z: 570.797424
Vertex 10: X: -448.353271 Y: 237.304672 Z: -92.34951
Vertex 11: X: -192.440964 Y: 237.304672 Z: -181.494431
Vertex 12: X: 145.038193 Y: 237.304672 Z: 109.754745
Vertex 13: X: 94.283768 Y: 237.304688 Z: 375.953766
Vertex 14: X: -326.684937 Y: 237.304733 Z: 522.594727
Vertex 15: X: -531.842834 Y: 237.304718 Z: 345.540588
Vertex 16: X: -331.419525 Y: -225.964966 Z: -168.564438
Vertex 17: X: 152.575485 Y: -225.964935 Z: 249.129868
Vertex 18: X: -451.155914 Y: -225.964905 Z: 459.434662
Vertex 19: X: -298.413483 Y: 423.31897 Z: 163.142761
Face list:
Face 0: A:0 B:4 C:6 AB:1 BC:1 CA:1
Face 1: A:4 B:5 C:16 AB:1 BC:1 CA:1
Face 2: A:4 B:16 C:6 AB:1 BC:1 CA:1
Face 3: A:6 B:16 C:7 AB:1 BC:1 CA:1
Face 4: A:5 B:1 C:10 AB:1 BC:1 CA:1
Face 5: A:5 B:10 C:16 AB:1 BC:1 CA:1
Face 6: A:16 B:10 C:11 AB:1 BC:1 CA:1
Face 7: A:16 B:11 C:7 AB:1 BC:1 CA:1
Face 8: A:7 B:11 C:2 AB:1 BC:1 CA:1
Face 9: A:0 B:6 C:8 AB:1 BC:1 CA:1
Face 10: A:6 B:7 C:17 AB:1 BC:1 CA:1
Face 11: A:6 B:17 C:8 AB:1 BC:1 CA:1
Face 12: A:8 B:17 C:9 AB:1 BC:1 CA:1
Face 13: A:7 B:2 C:12 AB:1 BC:1 CA:1
Face 14: A:7 B:12 C:17 AB:1 BC:1 CA:1
Face 15: A:17 B:12 C:13 AB:1 BC:1 CA:1
Face 16: A:17 B:13 C:9 AB:1 BC:1 CA:1
Face 17: A:9 B:13 C:3 AB:1 BC:1 CA:1
Face 18: A:0 B:8 C:4 AB:1 BC:1 CA:1
Face 19: A:8 B:9 C:18 AB:1 BC:1 CA:1
Face 20: A:8 B:18 C:4 AB:1 BC:1 CA:1
Face 21: A:4 B:18 C:5 AB:1 BC:1 CA:1
Face 22: A:9 B:3 C:14 AB:1 BC:1 CA:1
Face 23: A:9 B:14 C:18 AB:1 BC:1 CA:1
Face 24: A:18 B:14 C:15 AB:1 BC:1 CA:1
Face 25: A:18 B:15 C:5 AB:1 BC:1 CA:1
Face 26: A:5 B:15 C:1 AB:1 BC:1 CA:1
Face 27: A:1 B:15 C:10 AB:1 BC:1 CA:1
Face 28: A:15 B:14 C:19 AB:1 BC:1 CA:1
Face 29: A:15 B:19 C:10 AB:1 BC:1 CA:1
Face 30: A:10 B:19 C:11 AB:1 BC:1 CA:1
Face 31: A:14 B:3 C:13 AB:1 BC:1 CA:1
Face 32: A:14 B:13 C:19 AB:1 BC:1 CA:1
Face 33: A:19 B:13 C:12 AB:1 BC:1 CA:1
Face 34: A:19 B:12 C:11 AB:1 BC:1 CA:1
Page 1
Face 35: A:11 B:12 C:2 AB:1 BC:1 CA:1
Page 2
Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216
Named object: "Object01"
Tri-mesh, Vertices: 20 Faces: 36
Vertex list:
Vertex 0: X: -210 Y: -432.781738 Z: 180.000031
Vertex 1: X: -610.810303 Y: 144.260559 Z: 103.580154
Vertex 2: X: 56.586655 Y: 144.260544 Z: -128.902023
Vertex 3: X: -75.776352 Y: 144.260605 Z: 565.321838
Vertex 4: X: -462.815979 Y: -347.937683 Z: 131.797302
Vertex 5: X: -616.506042 Y: -126.67173 Z: 102.494209
Vertex 6: X: -41.847229 Y: -347.937683 Z: -14.843644
Vertex 7: X: 60.375015 Y: -126.671753 Z: -133.291641
Vertex 8: X: -125.336807 Y: -347.937653 Z: 423.046448
Vertex 9: X: -73.868958 Y: -126.671692 Z: 570.797424
Vertex 10: X: -448.353271 Y: 237.304672 Z: -92.34951
Vertex 11: X: -192.440964 Y: 237.304672 Z: -181.494431
Vertex 12: X: 145.038193 Y: 237.304672 Z: 109.754745
Vertex 13: X: 94.283768 Y: 237.304688 Z: 375.953766
Vertex 14: X: -326.684937 Y: 237.304733 Z: 522.594727
Vertex 15: X: -531.842834 Y: 237.304718 Z: 345.540588
Vertex 16: X: -331.419525 Y: -225.964966 Z: -168.564438
Vertex 17: X: 152.575485 Y: -225.964935 Z: 249.129868
Vertex 18: X: -451.155914 Y: -225.964905 Z: 459.434662
Vertex 19: X: -298.413483 Y: 423.31897 Z: 163.142761
Face list:
Face 0: A:0 B:4 C:6 AB:1 BC:1 CA:1
Face 1: A:4 B:5 C:16 AB:1 BC:1 CA:1
Face 2: A:4 B:16 C:6 AB:1 BC:1 CA:1
Face 3: A:6 B:16 C:7 AB:1 BC:1 CA:1
Face 4: A:5 B:1 C:10 AB:1 BC:1 CA:1
Face 5: A:5 B:10 C:16 AB:1 BC:1 CA:1
Face 6: A:16 B:10 C:11 AB:1 BC:1 CA:1
Face 7: A:16 B:11 C:7 AB:1 BC:1 CA:1
Face 8: A:7 B:11 C:2 AB:1 BC:1 CA:1
Face 9: A:0 B:6 C:8 AB:1 BC:1 CA:1
Face 10: A:6 B:7 C:17 AB:1 BC:1 CA:1
Face 11: A:6 B:17 C:8 AB:1 BC:1 CA:1
Face 12: A:8 B:17 C:9 AB:1 BC:1 CA:1
Face 13: A:7 B:2 C:12 AB:1 BC:1 CA:1
Face 14: A:7 B:12 C:17 AB:1 BC:1 CA:1
Face 15: A:17 B:12 C:13 AB:1 BC:1 CA:1
Face 16: A:17 B:13 C:9 AB:1 BC:1 CA:1
Face 17: A:9 B:13 C:3 AB:1 BC:1 CA:1
Face 18: A:0 B:8 C:4 AB:1 BC:1 CA:1
Face 19: A:8 B:9 C:18 AB:1 BC:1 CA:1
Face 20: A:8 B:18 C:4 AB:1 BC:1 CA:1
Face 21: A:4 B:18 C:5 AB:1 BC:1 CA:1
Face 22: A:9 B:3 C:14 AB:1 BC:1 CA:1
Face 23: A:9 B:14 C:18 AB:1 BC:1 CA:1
Face 24: A:18 B:14 C:15 AB:1 BC:1 CA:1
Face 25: A:18 B:15 C:5 AB:1 BC:1 CA:1
Face 26: A:5 B:15 C:1 AB:1 BC:1 CA:1
Face 27: A:1 B:15 C:10 AB:1 BC:1 CA:1
Face 28: A:15 B:14 C:19 AB:1 BC:1 CA:1
Face 29: A:15 B:19 C:10 AB:1 BC:1 CA:1
Face 30: A:10 B:19 C:11 AB:1 BC:1 CA:1
Face 31: A:14 B:3 C:13 AB:1 BC:1 CA:1
Face 32: A:14 B:13 C:19 AB:1 BC:1 CA:1
Face 33: A:19 B:13 C:12 AB:1 BC:1 CA:1
Face 34: A:19 B:12 C:11 AB:1 BC:1 CA:1
Page 1
Face 35: A:11 B:12 C:2 AB:1 BC:1 CA:1
Page 2

View file

@ -1,264 +1,264 @@
Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216
Named object: "Object01"
Tri-mesh, Vertices: 40 Faces: 80
Vertex list:
Vertex 0: X: -50.170624 Y: -0.000026 Z: -240.147842
Vertex 1: X: -80.584503 Y: -63.958851 Z: -205.014572
Vertex 2: X: -129.795166 Y: -39.528744 Z: -148.16774
Vertex 3: X: -129.795166 Y: 39.528721 Z: -148.16774
Vertex 4: X: -80.584503 Y: 63.958797 Z: -205.014572
Vertex 5: X: 85.963654 Y: -0.000002 Z: 31.490465
Vertex 6: X: 39.614838 Y: -63.958828 Z: 34.827602
Vertex 7: X: -35.37915 Y: -39.528728 Z: 40.227196
Vertex 8: X: -35.37912 Y: 39.528736 Z: 40.227188
Vertex 9: X: 39.614838 Y: 63.95882 Z: 34.827595
Vertex 10: X: -9.852051 Y: 0.000023 Z: 319.829254
Vertex 11: X: -44.985352 Y: -63.958805 Z: 289.415405
Vertex 12: X: -101.832199 Y: -39.528709 Z: 240.204758
Vertex 13: X: -101.832184 Y: 39.528755 Z: 240.204773
Vertex 14: X: -44.985352 Y: 63.958843 Z: 289.415405
Vertex 15: X: -281.490326 Y: 0.000035 Z: 455.963654
Vertex 16: X: -284.827484 Y: -63.958794 Z: 409.614868
Vertex 17: X: -290.227112 Y: -39.528702 Z: 334.62085
Vertex 18: X: -290.227112 Y: 39.528763 Z: 334.62088
Vertex 19: X: -284.827484 Y: 63.958855 Z: 409.614838
Vertex 20: X: -569.829163 Y: 0.000026 Z: 360.14798
Vertex 21: X: -539.415344 Y: -63.958801 Z: 325.014709
Vertex 22: X: -490.204712 Y: -39.528709 Z: 268.167847
Vertex 23: X: -490.204712 Y: 39.528755 Z: 268.167847
Vertex 24: X: -539.415344 Y: 63.958847 Z: 325.014679
Vertex 25: X: -705.963684 Y: 0.000002 Z: 88.509598
Vertex 26: X: -659.614807 Y: -63.958824 Z: 85.172462
Vertex 27: X: -584.62085 Y: -39.528725 Z: 79.77285
Vertex 28: X: -584.62085 Y: 39.52874 Z: 79.77285
Vertex 29: X: -659.614868 Y: 63.958824 Z: 85.172447
Vertex 30: X: -610.147827 Y: -0.000023 Z: -199.829361
Vertex 31: X: -575.014587 Y: -63.958847 Z: -169.415497
Vertex 32: X: -518.167725 Y: -39.528744 Z: -120.204819
Vertex 33: X: -518.167725 Y: 39.528721 Z: -120.204834
Vertex 34: X: -575.014587 Y: 63.958801 Z: -169.415497
Vertex 35: X: -338.509338 Y: -0.000035 Z: -335.963745
Vertex 36: X: -335.172241 Y: -63.958858 Z: -289.614868
Vertex 37: X: -329.772675 Y: -39.528751 Z: -214.620865
Vertex 38: X: -329.772675 Y: 39.528713 Z: -214.620865
Vertex 39: X: -335.172241 Y: 63.95879 Z: -289.614899
Face list:
Face 0: A:0 B:6 C:1 AB:0 BC:1 CA:1
Smoothing: 1
Face 1: A:0 B:5 C:6 AB:1 BC:1 CA:0
Smoothing: 1
Face 2: A:1 B:7 C:2 AB:0 BC:1 CA:1
Smoothing: 2
Face 3: A:1 B:6 C:7 AB:1 BC:1 CA:0
Smoothing: 2
Face 4: A:2 B:8 C:3 AB:0 BC:1 CA:1
Smoothing: 3
Face 5: A:2 B:7 C:8 AB:1 BC:1 CA:0
Smoothing: 3
Face 6: A:3 B:9 C:4 AB:0 BC:1 CA:1
Smoothing: 4
Face 7: A:3 B:8 C:9 AB:1 BC:1 CA:0
Page 1
Smoothing: 4
Face 8: A:4 B:5 C:0 AB:0 BC:1 CA:1
Smoothing: 5
Face 9: A:4 B:9 C:5 AB:1 BC:1 CA:0
Smoothing: 5
Face 10: A:5 B:11 C:6 AB:0 BC:1 CA:1
Smoothing: 6
Face 11: A:5 B:10 C:11 AB:1 BC:1 CA:0
Smoothing: 6
Face 12: A:6 B:12 C:7 AB:0 BC:1 CA:1
Smoothing: 7
Face 13: A:6 B:11 C:12 AB:1 BC:1 CA:0
Smoothing: 7
Face 14: A:7 B:13 C:8 AB:0 BC:1 CA:1
Smoothing: 8
Face 15: A:7 B:12 C:13 AB:1 BC:1 CA:0
Smoothing: 8
Face 16: A:8 B:14 C:9 AB:0 BC:1 CA:1
Smoothing: 9
Face 17: A:8 B:13 C:14 AB:1 BC:1 CA:0
Smoothing: 9
Face 18: A:9 B:10 C:5 AB:0 BC:1 CA:1
Smoothing: 10
Face 19: A:9 B:14 C:10 AB:1 BC:1 CA:0
Smoothing: 10
Face 20: A:10 B:16 C:11 AB:0 BC:1 CA:1
Smoothing: 11
Face 21: A:10 B:15 C:16 AB:1 BC:1 CA:0
Smoothing: 11
Face 22: A:11 B:17 C:12 AB:0 BC:1 CA:1
Smoothing: 12
Face 23: A:11 B:16 C:17 AB:1 BC:1 CA:0
Smoothing: 12
Face 24: A:12 B:18 C:13 AB:0 BC:1 CA:1
Smoothing: 13
Face 25: A:12 B:17 C:18 AB:1 BC:1 CA:0
Smoothing: 13
Face 26: A:13 B:19 C:14 AB:0 BC:1 CA:1
Smoothing: 14
Face 27: A:13 B:18 C:19 AB:1 BC:1 CA:0
Smoothing: 14
Face 28: A:14 B:15 C:10 AB:0 BC:1 CA:1
Smoothing: 15
Face 29: A:14 B:19 C:15 AB:1 BC:1 CA:0
Smoothing: 15
Face 30: A:15 B:21 C:16 AB:0 BC:1 CA:1
Smoothing: 16
Face 31: A:15 B:20 C:21 AB:1 BC:1 CA:0
Smoothing: 16
Face 32: A:16 B:22 C:17 AB:0 BC:1 CA:1
Smoothing: 17
Face 33: A:16 B:21 C:22 AB:1 BC:1 CA:0
Smoothing: 17
Face 34: A:17 B:23 C:18 AB:0 BC:1 CA:1
Smoothing: 18
Face 35: A:17 B:22 C:23 AB:1 BC:1 CA:0
Smoothing: 18
Face 36: A:18 B:24 C:19 AB:0 BC:1 CA:1
Smoothing: 19
Face 37: A:18 B:23 C:24 AB:1 BC:1 CA:0
Smoothing: 19
Page 2
Face 38: A:19 B:20 C:15 AB:0 BC:1 CA:1
Smoothing: 20
Face 39: A:19 B:24 C:20 AB:1 BC:1 CA:0
Smoothing: 20
Face 40: A:20 B:26 C:21 AB:0 BC:1 CA:1
Smoothing: 21
Face 41: A:20 B:25 C:26 AB:1 BC:1 CA:0
Smoothing: 21
Face 42: A:21 B:27 C:22 AB:0 BC:1 CA:1
Smoothing: 22
Face 43: A:21 B:26 C:27 AB:1 BC:1 CA:0
Smoothing: 22
Face 44: A:22 B:28 C:23 AB:0 BC:1 CA:1
Smoothing: 23
Face 45: A:22 B:27 C:28 AB:1 BC:1 CA:0
Smoothing: 23
Face 46: A:23 B:29 C:24 AB:0 BC:1 CA:1
Smoothing: 24
Face 47: A:23 B:28 C:29 AB:1 BC:1 CA:0
Smoothing: 24
Face 48: A:24 B:25 C:20 AB:0 BC:1 CA:1
Smoothing: 25
Face 49: A:24 B:29 C:25 AB:1 BC:1 CA:0
Smoothing: 25
Face 50: A:25 B:31 C:26 AB:0 BC:1 CA:1
Smoothing: 26
Face 51: A:25 B:30 C:31 AB:1 BC:1 CA:0
Smoothing: 26
Face 52: A:26 B:32 C:27 AB:0 BC:1 CA:1
Smoothing: 27
Face 53: A:26 B:31 C:32 AB:1 BC:1 CA:0
Smoothing: 27
Face 54: A:27 B:33 C:28 AB:0 BC:1 CA:1
Smoothing: 28
Face 55: A:27 B:32 C:33 AB:1 BC:1 CA:0
Smoothing: 28
Face 56: A:28 B:34 C:29 AB:0 BC:1 CA:1
Smoothing: 29
Face 57: A:28 B:33 C:34 AB:1 BC:1 CA:0
Smoothing: 29
Face 58: A:29 B:30 C:25 AB:0 BC:1 CA:1
Smoothing: 30
Face 59: A:29 B:34 C:30 AB:1 BC:1 CA:0
Smoothing: 30
Face 60: A:30 B:36 C:31 AB:0 BC:1 CA:1
Smoothing: 31
Face 61: A:30 B:35 C:36 AB:1 BC:1 CA:0
Smoothing: 31
Face 62: A:31 B:37 C:32 AB:0 BC:1 CA:1
Smoothing: 32
Face 63: A:31 B:36 C:37 AB:1 BC:1 CA:0
Smoothing: 32
Face 64: A:32 B:38 C:33 AB:0 BC:1 CA:1
Smoothing: 1
Face 65: A:32 B:37 C:38 AB:1 BC:1 CA:0
Smoothing: 1
Face 66: A:33 B:39 C:34 AB:0 BC:1 CA:1
Smoothing: 2
Face 67: A:33 B:38 C:39 AB:1 BC:1 CA:0
Smoothing: 2
Face 68: A:34 B:35 C:30 AB:0 BC:1 CA:1
Page 3
Smoothing: 3
Face 69: A:34 B:39 C:35 AB:1 BC:1 CA:0
Smoothing: 3
Face 70: A:35 B:1 C:36 AB:0 BC:1 CA:1
Smoothing: 4
Face 71: A:35 B:0 C:1 AB:1 BC:1 CA:0
Smoothing: 4
Face 72: A:36 B:2 C:37 AB:0 BC:1 CA:1
Smoothing: 5
Face 73: A:36 B:1 C:2 AB:1 BC:1 CA:0
Smoothing: 5
Face 74: A:37 B:3 C:38 AB:0 BC:1 CA:1
Smoothing: 6
Face 75: A:37 B:2 C:3 AB:1 BC:1 CA:0
Smoothing: 6
Face 76: A:38 B:4 C:39 AB:0 BC:1 CA:1
Smoothing: 7
Face 77: A:38 B:3 C:4 AB:1 BC:1 CA:0
Smoothing: 7
Face 78: A:39 B:0 C:35 AB:0 BC:1 CA:1
Smoothing: 8
Face 79: A:39 B:4 C:0 AB:1 BC:1 CA:0
Smoothing: 8
Page 4
Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216
Named object: "Object01"
Tri-mesh, Vertices: 40 Faces: 80
Vertex list:
Vertex 0: X: -50.170624 Y: -0.000026 Z: -240.147842
Vertex 1: X: -80.584503 Y: -63.958851 Z: -205.014572
Vertex 2: X: -129.795166 Y: -39.528744 Z: -148.16774
Vertex 3: X: -129.795166 Y: 39.528721 Z: -148.16774
Vertex 4: X: -80.584503 Y: 63.958797 Z: -205.014572
Vertex 5: X: 85.963654 Y: -0.000002 Z: 31.490465
Vertex 6: X: 39.614838 Y: -63.958828 Z: 34.827602
Vertex 7: X: -35.37915 Y: -39.528728 Z: 40.227196
Vertex 8: X: -35.37912 Y: 39.528736 Z: 40.227188
Vertex 9: X: 39.614838 Y: 63.95882 Z: 34.827595
Vertex 10: X: -9.852051 Y: 0.000023 Z: 319.829254
Vertex 11: X: -44.985352 Y: -63.958805 Z: 289.415405
Vertex 12: X: -101.832199 Y: -39.528709 Z: 240.204758
Vertex 13: X: -101.832184 Y: 39.528755 Z: 240.204773
Vertex 14: X: -44.985352 Y: 63.958843 Z: 289.415405
Vertex 15: X: -281.490326 Y: 0.000035 Z: 455.963654
Vertex 16: X: -284.827484 Y: -63.958794 Z: 409.614868
Vertex 17: X: -290.227112 Y: -39.528702 Z: 334.62085
Vertex 18: X: -290.227112 Y: 39.528763 Z: 334.62088
Vertex 19: X: -284.827484 Y: 63.958855 Z: 409.614838
Vertex 20: X: -569.829163 Y: 0.000026 Z: 360.14798
Vertex 21: X: -539.415344 Y: -63.958801 Z: 325.014709
Vertex 22: X: -490.204712 Y: -39.528709 Z: 268.167847
Vertex 23: X: -490.204712 Y: 39.528755 Z: 268.167847
Vertex 24: X: -539.415344 Y: 63.958847 Z: 325.014679
Vertex 25: X: -705.963684 Y: 0.000002 Z: 88.509598
Vertex 26: X: -659.614807 Y: -63.958824 Z: 85.172462
Vertex 27: X: -584.62085 Y: -39.528725 Z: 79.77285
Vertex 28: X: -584.62085 Y: 39.52874 Z: 79.77285
Vertex 29: X: -659.614868 Y: 63.958824 Z: 85.172447
Vertex 30: X: -610.147827 Y: -0.000023 Z: -199.829361
Vertex 31: X: -575.014587 Y: -63.958847 Z: -169.415497
Vertex 32: X: -518.167725 Y: -39.528744 Z: -120.204819
Vertex 33: X: -518.167725 Y: 39.528721 Z: -120.204834
Vertex 34: X: -575.014587 Y: 63.958801 Z: -169.415497
Vertex 35: X: -338.509338 Y: -0.000035 Z: -335.963745
Vertex 36: X: -335.172241 Y: -63.958858 Z: -289.614868
Vertex 37: X: -329.772675 Y: -39.528751 Z: -214.620865
Vertex 38: X: -329.772675 Y: 39.528713 Z: -214.620865
Vertex 39: X: -335.172241 Y: 63.95879 Z: -289.614899
Face list:
Face 0: A:0 B:6 C:1 AB:0 BC:1 CA:1
Smoothing: 1
Face 1: A:0 B:5 C:6 AB:1 BC:1 CA:0
Smoothing: 1
Face 2: A:1 B:7 C:2 AB:0 BC:1 CA:1
Smoothing: 2
Face 3: A:1 B:6 C:7 AB:1 BC:1 CA:0
Smoothing: 2
Face 4: A:2 B:8 C:3 AB:0 BC:1 CA:1
Smoothing: 3
Face 5: A:2 B:7 C:8 AB:1 BC:1 CA:0
Smoothing: 3
Face 6: A:3 B:9 C:4 AB:0 BC:1 CA:1
Smoothing: 4
Face 7: A:3 B:8 C:9 AB:1 BC:1 CA:0
Page 1
Smoothing: 4
Face 8: A:4 B:5 C:0 AB:0 BC:1 CA:1
Smoothing: 5
Face 9: A:4 B:9 C:5 AB:1 BC:1 CA:0
Smoothing: 5
Face 10: A:5 B:11 C:6 AB:0 BC:1 CA:1
Smoothing: 6
Face 11: A:5 B:10 C:11 AB:1 BC:1 CA:0
Smoothing: 6
Face 12: A:6 B:12 C:7 AB:0 BC:1 CA:1
Smoothing: 7
Face 13: A:6 B:11 C:12 AB:1 BC:1 CA:0
Smoothing: 7
Face 14: A:7 B:13 C:8 AB:0 BC:1 CA:1
Smoothing: 8
Face 15: A:7 B:12 C:13 AB:1 BC:1 CA:0
Smoothing: 8
Face 16: A:8 B:14 C:9 AB:0 BC:1 CA:1
Smoothing: 9
Face 17: A:8 B:13 C:14 AB:1 BC:1 CA:0
Smoothing: 9
Face 18: A:9 B:10 C:5 AB:0 BC:1 CA:1
Smoothing: 10
Face 19: A:9 B:14 C:10 AB:1 BC:1 CA:0
Smoothing: 10
Face 20: A:10 B:16 C:11 AB:0 BC:1 CA:1
Smoothing: 11
Face 21: A:10 B:15 C:16 AB:1 BC:1 CA:0
Smoothing: 11
Face 22: A:11 B:17 C:12 AB:0 BC:1 CA:1
Smoothing: 12
Face 23: A:11 B:16 C:17 AB:1 BC:1 CA:0
Smoothing: 12
Face 24: A:12 B:18 C:13 AB:0 BC:1 CA:1
Smoothing: 13
Face 25: A:12 B:17 C:18 AB:1 BC:1 CA:0
Smoothing: 13
Face 26: A:13 B:19 C:14 AB:0 BC:1 CA:1
Smoothing: 14
Face 27: A:13 B:18 C:19 AB:1 BC:1 CA:0
Smoothing: 14
Face 28: A:14 B:15 C:10 AB:0 BC:1 CA:1
Smoothing: 15
Face 29: A:14 B:19 C:15 AB:1 BC:1 CA:0
Smoothing: 15
Face 30: A:15 B:21 C:16 AB:0 BC:1 CA:1
Smoothing: 16
Face 31: A:15 B:20 C:21 AB:1 BC:1 CA:0
Smoothing: 16
Face 32: A:16 B:22 C:17 AB:0 BC:1 CA:1
Smoothing: 17
Face 33: A:16 B:21 C:22 AB:1 BC:1 CA:0
Smoothing: 17
Face 34: A:17 B:23 C:18 AB:0 BC:1 CA:1
Smoothing: 18
Face 35: A:17 B:22 C:23 AB:1 BC:1 CA:0
Smoothing: 18
Face 36: A:18 B:24 C:19 AB:0 BC:1 CA:1
Smoothing: 19
Face 37: A:18 B:23 C:24 AB:1 BC:1 CA:0
Smoothing: 19
Page 2
Face 38: A:19 B:20 C:15 AB:0 BC:1 CA:1
Smoothing: 20
Face 39: A:19 B:24 C:20 AB:1 BC:1 CA:0
Smoothing: 20
Face 40: A:20 B:26 C:21 AB:0 BC:1 CA:1
Smoothing: 21
Face 41: A:20 B:25 C:26 AB:1 BC:1 CA:0
Smoothing: 21
Face 42: A:21 B:27 C:22 AB:0 BC:1 CA:1
Smoothing: 22
Face 43: A:21 B:26 C:27 AB:1 BC:1 CA:0
Smoothing: 22
Face 44: A:22 B:28 C:23 AB:0 BC:1 CA:1
Smoothing: 23
Face 45: A:22 B:27 C:28 AB:1 BC:1 CA:0
Smoothing: 23
Face 46: A:23 B:29 C:24 AB:0 BC:1 CA:1
Smoothing: 24
Face 47: A:23 B:28 C:29 AB:1 BC:1 CA:0
Smoothing: 24
Face 48: A:24 B:25 C:20 AB:0 BC:1 CA:1
Smoothing: 25
Face 49: A:24 B:29 C:25 AB:1 BC:1 CA:0
Smoothing: 25
Face 50: A:25 B:31 C:26 AB:0 BC:1 CA:1
Smoothing: 26
Face 51: A:25 B:30 C:31 AB:1 BC:1 CA:0
Smoothing: 26
Face 52: A:26 B:32 C:27 AB:0 BC:1 CA:1
Smoothing: 27
Face 53: A:26 B:31 C:32 AB:1 BC:1 CA:0
Smoothing: 27
Face 54: A:27 B:33 C:28 AB:0 BC:1 CA:1
Smoothing: 28
Face 55: A:27 B:32 C:33 AB:1 BC:1 CA:0
Smoothing: 28
Face 56: A:28 B:34 C:29 AB:0 BC:1 CA:1
Smoothing: 29
Face 57: A:28 B:33 C:34 AB:1 BC:1 CA:0
Smoothing: 29
Face 58: A:29 B:30 C:25 AB:0 BC:1 CA:1
Smoothing: 30
Face 59: A:29 B:34 C:30 AB:1 BC:1 CA:0
Smoothing: 30
Face 60: A:30 B:36 C:31 AB:0 BC:1 CA:1
Smoothing: 31
Face 61: A:30 B:35 C:36 AB:1 BC:1 CA:0
Smoothing: 31
Face 62: A:31 B:37 C:32 AB:0 BC:1 CA:1
Smoothing: 32
Face 63: A:31 B:36 C:37 AB:1 BC:1 CA:0
Smoothing: 32
Face 64: A:32 B:38 C:33 AB:0 BC:1 CA:1
Smoothing: 1
Face 65: A:32 B:37 C:38 AB:1 BC:1 CA:0
Smoothing: 1
Face 66: A:33 B:39 C:34 AB:0 BC:1 CA:1
Smoothing: 2
Face 67: A:33 B:38 C:39 AB:1 BC:1 CA:0
Smoothing: 2
Face 68: A:34 B:35 C:30 AB:0 BC:1 CA:1
Page 3
Smoothing: 3
Face 69: A:34 B:39 C:35 AB:1 BC:1 CA:0
Smoothing: 3
Face 70: A:35 B:1 C:36 AB:0 BC:1 CA:1
Smoothing: 4
Face 71: A:35 B:0 C:1 AB:1 BC:1 CA:0
Smoothing: 4
Face 72: A:36 B:2 C:37 AB:0 BC:1 CA:1
Smoothing: 5
Face 73: A:36 B:1 C:2 AB:1 BC:1 CA:0
Smoothing: 5
Face 74: A:37 B:3 C:38 AB:0 BC:1 CA:1
Smoothing: 6
Face 75: A:37 B:2 C:3 AB:1 BC:1 CA:0
Smoothing: 6
Face 76: A:38 B:4 C:39 AB:0 BC:1 CA:1
Smoothing: 7
Face 77: A:38 B:3 C:4 AB:1 BC:1 CA:0
Smoothing: 7
Face 78: A:39 B:0 C:35 AB:0 BC:1 CA:1
Smoothing: 8
Face 79: A:39 B:4 C:0 AB:1 BC:1 CA:0
Smoothing: 8
Page 4

View file

@ -30,6 +30,7 @@ SOURCES = \
bug_3050.c \
bug_3101.c \
bug_3195.c \
calibrate_rast.c \
copypixrate.c \
crossbar.c \
cva.c \

View file

@ -0,0 +1,395 @@
/*
* Automatic primitive rasterization precision test.
*
* Draw prims at various sub-pixel offsets and examine where the quad is
* actually drawn.
* Check if the range of offsets which paint the right pixels falls within
* OpenGL's specification.
* In case of failures, report the coordinate bias needed to fix the problem.
*
* Note that even Mesa/swrast fails some line tests. This is because some
* window coordinates wind up as 53.9999 instead of 54, for example. Enabling
* the small translation factor below fixes that. Revisit someday...
*
* Brian Paul
* 28 Feb 2008
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
static int Width = 100, Height = 100;
static int Win;
static float Step = 0.125;
#if 0
/* This tiny offset fixes errors in Mesa/Xlib */
static float Xtrans = 0.5 * 0.125;
static float Ytrans = 0.5 * 0.125;
#else
static float Xtrans = 0.0;
static float Ytrans = 0.0;
#endif
static void
PointCalibrate(int xpos, int ypos)
{
GLfloat rgba[4];
float x, y;
float xmin, ymin, xmax, ymax;
xmin = ymin = 1000.0;
xmax = ymax = -1000.0;
for (y = -1.0; y <= 1.0; y += Step) {
for (x = -1.0; x <= 1.0; x += Step) {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
glVertex2f(xpos + x, ypos + y);
glEnd();
glReadPixels(xpos, ypos, 1, 1, GL_RGBA, GL_FLOAT, rgba);
if (rgba[0] == 1.0 && rgba[1] == 1.0 && rgba[2] == 1.0) {
/* hit */
if (x < xmin)
xmin = x;
if (y < ymin)
ymin = y;
if (x > xmax)
xmax = x;
if (y > ymax)
ymax = y;
}
}
}
printf("Point at (%2d, %2d) drawn for x in [%6.3f, %6.3f] and y in [%6.3f, %6.3f]\n",
xpos, ypos,
xpos + xmin, xpos + xmax,
ypos + ymin, ypos + ymax);
if (xmax - xmin != 1.0 - Step) {
printf(" => Inconsistant X-axis rasterization!\n");
}
if (ymax - ymin != 1.0 - Step) {
printf(" => Inconsistant Y-axis rasterization!\n");
}
if (xmin < 0.0) {
printf(" => Points should be X biased by about %f\n", xmin);
}
if (ymin < 0.0) {
printf(" => Points should be Y biased by about %f\n", ymin);
}
if (xmax > 1.0) {
printf(" => Points should be X biased by about %f\n", 1.0 - xmax);
}
if (ymax > 1.0) {
printf(" => Points should be Y biased by about %f\n", 1.0 - ymax);
}
}
/**
* XXX Implement VLineCalibrate() someday
*/
static void
HLineCalibrate(int xpos, int ypos, int len)
{
GLfloat rgba[2][4];
float x, y;
float ymin, ymax;
float xmin_left, xmax_left, xmin_right, xmax_right;
xmin_left = xmin_right = 1000.0;
xmax_left = xmax_right = -1000.0;
ymin = 1000;
ymax = -1000.0;
/*
* First, check vertical positioning of the horizontal line
*/
for (y = -1.0; y <= 1.0; y += Step) {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2f(xpos, ypos + y);
glVertex2f(xpos + len, ypos + y);
glEnd();
glReadPixels(xpos + len / 2, ypos, 1, 1, GL_RGBA, GL_FLOAT, rgba);
if (rgba[0][0] == 1.0) {
/* hit */
if (y < ymin)
ymin = y;
if (y > ymax)
ymax = y;
}
}
printf("H-line at Y=%2d drawn for y in [%6.3f, %6.3f]\n",
ypos,
ypos + ymin, ypos + ymax);
if (ymax - ymin != 1.0 - Step) {
printf(" => Inconsistant Y-axis rasterization!\n");
}
if (ymin > 0.5 ) {
printf(" => Lines should be Y biased by about %f\n", ymin - 0.5);
}
if (ymax < 0.5 ) {
printf(" => Lines should be Y biased by about %f\n", 0.5 - ymax);
}
/*
* Second, check endpoints (for Y at 1/2 pixel)
*/
for (x = -1.0; x <= 1.0; x += Step) {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2f(xpos + x, ypos + 0.5f);
glVertex2f(xpos + x + len, ypos + 0.5f);
glEnd();
/* left end */
glReadPixels(xpos - 1, ypos, 2, 1, GL_RGBA, GL_FLOAT, rgba);
if (rgba[0][0] == 0.0 && rgba[1][0] == 1.0) {
/* hit */
if (x < xmin_left)
xmin_left = x;
if (x > xmax_left)
xmax_left = x;
}
/* right end */
glReadPixels(xpos + len - 1, ypos, 2, 1, GL_RGBA, GL_FLOAT, rgba);
if (rgba[0][0] == 1.0 && rgba[1][0] == 0.0) {
/* hit */
if (x < xmin_right)
xmin_right = x;
if (x > xmax_right)
xmax_right = x;
}
}
printf("H-line [%d..%d) hit left end for x in [%6.3f, %6.3f] "
"hit right end for x in [%6.3f, %6.3f]\n",
xpos, xpos + len,
xpos + xmin_left, xpos + xmax_left,
xpos + len + xmin_right, xpos + len + xmax_right);
if (xmax_left - xmin_left > 1.0 - Step) {
printf(" => Inconsistant left-end rasterization!\n");
}
if (xmax_right - xmin_right > 1.0 - Step) {
printf(" => Inconsistant right-end rasterization!\n");
}
if (xmin_left != xmin_right ||
xmax_left != xmax_right) {
printf(" => Inconsistant length!\n");
}
if (xmin_left < 0.0) {
printf(" => Coords should be X biased by about %f\n", xmin_left );
}
if (xmin_right < 0.0) {
printf(" => Coords should be X biased by about %f\n", xmin_right );
}
if (xmax_left >= 1.0) {
printf(" => Coords should be X biased by about %f\n", -xmax_right + 1.0);
}
if (xmax_right >= 1.0) {
printf(" => Coords should be X biased by about %f\n", -xmax_right + 1.0);
}
}
static void
QuadCalibrate(int xpos, int ypos, int width, int height)
{
GLfloat rgba1[2][4];
GLfloat rgba2[2][4];
float x, y;
float xmin, ymin, xmax, ymax;
xmin = ymin = 1000.0;
xmax = ymax = -1000.0;
for (y = -1.0; y <= 1.0; y += Step) {
for (x = -1.0; x <= 1.0; x += Step) {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glVertex2f(xpos + x, ypos + y);
glVertex2f(xpos + x + width, ypos + y);
glVertex2f(xpos + x + width, ypos + y + height);
glVertex2f(xpos + x, ypos + y + height);
glEnd();
/* horizontal measurement */
glReadPixels(xpos - 1, ypos + 2, 2, 1, GL_RGBA, GL_FLOAT, rgba1);
glReadPixels(xpos + width - 1, ypos + 2, 2, 1, GL_RGBA, GL_FLOAT, rgba2);
if (rgba1[0][0] == 0.0 && rgba1[1][0] == 1.0 &&
rgba2[0][0] == 1.0 && rgba2[1][0] == 0.0) {
if (x < xmin)
xmin = x;
if (x > xmax)
xmax = x;
}
/* vertical measurement */
glReadPixels(xpos + 2, ypos - 1, 1, 2, GL_RGBA, GL_FLOAT, rgba1);
glReadPixels(xpos + 2, ypos + height - 1, 1, 2, GL_RGBA, GL_FLOAT, rgba2);
if (rgba1[0][0] == 0.0 && rgba1[1][0] == 1.0 &&
rgba2[0][0] == 1.0 && rgba2[1][0] == 0.0) {
if (y < ymin)
ymin = y;
if (y > ymax)
ymax = y;
}
}
}
printf("Quad at (%2d, %2d)..(%2d, %2d) drawn"
" for x in [%6.3f, %6.3f] and y in [%6.3f, %6.3f]\n",
xpos, ypos,
xpos + width, ypos + height,
xpos + xmin, xpos + xmax,
ypos + ymin, ypos + ymax);
if (xmax - xmin != 1.0 - Step) {
printf(" => Inconsistant X-axis rasterization/size!\n");
}
if (ymax - ymin != 1.0 - Step) {
printf(" => Inconsistant Y-axis rasterization/size!\n");
}
if (xmin < -0.5) {
printf(" => Coords should be X biased by about %f\n", 0.5 + xmin );
}
if (ymin < -0.5) {
printf(" => Coords should be Y biased by about %f\n", 0.5 + ymin);
}
if (xmax > 0.5) {
printf(" => Coords should be X biased by about %f\n", -xmax + 0.5);
}
if (ymax > 0.5) {
printf(" => Coords should be Y biased by about %f\n", -ymax + 0.5);
}
}
/**
* Misc/disabled code for debugging.
*/
static void
DebugTest(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glColor3f(.5, .5, .5);
glBegin(GL_LINES);
glVertex2f(30, 35.5);
glVertex2f(54, 35.5);
glVertex2f(54, 35.5);
glVertex2f(66, 35.5);
glEnd();
glDisable(GL_BLEND);
glColor3f(1,1,1);
}
static void
Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glTranslatef(Xtrans, Ytrans, 0);
PointCalibrate(1, 1);
PointCalibrate(50, 50);
PointCalibrate(28, 17);
PointCalibrate(17, 18);
printf("\n");
HLineCalibrate(5, 10, 10);
HLineCalibrate(25, 22, 12);
HLineCalibrate(54, 33, 12);
HLineCalibrate(54+12, 33, 12);
printf("\n");
QuadCalibrate(2, 2, 10, 10);
QuadCalibrate(50, 50, 10, 10);
QuadCalibrate(28, 17, 12, 12);
QuadCalibrate(17, 28, 12, 12);
(void) DebugTest;
glPopMatrix();
glutSwapBuffers();
}
static void
Reshape(int width, int height)
{
Width = width;
Height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, 0, height, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void
Key(unsigned char key, int x, int y)
{
(void) x;
(void) y;
switch (key) {
case 27:
glutDestroyWindow(Win);
exit(0);
break;
}
glutPostRedisplay();
}
static void
Init(void)
{
printf("Measurement/callibration for basic prim rasterization...\n");
printf("GL_RENDERER: %s\n", (char*) glGetString(GL_RENDERER));
}
int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(Width, Height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
Win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Draw);
Init();
glutMainLoop();
return 0;
}

View file

@ -88,44 +88,44 @@ struct cso_cache;
struct cso_blend {
struct pipe_blend_state state;
void *data;
void (*delete_state)(void *, void *);
void *context;
void *data;
void (*delete_state)(struct pipe_context *, void *);
struct pipe_context *context;
};
struct cso_depth_stencil_alpha {
struct pipe_depth_stencil_alpha_state state;
void *data;
void (*delete_state)(void *, void *);
void *context;
void (*delete_state)(struct pipe_context *, void *);
struct pipe_context *context;
};
struct cso_rasterizer {
struct pipe_rasterizer_state state;
void *data;
void (*delete_state)(void *, void *);
void *context;
void (*delete_state)(struct pipe_context *, void *);
struct pipe_context *context;
};
struct cso_fragment_shader {
struct pipe_shader_state state;
void *data;
void (*delete_state)(void *, void *);
void *context;
void (*delete_state)(struct pipe_context *, void *);
struct pipe_context *context;
};
struct cso_vertex_shader {
struct pipe_shader_state state;
void *data;
void (*delete_state)(void *, void *);
void *context;
void (*delete_state)(struct pipe_context *, void *);
struct pipe_context *context;
};
struct cso_sampler {
struct pipe_sampler_state state;
void *data;
void (*delete_state)(void *, void *);
void *context;
void (*delete_state)(struct pipe_context *, void *);
struct pipe_context *context;
};

View file

@ -29,7 +29,9 @@ C_SOURCES = \
draw_vf.c \
draw_vf_generic.c \
draw_vf_sse.c \
draw_wide_prims.c
draw_wide_line.c \
draw_wide_point.c
include ../../Makefile.template

View file

@ -28,7 +28,8 @@ draw = env.ConvenienceLibrary(
'draw_vf.c',
'draw_vf_generic.c',
'draw_vf_sse.c',
'draw_wide_prims.c',
'draw_wide_point.c',
'draw_wide_line.c'
])
auxiliaries.insert(0, draw)

View file

@ -340,9 +340,11 @@ generate_aaline_fs(struct aaline_stage *aaline)
tgsi_dump(aaline_fs.tokens, 0);
#endif
#if 1 /* XXX remove */
aaline_fs.input_semantic_name[aaline_fs.num_inputs] = TGSI_SEMANTIC_GENERIC;
aaline_fs.input_semantic_index[aaline_fs.num_inputs] = transform.maxGeneric + 1;
aaline_fs.num_inputs++;
#endif
aaline->fs->aaline_fs
= aaline->driver_create_fs_state(aaline->pipe, &aaline_fs);
@ -362,6 +364,7 @@ static void
aaline_create_texture(struct aaline_stage *aaline)
{
struct pipe_context *pipe = aaline->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_texture texTemp;
uint level;
@ -374,7 +377,7 @@ aaline_create_texture(struct aaline_stage *aaline)
texTemp.depth[0] = 1;
texTemp.cpp = 1;
aaline->texture = pipe->texture_create(pipe, &texTemp);
aaline->texture = screen->texture_create(screen, &texTemp);
/* Fill in mipmap images.
* Basically each level is solid opaque, except for the outermost
@ -388,7 +391,7 @@ aaline_create_texture(struct aaline_stage *aaline)
assert(aaline->texture->width[level] == aaline->texture->height[level]);
surface = pipe->get_tex_surface(pipe, aaline->texture, 0, level, 0);
surface = screen->get_tex_surface(screen, aaline->texture, 0, level, 0);
data = pipe_surface_map(surface);
for (i = 0; i < size; i++) {

View file

@ -509,14 +509,16 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
(struct tgsi_token *) aapoint_fs.tokens,
MAX, &transform.base);
#if 1 /* DEBUG */
#if 0 /* DEBUG */
tgsi_dump(orig_fs->tokens, 0);
tgsi_dump(aapoint_fs.tokens, 0);
#endif
#if 1 /* XXX remove */
aapoint_fs.input_semantic_name[aapoint_fs.num_inputs] = TGSI_SEMANTIC_GENERIC;
aapoint_fs.input_semantic_index[aapoint_fs.num_inputs] = transform.maxGeneric + 1;
aapoint_fs.num_inputs++;
#endif
aapoint->fs->aapoint_fs
= aapoint->driver_create_fs_state(aapoint->pipe, &aapoint_fs);
@ -694,8 +696,8 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
/* find PSIZ vertex output */
const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i;
for (i = 0; i < vs->state->num_outputs; i++) {
if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
for (i = 0; i < vs->info.num_outputs; i++) {
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
aapoint->psize_slot = i;
break;
}

View file

@ -409,13 +409,13 @@ clip_init_state( struct draw_stage *stage )
clipper->flat = stage->draw->rasterizer->flatshade ? TRUE : FALSE;
if (clipper->flat) {
const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
uint i;
clipper->num_color_attribs = 0;
for (i = 0; i < vs->num_outputs; i++) {
if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
for (i = 0; i < vs->info.num_outputs; i++) {
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
clipper->color_attribs[clipper->num_color_attribs++] = i;
}
}

View file

@ -48,7 +48,8 @@ struct draw_context *draw_create( void )
#endif
/* create pipeline stages */
draw->pipeline.wide = draw_wide_stage( draw );
draw->pipeline.wide_line = draw_wide_line_stage( draw );
draw->pipeline.wide_point = draw_wide_point_stage( draw );
draw->pipeline.stipple = draw_stipple_stage( draw );
draw->pipeline.unfilled = draw_unfilled_stage( draw );
draw->pipeline.twoside = draw_twoside_stage( draw );
@ -80,8 +81,9 @@ struct draw_context *draw_create( void )
draw->shader_queue_flush = draw_vertex_shader_queue_flush;
draw->convert_wide_points = TRUE;
draw->convert_wide_lines = TRUE;
/* these defaults are oriented toward the needs of softpipe */
draw->wide_point_threshold = 1000000.0; /* infinity */
draw->wide_line_threshold = 1.0;
draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
@ -94,7 +96,8 @@ struct draw_context *draw_create( void )
void draw_destroy( struct draw_context *draw )
{
draw->pipeline.wide->destroy( draw->pipeline.wide );
draw->pipeline.wide_line->destroy( draw->pipeline.wide_line );
draw->pipeline.wide_point->destroy( draw->pipeline.wide_point );
draw->pipeline.stipple->destroy( draw->pipeline.stipple );
draw->pipeline.unfilled->destroy( draw->pipeline.unfilled );
draw->pipeline.twoside->destroy( draw->pipeline.twoside );
@ -220,26 +223,26 @@ draw_set_mapped_constant_buffer(struct draw_context *draw,
/**
* Tells the draw module whether to convert wide points (size != 1)
* into triangles.
* Tells the draw module to draw points with triangles if their size
* is greater than this threshold.
*/
void
draw_convert_wide_points(struct draw_context *draw, boolean enable)
draw_wide_point_threshold(struct draw_context *draw, float threshold)
{
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
draw->convert_wide_points = enable;
draw->wide_point_threshold = threshold;
}
/**
* Tells the draw module whether to convert wide lines (width != 1)
* into triangles.
* Tells the draw module to draw lines with triangles if their width
* is greater than this threshold.
*/
void
draw_convert_wide_lines(struct draw_context *draw, boolean enable)
draw_wide_line_threshold(struct draw_context *draw, float threshold)
{
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
draw->convert_wide_lines = enable;
draw->wide_line_threshold = threshold;
}
@ -262,11 +265,11 @@ int
draw_find_vs_output(struct draw_context *draw,
uint semantic_name, uint semantic_index)
{
const struct pipe_shader_state *vs = draw->vertex_shader->state;
const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i;
for (i = 0; i < vs->num_outputs; i++) {
if (vs->output_semantic_name[i] == semantic_name &&
vs->output_semantic_index[i] == semantic_index)
for (i = 0; i < vs->info.num_outputs; i++) {
if (vs->info.output_semantic_name[i] == semantic_name &&
vs->info.output_semantic_index[i] == semantic_index)
return i;
}
@ -281,6 +284,19 @@ draw_find_vs_output(struct draw_context *draw,
}
/**
* Return number of vertex shader outputs.
*/
uint
draw_num_vs_outputs(struct draw_context *draw)
{
uint count = draw->vertex_shader->info.num_outputs;
if (draw->extra_vp_outputs.slot >= 0)
count++;
return count;
}
/**
* Allocate space for temporary post-transform vertices, such as for clipping.
*/

View file

@ -90,9 +90,9 @@ void draw_set_rasterizer_state( struct draw_context *draw,
void draw_set_rasterize_stage( struct draw_context *draw,
struct draw_stage *stage );
void draw_convert_wide_points(struct draw_context *draw, boolean enable);
void draw_wide_point_threshold(struct draw_context *draw, float threshold);
void draw_convert_wide_lines(struct draw_context *draw, boolean enable);
void draw_wide_line_threshold(struct draw_context *draw, float threshold);
boolean draw_use_sse(struct draw_context *draw);
@ -110,6 +110,10 @@ int
draw_find_vs_output(struct draw_context *draw,
uint semantic_name, uint semantic_index);
uint
draw_num_vs_outputs(struct draw_context *draw);
/*
* Vertex shader functions

View file

@ -128,14 +128,14 @@ static void flatshade_point( struct draw_stage *stage,
static void flatshade_init_state( struct draw_stage *stage )
{
struct flat_stage *flat = flat_stage(stage);
const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
uint i;
/* Find which vertex shader outputs are colors, make a list */
flat->num_color_attribs = 0;
for (i = 0; i < vs->num_outputs; i++) {
if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
for (i = 0; i < vs->info.num_outputs; i++) {
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
flat->color_attribs[flat->num_color_attribs++] = i;
}
}

View file

@ -46,6 +46,7 @@
#include "rtasm/rtasm_x86sse.h"
#include "tgsi/exec/tgsi_exec.h"
#include "tgsi/util/tgsi_scan.h"
struct pipe_context;
@ -134,6 +135,8 @@ struct draw_vertex_shader {
*/
const struct pipe_shader_state *state;
struct tgsi_shader_info info;
void (*prepare)( struct draw_vertex_shader *shader,
struct draw_context *draw );
@ -183,7 +186,8 @@ struct draw_context
struct draw_stage *aapoint;
struct draw_stage *aaline;
struct draw_stage *pstipple;
struct draw_stage *wide;
struct draw_stage *wide_line;
struct draw_stage *wide_point;
struct draw_stage *rasterize;
} pipeline;
@ -215,8 +219,8 @@ struct draw_context
float plane[12][4];
unsigned nr_planes;
boolean convert_wide_points; /**< convert wide points to tris? */
boolean convert_wide_lines; /**< convert wide lines to tris? */
float wide_point_threshold; /**< convert pnts to tris if larger than this */
float wide_line_threshold; /**< convert lines to tris if wider than this */
boolean use_sse;
/* If a prim stage introduces new vertex attributes, they'll be stored here
@ -301,7 +305,8 @@ extern struct draw_stage *draw_clip_stage( struct draw_context *context );
extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
extern struct draw_stage *draw_cull_stage( struct draw_context *context );
extern struct draw_stage *draw_stipple_stage( struct draw_context *context );
extern struct draw_stage *draw_wide_stage( struct draw_context *context );
extern struct draw_stage *draw_wide_line_stage( struct draw_context *context );
extern struct draw_stage *draw_wide_point_stage( struct draw_context *context );
extern struct draw_stage *draw_validate_stage( struct draw_context *context );

View file

@ -330,11 +330,13 @@ generate_pstip_fs(struct pstip_stage *pstip)
pstip->sampler_unit = transform.maxSampler + 1;
#if 1 /* XXX remove */
if (transform.wincoordInput < 0) {
pstip_fs.input_semantic_name[pstip_fs.num_inputs] = TGSI_SEMANTIC_POSITION;
pstip_fs.input_semantic_index[pstip_fs.num_inputs] = (ubyte)transform.maxInput;
pstip_fs.num_inputs++;
}
#endif
pstip->fs->pstip_fs = pstip->driver_create_fs_state(pstip->pipe, &pstip_fs);
}
@ -348,12 +350,13 @@ pstip_update_texture(struct pstip_stage *pstip)
{
static const uint bit31 = 1 << 31;
struct pipe_context *pipe = pstip->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_surface *surface;
const uint *stipple = pstip->state.stipple->stipple;
uint i, j;
ubyte *data;
surface = pipe->get_tex_surface(pipe, pstip->texture, 0, 0, 0);
surface = screen->get_tex_surface(screen, pstip->texture, 0, 0, 0);
data = pipe_surface_map(surface);
/*
@ -389,6 +392,7 @@ static void
pstip_create_texture(struct pstip_stage *pstip)
{
struct pipe_context *pipe = pstip->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_texture texTemp;
memset(&texTemp, 0, sizeof(texTemp));
@ -400,7 +404,7 @@ pstip_create_texture(struct pstip_stage *pstip)
texTemp.depth[0] = 1;
texTemp.cpp = 1;
pstip->texture = pipe->texture_create(pipe, &texTemp);
pstip->texture = screen->texture_create(screen, &texTemp);
//pstip_update_texture(pstip);
}

View file

@ -119,7 +119,7 @@ static void twoside_first_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct twoside_stage *twoside = twoside_stage(stage);
const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
uint i;
twoside->attrib_front0 = 0;
@ -128,15 +128,15 @@ static void twoside_first_tri( struct draw_stage *stage,
twoside->attrib_back1 = 0;
/* Find which vertex shader outputs are front/back colors */
for (i = 0; i < vs->num_outputs; i++) {
if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
if (vs->output_semantic_index[i] == 0)
for (i = 0; i < vs->info.num_outputs; i++) {
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
if (vs->info.output_semantic_index[i] == 0)
twoside->attrib_front0 = i;
else
twoside->attrib_front1 = i;
}
if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
if (vs->output_semantic_index[i] == 0)
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
if (vs->info.output_semantic_index[i] == 0)
twoside->attrib_back0 = i;
else
twoside->attrib_back1 = i;

View file

@ -52,6 +52,18 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
*/
stage->next = next;
/* drawing wide lines? */
wide_lines = (draw->rasterizer->line_width > draw->wide_line_threshold
&& !draw->rasterizer->line_smooth);
/* drawing large points? */
if (draw->rasterizer->point_smooth && draw->pipeline.aapoint)
wide_points = FALSE;
else if (draw->rasterizer->point_size > draw->wide_point_threshold)
wide_points = TRUE;
else
wide_points = FALSE;
/*
* NOTE: we build up the pipeline in end-to-start order.
*
@ -69,21 +81,14 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
next = draw->pipeline.aapoint;
}
/* drawing wide lines? */
wide_lines = (draw->rasterizer->line_width != 1.0
&& draw->convert_wide_lines
&& !draw->rasterizer->line_smooth);
if (wide_lines) {
draw->pipeline.wide_line->next = next;
next = draw->pipeline.wide_line;
}
/* drawing large points? */
wide_points = (draw->rasterizer->point_size != 1.0
&& draw->convert_wide_points
&& !draw->pipeline.aapoint);
if (wide_lines ||
wide_points ||
draw->rasterizer->point_sprite) {
draw->pipeline.wide->next = next;
next = draw->pipeline.wide;
if (wide_points || draw->rasterizer->point_sprite) {
draw->pipeline.wide_point->next = next;
next = draw->pipeline.wide_point;
}
if (draw->rasterizer->line_stipple_enable) {

View file

@ -473,7 +473,7 @@ void draw_update_vertex_fetch( struct draw_context *draw )
if (!draw->vertex_shader)
return;
nr_attrs = draw->vertex_shader->state->num_inputs;
nr_attrs = draw->vertex_shader->info.num_inputs;
for (i = 0; i < nr_attrs; i++) {
unsigned buf = draw->vertex_element[i].vertex_buffer_index;

View file

@ -91,15 +91,16 @@ draw_create_vertex_shader(struct draw_context *draw,
struct draw_vertex_shader *vs;
vs = draw_create_vs_llvm( draw, shader );
if (vs)
return vs;
vs = draw_create_vs_sse( draw, shader );
if (vs)
return vs;
vs = draw_create_vs_exec( draw, shader );
if (!vs) {
vs = draw_create_vs_sse( draw, shader );
if (!vs) {
vs = draw_create_vs_exec( draw, shader );
}
}
assert(vs);
tgsi_scan_shader(shader->tokens, &vs->info);
return vs;
}
@ -111,7 +112,7 @@ draw_bind_vertex_shader(struct draw_context *draw,
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
draw->vertex_shader = dvs;
draw->num_vs_outputs = dvs->state->num_outputs;
draw->num_vs_outputs = dvs->info.num_outputs;
tgsi_exec_machine_init(&draw->machine);

View file

@ -103,7 +103,7 @@ vs_exec_run( struct draw_vertex_shader *shader,
const float *trans = draw->viewport.translate;
assert(count <= 4);
assert(draw->vertex_shader->state->output_semantic_name[0]
assert(draw->vertex_shader->info.output_semantic_name[0]
== TGSI_SEMANTIC_POSITION);
machine->Consts = (float (*)[4]) draw->user.constants;

View file

@ -119,7 +119,7 @@ vs_sse_run( struct draw_vertex_shader *base,
const float *trans = draw->viewport.translate;
assert(count <= 4);
assert(draw->vertex_shader->state->output_semantic_name[0]
assert(draw->vertex_shader->info.output_semantic_name[0]
== TGSI_SEMANTIC_POSITION);
/* Consts does not require 16 byte alignment. */

View file

@ -0,0 +1,187 @@
/**************************************************************************
*
* Copyright 2007 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, 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 TUNGSTEN GRAPHICS 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: Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
struct wideline_stage {
struct draw_stage stage;
float half_line_width;
};
static INLINE struct wideline_stage *wideline_stage( struct draw_stage *stage )
{
return (struct wideline_stage *)stage;
}
static void wideline_point( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->point( stage->next, header );
}
static void wideline_tri( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->tri(stage->next, header);
}
/**
* Draw a wide line by drawing a quad (two triangles).
* XXX need to disable polygon stipple.
*/
static void wideline_line( struct draw_stage *stage,
struct prim_header *header )
{
/*const struct wideline_stage *wide = wideline_stage(stage);*/
const float half_width = 0.5f * stage->draw->rasterizer->line_width;
struct prim_header tri;
struct vertex_header *v0 = dup_vert(stage, header->v[0], 0);
struct vertex_header *v1 = dup_vert(stage, header->v[0], 1);
struct vertex_header *v2 = dup_vert(stage, header->v[1], 2);
struct vertex_header *v3 = dup_vert(stage, header->v[1], 3);
float *pos0 = v0->data[0];
float *pos1 = v1->data[0];
float *pos2 = v2->data[0];
float *pos3 = v3->data[0];
const float dx = FABSF(pos0[0] - pos2[0]);
const float dy = FABSF(pos0[1] - pos2[1]);
/*
* Draw wide line as a quad (two tris) by "stretching" the line along
* X or Y.
* We need to tweak coords in several ways to be conformant here.
*/
if (dx > dy) {
/* x-major line */
pos0[1] = pos0[1] - half_width - 0.25f;
pos1[1] = pos1[1] + half_width - 0.25f;
pos2[1] = pos2[1] - half_width - 0.25f;
pos3[1] = pos3[1] + half_width - 0.25f;
if (pos0[0] < pos2[0]) {
/* left to right line */
pos0[0] -= 0.5f;
pos1[0] -= 0.5f;
pos2[0] -= 0.5f;
pos3[0] -= 0.5f;
}
else {
/* right to left line */
pos0[0] += 0.5f;
pos1[0] += 0.5f;
pos2[0] += 0.5f;
pos3[0] += 0.5f;
}
}
else {
/* y-major line */
pos0[0] = pos0[0] - half_width + 0.25f;
pos1[0] = pos1[0] + half_width + 0.25f;
pos2[0] = pos2[0] - half_width + 0.25f;
pos3[0] = pos3[0] + half_width + 0.25f;
if (pos0[1] < pos2[1]) {
/* top to bottom line */
pos0[1] -= 0.5f;
pos1[1] -= 0.5f;
pos2[1] -= 0.5f;
pos3[1] -= 0.5f;
}
else {
/* bottom to top line */
pos0[1] += 0.5f;
pos1[1] += 0.5f;
pos2[1] += 0.5f;
pos3[1] += 0.5f;
}
}
tri.det = header->det; /* only the sign matters */
tri.v[0] = v0;
tri.v[1] = v2;
tri.v[2] = v3;
stage->next->tri( stage->next, &tri );
tri.v[0] = v0;
tri.v[1] = v3;
tri.v[2] = v1;
stage->next->tri( stage->next, &tri );
}
static void wideline_flush( struct draw_stage *stage, unsigned flags )
{
stage->next->flush( stage->next, flags );
}
static void wideline_reset_stipple_counter( struct draw_stage *stage )
{
stage->next->reset_stipple_counter( stage->next );
}
static void wideline_destroy( struct draw_stage *stage )
{
draw_free_temp_verts( stage );
FREE( stage );
}
struct draw_stage *draw_wide_line_stage( struct draw_context *draw )
{
struct wideline_stage *wide = CALLOC_STRUCT(wideline_stage);
draw_alloc_temp_verts( &wide->stage, 4 );
wide->stage.draw = draw;
wide->stage.next = NULL;
wide->stage.point = wideline_point;
wide->stage.line = wideline_line;
wide->stage.tri = wideline_tri;
wide->stage.flush = wideline_flush;
wide->stage.reset_stipple_counter = wideline_reset_stipple_counter;
wide->stage.destroy = wideline_destroy;
return &wide->stage;
}

View file

@ -0,0 +1,257 @@
/**************************************************************************
*
* Copyright 2007 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, 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 TUNGSTEN GRAPHICS 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: Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
struct widepoint_stage {
struct draw_stage stage;
float half_point_size;
uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS];
uint texcoord_mode[PIPE_MAX_SHADER_OUTPUTS];
uint num_texcoords;
int psize_slot;
};
static INLINE struct widepoint_stage *
widepoint_stage( struct draw_stage *stage )
{
return (struct widepoint_stage *)stage;
}
static void passthrough_point( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->point( stage->next, header );
}
static void widepoint_line( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->line(stage->next, header);
}
static void widepoint_tri( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->tri(stage->next, header);
}
/**
* Set the vertex texcoords for sprite mode.
* Coords may be left untouched or set to a right-side-up or upside-down
* orientation.
*/
static void set_texcoords(const struct widepoint_stage *wide,
struct vertex_header *v, const float tc[4])
{
uint i;
for (i = 0; i < wide->num_texcoords; i++) {
if (wide->texcoord_mode[i] != PIPE_SPRITE_COORD_NONE) {
uint j = wide->texcoord_slot[i];
v->data[j][0] = tc[0];
if (wide->texcoord_mode[i] == PIPE_SPRITE_COORD_LOWER_LEFT)
v->data[j][1] = 1.0f - tc[1];
else
v->data[j][1] = tc[1];
v->data[j][2] = tc[2];
v->data[j][3] = tc[3];
}
}
}
/* If there are lots of sprite points (and why wouldn't there be?) it
* would probably be more sensible to change hardware setup to
* optimize this rather than doing the whole thing in software like
* this.
*/
static void widepoint_point( struct draw_stage *stage,
struct prim_header *header )
{
const struct widepoint_stage *wide = widepoint_stage(stage);
const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
float half_size;
float left_adj, right_adj;
struct prim_header tri;
/* four dups of original vertex */
struct vertex_header *v0 = dup_vert(stage, header->v[0], 0);
struct vertex_header *v1 = dup_vert(stage, header->v[0], 1);
struct vertex_header *v2 = dup_vert(stage, header->v[0], 2);
struct vertex_header *v3 = dup_vert(stage, header->v[0], 3);
float *pos0 = v0->data[0];
float *pos1 = v1->data[0];
float *pos2 = v2->data[0];
float *pos3 = v3->data[0];
/* point size is either per-vertex or fixed size */
if (wide->psize_slot >= 0) {
half_size = 0.5f * header->v[0]->data[wide->psize_slot][0];
}
else {
half_size = wide->half_point_size;
}
left_adj = -half_size; /* + 0.25f;*/
right_adj = half_size; /* + 0.25f;*/
pos0[0] += left_adj;
pos0[1] -= half_size;
pos1[0] += left_adj;
pos1[1] += half_size;
pos2[0] += right_adj;
pos2[1] -= half_size;
pos3[0] += right_adj;
pos3[1] += half_size;
if (sprite) {
static const float tex00[4] = { 0, 0, 0, 1 };
static const float tex01[4] = { 0, 1, 0, 1 };
static const float tex11[4] = { 1, 1, 0, 1 };
static const float tex10[4] = { 1, 0, 0, 1 };
set_texcoords( wide, v0, tex00 );
set_texcoords( wide, v1, tex01 );
set_texcoords( wide, v2, tex10 );
set_texcoords( wide, v3, tex11 );
}
tri.det = header->det; /* only the sign matters */
tri.v[0] = v0;
tri.v[1] = v2;
tri.v[2] = v3;
stage->next->tri( stage->next, &tri );
tri.v[0] = v0;
tri.v[1] = v3;
tri.v[2] = v1;
stage->next->tri( stage->next, &tri );
}
static void widepoint_first_point( struct draw_stage *stage,
struct prim_header *header )
{
struct widepoint_stage *wide = widepoint_stage(stage);
struct draw_context *draw = stage->draw;
wide->half_point_size = 0.5f * draw->rasterizer->point_size;
/* XXX we won't know the real size if it's computed by the vertex shader! */
if (draw->rasterizer->point_size > draw->wide_point_threshold) {
stage->point = widepoint_point;
}
else {
stage->point = passthrough_point;
}
if (draw->rasterizer->point_sprite) {
/* find vertex shader texcoord outputs */
const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i, j = 0;
for (i = 0; i < vs->info.num_outputs; i++) {
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
wide->texcoord_slot[j] = i;
wide->texcoord_mode[j] = draw->rasterizer->sprite_coord_mode[j];
j++;
}
}
wide->num_texcoords = j;
}
wide->psize_slot = -1;
if (draw->rasterizer->point_size_per_vertex) {
/* find PSIZ vertex output */
const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i;
for (i = 0; i < vs->info.num_outputs; i++) {
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
wide->psize_slot = i;
break;
}
}
}
stage->point( stage, header );
}
static void widepoint_flush( struct draw_stage *stage, unsigned flags )
{
stage->point = widepoint_first_point;
stage->next->flush( stage->next, flags );
}
static void widepoint_reset_stipple_counter( struct draw_stage *stage )
{
stage->next->reset_stipple_counter( stage->next );
}
static void widepoint_destroy( struct draw_stage *stage )
{
draw_free_temp_verts( stage );
FREE( stage );
}
struct draw_stage *draw_wide_point_stage( struct draw_context *draw )
{
struct widepoint_stage *wide = CALLOC_STRUCT(widepoint_stage);
draw_alloc_temp_verts( &wide->stage, 4 );
wide->stage.draw = draw;
wide->stage.next = NULL;
wide->stage.point = widepoint_first_point;
wide->stage.line = widepoint_line;
wide->stage.tri = widepoint_tri;
wide->stage.flush = widepoint_flush;
wide->stage.reset_stipple_counter = widepoint_reset_stipple_counter;
wide->stage.destroy = widepoint_destroy;
return &wide->stage;
}

View file

@ -219,8 +219,8 @@ static void wide_point( struct draw_stage *stage,
half_size = wide->half_point_size;
}
left_adj = -half_size + 0.25f;
right_adj = half_size + 0.25f;
left_adj = -half_size; /* + 0.25f;*/
right_adj = half_size; /* + 0.25f;*/
pos0[0] += left_adj;
pos0[1] -= half_size;
@ -266,7 +266,8 @@ static void wide_first_point( struct draw_stage *stage,
wide->half_point_size = 0.5f * draw->rasterizer->point_size;
if (draw->rasterizer->point_size != 1.0) {
/* XXX we won't know the real size if it's computed by the vertex shader! */
if (draw->rasterizer->point_size > draw->wide_point_threshold) {
stage->point = wide_point;
}
else {
@ -277,8 +278,8 @@ static void wide_first_point( struct draw_stage *stage,
/* find vertex shader texcoord outputs */
const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i, j = 0;
for (i = 0; i < vs->state->num_outputs; i++) {
if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
for (i = 0; i < vs->info.num_outputs; i++) {
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
wide->texcoord_slot[j] = i;
wide->texcoord_mode[j] = draw->rasterizer->sprite_coord_mode[j];
j++;
@ -293,8 +294,8 @@ static void wide_first_point( struct draw_stage *stage,
/* find PSIZ vertex output */
const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i;
for (i = 0; i < vs->state->num_outputs; i++) {
if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
for (i = 0; i < vs->info.num_outputs; i++) {
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
wide->psize_slot = i;
break;
}

View file

@ -97,7 +97,7 @@ void gallivm_cpu_engine_delete(struct gallivm_cpu_engine *ee);
#endif /* MESA_LLVM */
#if defined __cplusplus
} // extern "C"
}
#endif
#endif

View file

@ -32,7 +32,7 @@ struct gallivm_ir {
int num_components;
int num_consts;
//FIXME: this might not be enough for some shaders
/* FIXME: this might not be enough for some shaders */
struct gallivm_interpolate interpolators[32*4];
int num_interp;
};
@ -46,7 +46,7 @@ struct gallivm_prog {
int num_consts;
//FIXME: this might not be enough for some shaders
/* FIXME: this might not be enough for some shaders */
struct gallivm_interpolate interpolators[32*4];
int num_interp;
};
@ -104,7 +104,7 @@ static INLINE int gallivm_w_swizzle(int swizzle)
#endif /* MESA_LLVM */
#if defined __cplusplus
} // extern "C"
}
#endif
#endif

View file

@ -37,7 +37,7 @@
* There is no obligation of a winsys driver to use this library. And a pipe
* driver should be completly agnostic about it.
*
* \author José Fonseca <jrfonseca@tungstengraphics.com>
* \author Jos<EFBFBD> Fonseca <jrfonseca@tungstengraphics.com>
*/
#ifndef PB_BUFFER_H_
@ -50,6 +50,11 @@
#include "pipe/p_inlines.h"
#ifdef __cplusplus
extern "C" {
#endif
struct pb_vtbl;
/**
@ -200,4 +205,8 @@ void
pb_init_winsys(struct pipe_winsys *winsys);
#ifdef __cplusplus
}
#endif
#endif /*PB_BUFFER_H_*/

View file

@ -44,7 +44,7 @@
* Between the handle's destruction, and the fence signalling, the buffer is
* stored in a fenced buffer list.
*
* \author José Fonseca <jrfonseca@tungstengraphics.com>
* \author José Fonseca <jrfonseca@tungstengraphics.com>
*/
#ifndef PB_BUFFER_FENCED_H_
@ -54,6 +54,11 @@
#include "pipe/p_debug.h"
#ifdef __cplusplus
extern "C" {
#endif
struct pipe_winsys;
struct pipe_buffer;
struct pipe_fence_handle;
@ -114,4 +119,8 @@ buffer_fence(struct pb_buffer *buf,
struct pipe_fence_handle *fence);
#ifdef __cplusplus
}
#endif
#endif /*PB_BUFFER_FENCED_H_*/

View file

@ -43,7 +43,7 @@
* - the fenced buffer manager, which will delay buffer destruction until the
* the moment the card finishing processing it.
*
* \author José Fonseca <jrfonseca@tungstengraphics.com>
* \author José Fonseca <jrfonseca@tungstengraphics.com>
*/
#ifndef PB_BUFMGR_H_
@ -53,6 +53,11 @@
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
struct pb_desc;
struct pipe_buffer;
struct pipe_winsys;
@ -123,4 +128,8 @@ fenced_bufmgr_create(struct pb_manager *provider,
struct pipe_winsys *winsys);
#ifdef __cplusplus
}
#endif
#endif /*PB_BUFMGR_H_*/

View file

@ -1268,7 +1268,7 @@ emit_store(
break;
case TGSI_SAT_ZERO_ONE:
// assert( 0 );
/* assert( 0 ); */
break;
case TGSI_SAT_MINUS_PLUS_ONE:
@ -2268,7 +2268,7 @@ tgsi_emit_sse2(
&parse.FullToken.FullInstruction );
if (!ok) {
debug_printf("failed to translate tgsi opcode %d\n",
debug_printf("failed to translate tgsi opcode %d to SSE\n",
parse.FullToken.FullInstruction.Instruction.Opcode );
}
break;
@ -2276,7 +2276,7 @@ tgsi_emit_sse2(
case TGSI_TOKEN_TYPE_IMMEDIATE:
/* XXX implement this */
ok = 0;
debug_printf("failed to emit immediate value\n");
debug_printf("failed to emit immediate value to SSE\n");
break;
default:
@ -2358,7 +2358,7 @@ tgsi_emit_sse2_fs(
&parse.FullToken.FullInstruction );
if (!ok) {
debug_printf("failed to translate tgsi opcode %d\n",
debug_printf("failed to translate tgsi opcode %d to SSE\n",
parse.FullToken.FullInstruction.Instruction.Opcode );
}
break;
@ -2366,7 +2366,7 @@ tgsi_emit_sse2_fs(
case TGSI_TOKEN_TYPE_IMMEDIATE:
/* XXX implement this */
ok = 0;
debug_printf("failed to emit immediate value\n");
debug_printf("failed to emit immediate value to SSE\n");
break;
default:

View file

@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
#endif
struct tgsi_token;
struct x86_function;
@ -19,8 +19,8 @@ tgsi_emit_sse2_fs(
struct x86_function *function );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
}
#endif
#endif // !defined TGSI_SSE2_H
#endif /* TGSI_SSE2_H */

View file

@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
#endif
/*
* version
@ -313,8 +313,8 @@ tgsi_build_dst_register_ext_modulate(
struct tgsi_header *header );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
}
#endif
#endif // !defined TGSI_BUILD_H
#endif /* TGSI_BUILD_H */

View file

@ -664,6 +664,19 @@ static const char *TGSI_TEXTURES[] =
"TEXTURE_SHADOWRECT"
};
static const char *TGSI_TEXTURES_SHORT[] =
{
"UNKNOWN",
"1D",
"2D",
"3D",
"CUBE",
"RECT",
"SHADOW1D",
"SHADOW2D",
"SHADOWRECT"
};
static const char *TGSI_SRC_REGISTER_EXTS[] =
{
"SRC_REGISTER_EXT_TYPE_SWZ",
@ -1037,6 +1050,11 @@ dump_instruction_short(
first_reg = FALSE;
}
if (inst->InstructionExtTexture.Texture != TGSI_TEXTURE_UNKNOWN) {
TXT( ", " );
ENM( inst->InstructionExtTexture.Texture, TGSI_TEXTURES_SHORT );
}
switch( inst->Instruction.Opcode ) {
case TGSI_OPCODE_IF:
case TGSI_OPCODE_ELSE:

View file

@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
#endif
#define TGSI_DUMP_VERBOSE 1
#define TGSI_DUMP_NO_IGNORED 2
@ -21,8 +21,8 @@ tgsi_dump_str(
unsigned flags );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
}
#endif
#endif // !defined TGSI_DUMP_H
#endif /* TGSI_DUMP_H */

View file

@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
#endif
struct tgsi_full_version
{
@ -114,8 +114,8 @@ tgsi_parse_token(
struct tgsi_parse_context *ctx );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
}
#endif
#endif // !defined TGSI_PARSE_H
#endif /* TGSI_PARSE_H */

View file

@ -37,6 +37,7 @@
#include "tgsi/util/tgsi_parse.h"
#include "tgsi/util/tgsi_build.h"
#include "pipe/p_util.h"
@ -46,10 +47,12 @@ void
tgsi_scan_shader(const struct tgsi_token *tokens,
struct tgsi_shader_info *info)
{
uint procType;
uint procType, i;
struct tgsi_parse_context parse;
memset(info, 0, sizeof(*info));
for (i = 0; i < TGSI_FILE_COUNT; i++)
info->file_max[i] = -1;
/**
** Setup to begin parsing input shader
@ -69,6 +72,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
*/
while( !tgsi_parse_end_of_tokens( &parse ) ) {
info->num_tokens++;
tgsi_parse_token( &parse );
switch( parse.FullToken.Token.Type ) {
@ -91,8 +96,27 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
for (i = fulldecl->u.DeclarationRange.First;
i <= fulldecl->u.DeclarationRange.Last;
i++) {
/* only first 32 regs will appear in this bitfield */
info->file_mask[file] |= (1 << i);
info->file_count[file]++;
info->file_max[file] = MAX2(info->file_max[file], (int)i);
if (file == TGSI_FILE_INPUT) {
info->input_semantic_name[info->num_inputs]
= (ubyte)fulldecl->Semantic.SemanticName;
info->input_semantic_index[info->num_inputs]
= (ubyte)fulldecl->Semantic.SemanticIndex;
info->num_inputs++;
}
if (file == TGSI_FILE_OUTPUT) {
info->output_semantic_name[info->num_outputs]
= (ubyte)fulldecl->Semantic.SemanticName;
info->output_semantic_index[info->num_outputs]
= (ubyte)fulldecl->Semantic.SemanticIndex;
info->num_outputs++;
}
/* special case */
if (procType == TGSI_PROCESSOR_FRAGMENT &&
@ -113,5 +137,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
}
}
info->uses_kill = (info->opcode_count[TGSI_OPCODE_KIL] ||
info->opcode_count[TGSI_OPCODE_KILP]);
tgsi_parse_free (&parse);
}

View file

@ -29,7 +29,8 @@
#define TGSI_SCAN_H
#include "pipe/p_util.h"
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
@ -38,14 +39,26 @@
*/
struct tgsi_shader_info
{
uint num_tokens;
/* XXX eventually remove the corresponding fields from pipe_shader_state: */
ubyte num_inputs;
ubyte num_outputs;
ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */
ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
uint file_mask[TGSI_FILE_COUNT]; /**< bitmask of declared registers */
uint file_count[TGSI_FILE_COUNT]; /**< number of declared registers */
int file_max[TGSI_FILE_COUNT]; /**< highest index of declared registers */
uint immediate_count; /**< number of immediates declared */
uint opcode_count[TGSI_OPCODE_LAST]; /**< opcode histogram */
boolean writes_z; /**< does fragment shader write Z value? */
boolean uses_kill; /**< KIL or KILP instruction used? */
};

View file

@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
#endif
void *
tgsi_align_128bit(
@ -63,8 +63,8 @@ tgsi_util_set_full_src_register_sign_mode(
unsigned sign_mode );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
}
#endif
#endif // !defined TGSI_UTIL_H
#endif /* TGSI_UTIL_H */

View file

@ -29,6 +29,7 @@ SOURCES = \
cell_state_emit.c \
cell_state_shader.c \
cell_pipe_state.c \
cell_screen.c \
cell_state_vertex.c \
cell_spu.c \
cell_surface.c \

View file

@ -37,9 +37,12 @@
#include "pipe/p_format.h"
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "cell/common.h"
#include "pipe/p_screen.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "cell/common.h"
#include "cell_clear.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
@ -54,99 +57,6 @@
static boolean
cell_is_format_supported( struct pipe_context *pipe,
enum pipe_format format, uint type )
{
/*struct cell_context *cell = cell_context( pipe );*/
switch (type) {
case PIPE_TEXTURE:
/* cell supports all texture formats, XXX for now anyway */
return TRUE;
case PIPE_SURFACE:
/* cell supports all (off-screen) surface formats, XXX for now */
return TRUE;
default:
assert(0);
return FALSE;
}
}
static int cell_get_param(struct pipe_context *pipe, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
return 8;
case PIPE_CAP_NPOT_TEXTURES:
return 1;
case PIPE_CAP_TWO_SIDED_STENCIL:
return 1;
case PIPE_CAP_GLSL:
return 1;
case PIPE_CAP_S3TC:
return 0;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
case PIPE_CAP_POINT_SPRITE:
return 1;
case PIPE_CAP_MAX_RENDER_TARGETS:
return 1;
case PIPE_CAP_OCCLUSION_QUERY:
return 1;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1;
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
return 12; /* max 2Kx2K */
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 12; /* max 2Kx2K */
default:
return 0;
}
}
static float cell_get_paramf(struct pipe_context *pipe, int param)
{
switch (param) {
case PIPE_CAP_MAX_LINE_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_LINE_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAP_MAX_POINT_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_POINT_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
return 0.0;
case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
return 16.0; /* arbitrary */
default:
return 0;
}
}
static const char *
cell_get_name( struct pipe_context *pipe )
{
return "Cell";
}
static const char *
cell_get_vendor( struct pipe_context *pipe )
{
return "Tungsten Graphics, Inc.";
}
static void
cell_destroy_context( struct pipe_context *pipe )
{
@ -174,7 +84,8 @@ cell_draw_create(struct cell_context *cell)
struct pipe_context *
cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
cell_create_context(struct pipe_screen *screen,
struct cell_winsys *cws)
{
struct cell_context *cell;
uint spu, buf;
@ -187,17 +98,10 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
memset(cell, 0, sizeof(*cell));
cell->winsys = cws;
cell->pipe.winsys = winsys;
cell->pipe.winsys = screen->winsys;
cell->pipe.screen = screen;
cell->pipe.destroy = cell_destroy_context;
/* queries */
cell->pipe.is_format_supported = cell_is_format_supported;
cell->pipe.get_name = cell_get_name;
cell->pipe.get_vendor = cell_get_vendor;
cell->pipe.get_param = cell_get_param;
cell->pipe.get_paramf = cell_get_paramf;
/* state setters */
cell->pipe.set_vertex_buffer = cell_set_vertex_buffer;
cell->pipe.set_vertex_element = cell_set_vertex_element;
@ -224,10 +128,17 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
cell_init_vbuf(cell);
draw_set_rasterize_stage(cell->draw, cell->vbuf);
/* convert all points/lines to tris for the time being */
draw_wide_point_threshold(cell->draw, 0.0);
draw_wide_line_threshold(cell->draw, 0.0);
/*
* SPU stuff
*/
cell->num_spus = 6;
/* XXX is this in SDK 3.0 only?
cell->num_spus = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
*/
cell_start_spus(cell);

View file

@ -128,7 +128,7 @@ cell_context(struct pipe_context *pipe)
extern struct pipe_context *
cell_create_context(struct pipe_winsys *ws, struct cell_winsys *cws);
cell_create_context(struct pipe_screen *screen, struct cell_winsys *cws);
extern void
cell_vertex_shader_queue_flush(struct draw_context *draw);

View file

@ -242,8 +242,7 @@ cell_set_sampler_texture(struct pipe_context *pipe,
draw_flush(cell->draw);
pipe_texture_reference(pipe,
(struct pipe_texture **) &cell->texture[sampler],
pipe_texture_reference((struct pipe_texture **) &cell->texture[sampler],
texture);
cell_update_texture_mapping(cell);

View file

@ -0,0 +1,166 @@
/**************************************************************************
*
* Copyright 2008 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
#include "cell_screen.h"
#include "cell_texture.h"
#include "cell_winsys.h"
static const char *
cell_get_vendor(struct pipe_screen *screen)
{
return "Tungsten Graphics, Inc.";
}
static const char *
cell_get_name(struct pipe_screen *screen)
{
return "Cell";
}
static int
cell_get_param(struct pipe_screen *screen, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
return 8;
case PIPE_CAP_NPOT_TEXTURES:
return 1;
case PIPE_CAP_TWO_SIDED_STENCIL:
return 1;
case PIPE_CAP_GLSL:
return 1;
case PIPE_CAP_S3TC:
return 0;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
case PIPE_CAP_POINT_SPRITE:
return 1;
case PIPE_CAP_MAX_RENDER_TARGETS:
return 1;
case PIPE_CAP_OCCLUSION_QUERY:
return 1;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1;
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
return 12; /* max 2Kx2K */
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 12; /* max 2Kx2K */
default:
return 0;
}
}
static float
cell_get_paramf(struct pipe_screen *screen, int param)
{
switch (param) {
case PIPE_CAP_MAX_LINE_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_LINE_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAP_MAX_POINT_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_POINT_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
return 0.0;
case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
return 16.0; /* arbitrary */
default:
return 0;
}
}
static boolean
cell_is_format_supported( struct pipe_screen *screen,
enum pipe_format format, uint type )
{
switch (type) {
case PIPE_TEXTURE:
/* cell supports all texture formats, XXX for now anyway */
return TRUE;
case PIPE_SURFACE:
/* cell supports all (off-screen) surface formats, XXX for now */
return TRUE;
default:
assert(0);
return FALSE;
}
}
static void
cell_destroy_screen( struct pipe_screen *screen )
{
FREE(screen);
}
/**
* Create a new pipe_screen object
* Note: we're not presently subclassing pipe_screen (no cell_screen) but
* that would be the place to put SPU thread/context info...
*/
struct pipe_screen *
cell_create_screen(struct pipe_winsys *winsys)
{
struct pipe_screen *screen = CALLOC_STRUCT(pipe_screen);
if (!screen)
return NULL;
screen->winsys = winsys;
screen->destroy = cell_destroy_screen;
screen->get_name = cell_get_name;
screen->get_vendor = cell_get_vendor;
screen->get_param = cell_get_param;
screen->get_paramf = cell_get_paramf;
screen->is_format_supported = cell_is_format_supported;
cell_init_screen_texture_funcs(screen);
return screen;
}

View file

@ -0,0 +1,41 @@
/**************************************************************************
*
* Copyright 2008 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef CELL_SCREEN_H
#define CELL_SCREEN_H
struct pipe_screen;
struct pipe_winsys;
extern struct pipe_screen *
cell_create_screen(struct pipe_winsys *winsys);
#endif /* CELL_SCREEN_H */

View file

@ -97,8 +97,18 @@ static void *cell_thread_function(void *arg)
void
cell_start_spus(struct cell_context *cell)
{
static boolean one_time_init = FALSE;
uint i, j;
if (one_time_init) {
fprintf(stderr, "PPU: Multiple rendering contexts not yet supported "
"on Cell.\n");
abort();
}
one_time_init = TRUE;
assert(cell->num_spus <= MAX_SPUS);
ASSERT_ALIGN16(&cell_global.command[0]);

View file

@ -80,21 +80,23 @@ cell_texture_layout(struct cell_texture * spt)
static struct pipe_texture *
cell_texture_create(struct pipe_context *pipe,
const struct pipe_texture *templat)
cell_texture_create_screen(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
struct pipe_winsys *ws = screen->winsys;
struct cell_texture *spt = CALLOC_STRUCT(cell_texture);
if (!spt)
return NULL;
spt->base = *templat;
spt->base.refcount = 1;
spt->base.screen = screen;
cell_texture_layout(spt);
spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
PIPE_BUFFER_USAGE_PIXEL,
spt->buffer_size);
spt->buffer = ws->buffer_create(ws, 32,
PIPE_BUFFER_USAGE_PIXEL,
spt->buffer_size);
if (!spt->buffer) {
FREE(spt);
@ -106,7 +108,8 @@ cell_texture_create(struct pipe_context *pipe,
static void
cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
cell_texture_release_screen(struct pipe_screen *screen,
struct pipe_texture **pt)
{
if (!*pt)
return;
@ -122,7 +125,7 @@ cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
*/
pipe_buffer_reference(pipe->winsys, &spt->buffer, NULL);
pipe_buffer_reference(screen->winsys, &spt->buffer, NULL);
FREE(spt);
}
@ -138,22 +141,20 @@ cell_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
}
/**
* Called via pipe->get_tex_surface()
*/
static struct pipe_surface *
cell_get_tex_surface(struct pipe_context *pipe,
struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice)
cell_get_tex_surface_screen(struct pipe_screen *screen,
struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice)
{
struct pipe_winsys *ws = screen->winsys;
struct cell_texture *spt = cell_texture(pt);
struct pipe_surface *ps;
ps = pipe->winsys->surface_alloc(pipe->winsys);
ps = ws->surface_alloc(ws);
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
pipe_buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
pipe_buffer_reference(ws, &ps->buffer, spt->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
@ -208,6 +209,7 @@ static void
cell_tile_texture(struct cell_context *cell,
struct cell_texture *texture)
{
struct pipe_screen *screen = cell->pipe.screen;
uint face = 0, level = 0, zslice = 0;
struct pipe_surface *surf;
const uint w = texture->base.width[0], h = texture->base.height[0];
@ -219,7 +221,7 @@ cell_tile_texture(struct cell_context *cell,
assert(w % TILE_SIZE == 0);
assert(h % TILE_SIZE == 0);
surf = cell_get_tex_surface(&cell->pipe, &texture->base, face, level, zslice);
surf = screen->get_tex_surface(screen, &texture->base, face, level, zslice);
ASSERT(surf);
src = (const uint *) pipe_surface_map(surf);
@ -265,8 +267,13 @@ cell_update_texture_mapping(struct cell_context *cell)
void
cell_init_texture_functions(struct cell_context *cell)
{
cell->pipe.texture_create = cell_texture_create;
cell->pipe.texture_release = cell_texture_release;
cell->pipe.texture_update = cell_texture_update;
cell->pipe.get_tex_surface = cell_get_tex_surface;
}
void
cell_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = cell_texture_create_screen;
screen->texture_release = cell_texture_release_screen;
screen->get_tex_surface = cell_get_tex_surface_screen;
}

View file

@ -68,4 +68,8 @@ extern void
cell_init_texture_functions(struct cell_context *cell);
extern void
cell_init_screen_texture_funcs(struct pipe_screen *screen);
#endif /* CELL_TEXTURE_H */

View file

@ -286,6 +286,8 @@ cmd_state_texture(const struct cell_command_texture *texture)
{ spu.texture.width, spu.texture.height, 0.0, 0.0};
spu.tex_size_mask = (vector unsigned int)
{ spu.texture.width - 1, spu.texture.height - 1, 0, 0 };
spu.tex_size_x_mask = spu_splats(spu.texture.width - 1);
spu.tex_size_y_mask = spu_splats(spu.texture.height - 1);
}

View file

@ -107,6 +107,8 @@ struct spu_global
vector float tex_size;
vector unsigned int tex_size_mask; /**< == int(size - 1) */
vector unsigned int tex_size_x_mask; /**< == int(size - 1) */
vector unsigned int tex_size_y_mask; /**< == int(size - 1) */
vector float (*sample_texture)(vector float texcoord);
@ -130,7 +132,6 @@ extern boolean Debug;
#define TAG_INDEX_BUFFER 16
#define TAG_BATCH_BUFFER 17
#define TAG_MISC 18
#define TAG_TEXTURE_TILE 19
#define TAG_DCACHE0 20
#define TAG_DCACHE1 21
#define TAG_DCACHE2 22

View file

@ -31,19 +31,7 @@
#include "spu_texture.h"
#include "spu_tile.h"
#include "spu_colorpack.h"
/**
* Number of texture tiles to cache.
* Note that this will probably be the largest consumer of SPU local store/
* memory for this driver!
*/
#define CACHE_SIZE 16
static tile_t tex_tiles[CACHE_SIZE] ALIGN16_ATTRIB;
static vector unsigned int tex_tile_xy[CACHE_SIZE];
#include "spu_dcache.h"
/**
@ -52,78 +40,60 @@ static vector unsigned int tex_tile_xy[CACHE_SIZE];
void
invalidate_tex_cache(void)
{
/* XXX memset? */
uint i;
for (i = 0; i < CACHE_SIZE; i++) {
tex_tile_xy[i] = ((vector unsigned int) { ~0U, ~0U, ~0U, ~0U });
}
spu_dcache_mark_dirty((unsigned) spu.texture.start,
4 * spu.texture.width * spu.texture.height);
}
/**
* Return the cache pos/index which corresponds to tile (tx,ty)
*/
static INLINE uint
cache_pos(vector unsigned int txty)
{
uint pos = (spu_extract(txty,0) + spu_extract(txty,1) * 4) % CACHE_SIZE;
return pos;
}
/**
* Make sure the tile for texel (i,j) is present, return its position/index
* in the cache.
*/
static uint
get_tex_tile(vector unsigned int ij)
get_texel(vec_uint4 coordinate)
{
/* tile address: tx,ty */
const vector unsigned int txty = spu_rlmask(ij, -5); /* divide by 32 */
const uint pos = cache_pos(txty);
vec_uint4 tmp;
unsigned x = spu_extract(coordinate, 0);
unsigned y = spu_extract(coordinate, 1);
const unsigned tiles_per_row = spu.texture.width / TILE_SIZE;
unsigned tile_offset = sizeof(tile_t) * ((y / TILE_SIZE * tiles_per_row)
+ (x / TILE_SIZE));
unsigned texel_offset = 4 * (((y % TILE_SIZE) * TILE_SIZE)
+ (x % TILE_SIZE));
if ((spu_extract(tex_tile_xy[pos], 0) != spu_extract(txty, 0)) ||
(spu_extract(tex_tile_xy[pos], 1) != spu_extract(txty, 1))) {
/* texture cache miss, fetch tile from main memory */
const uint tiles_per_row = spu.texture.width / TILE_SIZE;
const uint bytes_per_tile = sizeof(tile_t);
const void *src = (const ubyte *) spu.texture.start
+ (spu_extract(txty,1) * tiles_per_row + spu_extract(txty,0)) * bytes_per_tile;
printf("SPU %u: tex cache miss at %d, %d pos=%u old=%d,%d\n",
spu.init.id,
spu_extract(txty,0),
spu_extract(txty,1),
pos,
spu_extract(tex_tile_xy[pos],0),
spu_extract(tex_tile_xy[pos],1));
ASSERT_ALIGN16(tex_tiles[pos].ui);
ASSERT_ALIGN16(src);
mfc_get(tex_tiles[pos].ui, /* dest */
(unsigned int) src,
bytes_per_tile, /* size */
TAG_TEXTURE_TILE,
0, /* tid */
0 /* rid */);
wait_on_mask(1 << TAG_TEXTURE_TILE);
tex_tile_xy[pos] = txty;
}
else {
#if 0
printf("SPU %u: tex cache HIT at %d, %d\n",
spu.init.id, tx, ty);
#endif
}
return pos;
spu_dcache_fetch_unaligned((qword *) & tmp,
spu.texture.start + tile_offset + texel_offset,
4);
return spu_extract(tmp, 0);
}
static void
get_four_texels(vec_uint4 x, vec_uint4 y, vec_uint4 *texels)
{
const unsigned texture_ea = (uintptr_t) spu.texture.start;
vec_uint4 tile_x = spu_rlmask(x, -5);
vec_uint4 tile_y = spu_rlmask(y, -5);
const qword offset_x = si_andi((qword) x, 0x1f);
const qword offset_y = si_andi((qword) y, 0x1f);
const qword tiles_per_row = (qword) spu_splats(spu.texture.width / TILE_SIZE);
const qword tile_size = (qword) spu_splats(sizeof(tile_t));
qword tile_offset = si_mpya((qword) tile_y, tiles_per_row, (qword) tile_x);
tile_offset = si_mpy((qword) tile_offset, tile_size);
qword texel_offset = si_a(si_mpyui(offset_y, 32), offset_x);
texel_offset = si_mpyui(texel_offset, 4);
vec_uint4 offset = (vec_uint4) si_a(tile_offset, texel_offset);
spu_dcache_fetch_unaligned((qword *) & texels[0],
texture_ea + spu_extract(offset, 0), 4);
spu_dcache_fetch_unaligned((qword *) & texels[1],
texture_ea + spu_extract(offset, 1), 4);
spu_dcache_fetch_unaligned((qword *) & texels[2],
texture_ea + spu_extract(offset, 2), 4);
spu_dcache_fetch_unaligned((qword *) & texels[3],
texture_ea + spu_extract(offset, 3), 4);
}
/**
* Get texture sample at texcoord.
* XXX this is extremely primitive for now.
@ -134,9 +104,7 @@ sample_texture_nearest(vector float texcoord)
vector float tc = spu_mul(texcoord, spu.tex_size);
vector unsigned int itc = spu_convtu(tc, 0); /* convert to int */
itc = spu_and(itc, spu.tex_size_mask); /* mask (GL_REPEAT) */
vector unsigned int ij = spu_and(itc, TILE_SIZE-1); /* intra tile addr */
uint pos = get_tex_tile(itc);
uint texel = tex_tiles[pos].ui[spu_extract(ij, 1)][spu_extract(ij, 0)];
uint texel = get_texel(itc);
return spu_unpack_A8R8G8B8(texel);
}
@ -144,49 +112,33 @@ sample_texture_nearest(vector float texcoord)
vector float
sample_texture_bilinear(vector float texcoord)
{
static const vector unsigned int offset10 = {1, 0, 0, 0};
static const vector unsigned int offset01 = {0, 1, 0, 0};
static const vec_uint4 offset_x = {0, 0, 1, 1};
static const vec_uint4 offset_y = {0, 1, 0, 1};
vector float tc = spu_mul(texcoord, spu.tex_size);
tc = spu_add(tc, spu_splats(-0.5f)); /* half texel bias */
/* integer texcoords S,T: */
vector unsigned int itc00 = spu_convtu(tc, 0); /* convert to int */
vector unsigned int itc01 = spu_add(itc00, offset01);
vector unsigned int itc10 = spu_add(itc00, offset10);
vector unsigned int itc11 = spu_add(itc10, offset01);
vec_uint4 itc = spu_convtu(tc, 0); /* convert to int */
/* mask (GL_REPEAT) */
itc00 = spu_and(itc00, spu.tex_size_mask);
itc01 = spu_and(itc01, spu.tex_size_mask);
itc10 = spu_and(itc10, spu.tex_size_mask);
itc11 = spu_and(itc11, spu.tex_size_mask);
vec_uint4 texels[4];
vec_uint4 x = spu_splats(spu_extract(itc, 0));
vec_uint4 y = spu_splats(spu_extract(itc, 1));
/* intra tile addr */
vector unsigned int ij00 = spu_and(itc00, TILE_SIZE-1);
vector unsigned int ij01 = spu_and(itc01, TILE_SIZE-1);
vector unsigned int ij10 = spu_and(itc10, TILE_SIZE-1);
vector unsigned int ij11 = spu_and(itc11, TILE_SIZE-1);
x = spu_add(x, offset_x);
y = spu_add(y, offset_y);
/* get tile cache positions */
uint pos00 = get_tex_tile(itc00);
uint pos01, pos10, pos11;
if ((spu_extract(ij00, 0) < TILE_SIZE-1) &&
(spu_extract(ij00, 1) < TILE_SIZE-1)) {
/* all texels are in the same tile */
pos01 = pos10 = pos11 = pos00;
}
else {
pos01 = get_tex_tile(itc01);
pos10 = get_tex_tile(itc10);
pos11 = get_tex_tile(itc11);
}
x = spu_and(x, spu.tex_size_x_mask);
y = spu_and(y, spu.tex_size_y_mask);
get_four_texels(x, y, texels);
vector float texel00 = spu_unpack_A8R8G8B8(spu_extract(texels[0], 0));
vector float texel01 = spu_unpack_A8R8G8B8(spu_extract(texels[1], 0));
vector float texel10 = spu_unpack_A8R8G8B8(spu_extract(texels[2], 0));
vector float texel11 = spu_unpack_A8R8G8B8(spu_extract(texels[3], 0));
/* get texels from tiles and convert to float[4] */
vector float texel00 = spu_unpack_A8R8G8B8(tex_tiles[pos00].ui[spu_extract(ij00, 1)][spu_extract(ij00, 0)]);
vector float texel01 = spu_unpack_A8R8G8B8(tex_tiles[pos01].ui[spu_extract(ij01, 1)][spu_extract(ij01, 0)]);
vector float texel10 = spu_unpack_A8R8G8B8(tex_tiles[pos10].ui[spu_extract(ij10, 1)][spu_extract(ij10, 0)]);
vector float texel11 = spu_unpack_A8R8G8B8(tex_tiles[pos11].ui[spu_extract(ij11, 1)][spu_extract(ij11, 0)]);
/* Compute weighting factors in [0,1]
* Multiply texcoord by 1024, AND with 1023, convert back to float.

View file

@ -117,12 +117,15 @@ struct pipe_context *failover_create( struct pipe_context *hw,
failover->hw = hw;
failover->sw = sw;
failover->pipe.winsys = hw->winsys;
failover->pipe.screen = hw->screen;
failover->pipe.destroy = failover_destroy;
#if 0
failover->pipe.is_format_supported = hw->is_format_supported;
failover->pipe.get_name = hw->get_name;
failover->pipe.get_vendor = hw->get_vendor;
failover->pipe.get_param = hw->get_param;
failover->pipe.get_paramf = hw->get_paramf;
#endif
failover->pipe.draw_arrays = failover_draw_arrays;
failover->pipe.draw_elements = failover_draw_elements;
@ -140,10 +143,12 @@ struct pipe_context *failover_create( struct pipe_context *hw,
failover->pipe.surface_copy = hw->surface_copy;
failover->pipe.surface_fill = hw->surface_fill;
#if 0
failover->pipe.texture_create = hw->texture_create;
failover->pipe.texture_release = hw->texture_release;
failover->pipe.texture_update = hw->texture_update;
failover->pipe.get_tex_surface = hw->get_tex_surface;
#endif
failover->pipe.texture_update = hw->texture_update;
failover->pipe.flush = hw->flush;

View file

@ -17,7 +17,7 @@ C_SOURCES = \
i915_state_derived.c \
i915_state_emit.c \
i915_state_sampler.c \
i915_strings.c \
i915_screen.c \
i915_prim_emit.c \
i915_prim_vbuf.c \
i915_texture.c \

View file

@ -15,13 +15,13 @@ i915simple = env.ConvenienceLibrary(
'i915_fpc_translate.c',
'i915_prim_emit.c',
'i915_prim_vbuf.c',
'i915_screen.c',
'i915_state.c',
'i915_state_derived.c',
'i915_state_dynamic.c',
'i915_state_emit.c',
'i915_state_immediate.c',
'i915_state_sampler.c',
'i915_strings.c',
'i915_surface.c',
'i915_texture.c',
])

View file

@ -36,120 +36,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
#include "pipe/p_util.h"
/**
* Query format support for creating a texture, drawing surface, etc.
* \param format the format to test
* \param type one of PIPE_TEXTURE, PIPE_SURFACE
*/
static boolean
i915_is_format_supported( struct pipe_context *pipe,
enum pipe_format format, uint type )
{
static const enum pipe_format tex_supported[] = {
PIPE_FORMAT_R8G8B8A8_UNORM,
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_R5G6B5_UNORM,
PIPE_FORMAT_U_L8,
PIPE_FORMAT_U_A8,
PIPE_FORMAT_U_I8,
PIPE_FORMAT_U_A8_L8,
PIPE_FORMAT_YCBCR,
PIPE_FORMAT_YCBCR_REV,
PIPE_FORMAT_S8Z24_UNORM,
PIPE_FORMAT_NONE /* list terminator */
};
static const enum pipe_format surface_supported[] = {
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_R5G6B5_UNORM,
PIPE_FORMAT_S8Z24_UNORM,
/*PIPE_FORMAT_R16G16B16A16_SNORM,*/
PIPE_FORMAT_NONE /* list terminator */
};
const enum pipe_format *list;
uint i;
switch (type) {
case PIPE_TEXTURE:
list = tex_supported;
break;
case PIPE_SURFACE:
list = surface_supported;
break;
default:
assert(0);
}
for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
if (list[i] == format)
return TRUE;
}
return FALSE;
}
static int
i915_get_param(struct pipe_context *pipe, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
return 8;
case PIPE_CAP_NPOT_TEXTURES:
return 1;
case PIPE_CAP_TWO_SIDED_STENCIL:
return 1;
case PIPE_CAP_GLSL:
return 0;
case PIPE_CAP_S3TC:
return 0;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
case PIPE_CAP_POINT_SPRITE:
return 0;
case PIPE_CAP_MAX_RENDER_TARGETS:
return 1;
case PIPE_CAP_OCCLUSION_QUERY:
return 0;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1;
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
return 11; /* max 1024x1024 */
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 11; /* max 1024x1024 */
default:
return 0;
}
}
static float
i915_get_paramf(struct pipe_context *pipe, int param)
{
switch (param) {
case PIPE_CAP_MAX_LINE_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_LINE_WIDTH_AA:
return 7.5;
case PIPE_CAP_MAX_POINT_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_POINT_WIDTH_AA:
return 255.0;
case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
return 4.0;
case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
return 16.0;
default:
return 0;
}
}
#include "pipe/p_screen.h"
static void i915_destroy( struct pipe_context *pipe )
@ -162,8 +49,6 @@ static void i915_destroy( struct pipe_context *pipe )
}
static boolean
i915_draw_elements( struct pipe_context *pipe,
struct pipe_buffer *indexBuffer,
@ -234,33 +119,11 @@ static boolean i915_draw_arrays( struct pipe_context *pipe,
struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
struct i915_winsys *i915_winsys,
unsigned pci_id )
struct pipe_context *i915_create_context( struct pipe_screen *screen,
struct pipe_winsys *pipe_winsys,
struct i915_winsys *i915_winsys )
{
struct i915_context *i915;
unsigned is_i945 = 0;
switch (pci_id) {
case PCI_CHIP_I915_G:
case PCI_CHIP_I915_GM:
break;
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
case PCI_CHIP_I945_GME:
case PCI_CHIP_G33_G:
case PCI_CHIP_Q33_G:
case PCI_CHIP_Q35_G:
is_i945 = 1;
break;
default:
pipe_winsys->printf(pipe_winsys,
"%s: unknown pci id 0x%x, cannot create context\n",
__FUNCTION__, pci_id);
return NULL;
}
i915 = CALLOC_STRUCT(i915_context);
if (i915 == NULL)
@ -268,11 +131,9 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915->winsys = i915_winsys;
i915->pipe.winsys = pipe_winsys;
i915->pipe.screen = screen;
i915->pipe.destroy = i915_destroy;
i915->pipe.is_format_supported = i915_is_format_supported;
i915->pipe.get_param = i915_get_param;
i915->pipe.get_paramf = i915_get_paramf;
i915->pipe.clear = i915_clear;
@ -295,15 +156,11 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915_init_surface_functions(i915);
i915_init_state_functions(i915);
i915_init_flush_functions(i915);
i915_init_string_functions(i915);
i915_init_texture_functions(i915);
draw_install_aaline_stage(i915->draw, &i915->pipe);
draw_install_aapoint_stage(i915->draw, &i915->pipe);
i915->pci_id = pci_id;
i915->flags.is_i945 = is_i945;
i915->dirty = ~0;
i915->hardware_dirty = ~0;
@ -311,11 +168,6 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
*/
i915->batch_start = NULL;
/*
* XXX we could plug GL selection/feedback into the drawing pipeline
* by specifying a different setup/render stage.
*/
return &i915->pipe;
}

View file

@ -35,6 +35,8 @@
#include "draw/draw_vertex.h"
#include "tgsi/util/tgsi_scan.h"
#define I915_TEX_UNITS 8
@ -89,6 +91,9 @@
struct i915_fragment_shader
{
struct pipe_shader_state state;
struct tgsi_shader_info info;
uint *program;
uint program_len;
@ -240,11 +245,6 @@ struct i915_context
unsigned hardware_dirty;
unsigned debug;
unsigned pci_id;
struct {
unsigned is_i945:1;
} flags;
};
/* A flag for each state_tracker state object:
@ -320,6 +320,7 @@ void i915_init_string_functions( struct i915_context *i915 );
/***********************************************************************
* Inline conversion functions. These are better-typed than the
* macros used previously:

View file

@ -58,12 +58,6 @@ struct i915_fp_compile {
uint declarations[I915_PROGRAM_SIZE];
uint program[I915_PROGRAM_SIZE];
uint input_semantic_name[PIPE_MAX_SHADER_INPUTS];
uint input_semantic_index[PIPE_MAX_SHADER_INPUTS];
uint output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
uint output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
uint *csr; /**< Cursor, points into program. */
uint *decl; /**< Cursor, points into declarations. */

View file

@ -162,8 +162,8 @@ src_vector(struct i915_fp_compile *p,
* We also use a texture coordinate to pass wpos when possible.
*/
sem_name = p->input_semantic_name[index];
sem_ind = p->input_semantic_index[index];
sem_name = p->shader->info.input_semantic_name[index];
sem_ind = p->shader->info.input_semantic_index[index];
switch (sem_name) {
case TGSI_SEMANTIC_POSITION:
@ -265,7 +265,7 @@ get_result_vector(struct i915_fp_compile *p,
switch (dest->DstRegister.File) {
case TGSI_FILE_OUTPUT:
{
uint sem_name = p->output_semantic_name[dest->DstRegister.Index];
uint sem_name = p->shader->info.output_semantic_name[dest->DstRegister.Index];
switch (sem_name) {
case TGSI_SEMANTIC_POSITION:
return UREG(REG_TYPE_OD, 0);
@ -942,28 +942,6 @@ i915_translate_instructions(struct i915_fp_compile *p,
switch( parse.FullToken.Token.Type ) {
case TGSI_TOKEN_TYPE_DECLARATION:
if (parse.FullToken.FullDeclaration.Declaration.File
== TGSI_FILE_INPUT) {
/* save input register info for use in src_vector() */
uint ind, sem, semi;
ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
/*debug_printf("FS Input DECL [%u] sem %u\n", ind, sem);*/
p->input_semantic_name[ind] = sem;
p->input_semantic_index[ind] = semi;
}
else if (parse.FullToken.FullDeclaration.Declaration.File
== TGSI_FILE_OUTPUT) {
/* save output register info for use in get_result_vector() */
uint ind, sem, semi;
ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
/*debug_printf("FS Output DECL [%u] sem %u\n", ind, sem);*/
p->output_semantic_name[ind] = sem;
p->output_semantic_index[ind] = semi;
}
else if (parse.FullToken.FullDeclaration.Declaration.File
== TGSI_FILE_CONSTANT) {
uint i;
for (i = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
@ -981,6 +959,7 @@ i915_translate_instructions(struct i915_fp_compile *p,
i <= parse.FullToken.FullDeclaration.u.DeclarationRange.Last;
i++) {
assert(i < I915_MAX_TEMPORARY);
/* XXX just use shader->info->file_mask[TGSI_FILE_TEMPORARY] */
p->temp_flag |= (1 << i); /* mark temp as used */
}
}
@ -1163,7 +1142,7 @@ i915_find_wpos_space(struct i915_fp_compile *p)
i915_program_error(p, "No free texcoord for wpos value");
}
#else
if (p->shader->state.input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
if (p->shader->info.input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
/* frag shader using the fragment position input */
#if 0
assert(0);
@ -1184,7 +1163,7 @@ static void
i915_fixup_depth_write(struct i915_fp_compile *p)
{
/* XXX assuming pos/depth is always in output[0] */
if (p->shader->state.output_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
if (p->shader->info.output_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
const uint depth = UREG(REG_TYPE_OD, 0);
i915_emit_arith(p,

View file

@ -0,0 +1,250 @@
/**************************************************************************
*
* Copyright 2008 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "i915_reg.h"
#include "i915_context.h"
#include "i915_screen.h"
#include "i915_texture.h"
static const char *
i915_get_vendor( struct pipe_screen *pscreen )
{
return "Tungsten Graphics, Inc.";
}
static const char *
i915_get_name( struct pipe_screen *pscreen )
{
static char buffer[128];
const char *chipset;
switch (i915_screen(pscreen)->pci_id) {
case PCI_CHIP_I915_G:
chipset = "915G";
break;
case PCI_CHIP_I915_GM:
chipset = "915GM";
break;
case PCI_CHIP_I945_G:
chipset = "945G";
break;
case PCI_CHIP_I945_GM:
chipset = "945GM";
break;
case PCI_CHIP_I945_GME:
chipset = "945GME";
break;
case PCI_CHIP_G33_G:
chipset = "G33";
break;
case PCI_CHIP_Q35_G:
chipset = "Q35";
break;
case PCI_CHIP_Q33_G:
chipset = "Q33";
break;
default:
chipset = "unknown";
break;
}
sprintf(buffer, "i915 (chipset: %s)", chipset);
return buffer;
}
static int
i915_get_param(struct pipe_screen *screen, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
return 8;
case PIPE_CAP_NPOT_TEXTURES:
return 1;
case PIPE_CAP_TWO_SIDED_STENCIL:
return 1;
case PIPE_CAP_GLSL:
return 0;
case PIPE_CAP_S3TC:
return 0;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
case PIPE_CAP_POINT_SPRITE:
return 0;
case PIPE_CAP_MAX_RENDER_TARGETS:
return 1;
case PIPE_CAP_OCCLUSION_QUERY:
return 0;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1;
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
return 11; /* max 1024x1024 */
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 11; /* max 1024x1024 */
default:
return 0;
}
}
static float
i915_get_paramf(struct pipe_screen *screen, int param)
{
switch (param) {
case PIPE_CAP_MAX_LINE_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_LINE_WIDTH_AA:
return 7.5;
case PIPE_CAP_MAX_POINT_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_POINT_WIDTH_AA:
return 255.0;
case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
return 4.0;
case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
return 16.0;
default:
return 0;
}
}
static boolean
i915_is_format_supported( struct pipe_screen *screen,
enum pipe_format format, uint type )
{
static const enum pipe_format tex_supported[] = {
PIPE_FORMAT_R8G8B8A8_UNORM,
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_R5G6B5_UNORM,
PIPE_FORMAT_U_L8,
PIPE_FORMAT_U_A8,
PIPE_FORMAT_U_I8,
PIPE_FORMAT_U_A8_L8,
PIPE_FORMAT_YCBCR,
PIPE_FORMAT_YCBCR_REV,
PIPE_FORMAT_S8Z24_UNORM,
PIPE_FORMAT_NONE /* list terminator */
};
static const enum pipe_format surface_supported[] = {
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_R5G6B5_UNORM,
PIPE_FORMAT_S8Z24_UNORM,
/*PIPE_FORMAT_R16G16B16A16_SNORM,*/
PIPE_FORMAT_NONE /* list terminator */
};
const enum pipe_format *list;
uint i;
switch (type) {
case PIPE_TEXTURE:
list = tex_supported;
break;
case PIPE_SURFACE:
list = surface_supported;
break;
default:
assert(0);
}
for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
if (list[i] == format)
return TRUE;
}
return FALSE;
}
static void
i915_destroy_screen( struct pipe_screen *screen )
{
FREE(screen);
}
/**
* Create a new i915_screen object
*/
struct pipe_screen *
i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
{
struct i915_screen *i915screen = CALLOC_STRUCT(i915_screen);
if (!i915screen)
return NULL;
switch (pci_id) {
case PCI_CHIP_I915_G:
case PCI_CHIP_I915_GM:
i915screen->is_i945 = FALSE;
break;
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
case PCI_CHIP_I945_GME:
case PCI_CHIP_G33_G:
case PCI_CHIP_Q33_G:
case PCI_CHIP_Q35_G:
i915screen->is_i945 = TRUE;
break;
default:
winsys->printf(winsys,
"%s: unknown pci id 0x%x, cannot create screen\n",
__FUNCTION__, pci_id);
return NULL;
}
i915screen->pci_id = pci_id;
i915screen->screen.winsys = winsys;
i915screen->screen.destroy = i915_destroy_screen;
i915screen->screen.get_name = i915_get_name;
i915screen->screen.get_vendor = i915_get_vendor;
i915screen->screen.get_param = i915_get_param;
i915screen->screen.get_paramf = i915_get_paramf;
i915screen->screen.is_format_supported = i915_is_format_supported;
i915_init_screen_texture_functions(&i915screen->screen);
return &i915screen->screen;
}

View file

@ -1,6 +1,6 @@
/**************************************************************************
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@ -25,48 +25,45 @@
*
**************************************************************************/
#include "brw_context.h"
#include "brw_reg.h"
#ifndef I915_SCREEN_H
#define I915_SCREEN_H
static const char *brw_get_vendor( struct pipe_context *pipe )
#include "pipe/p_screen.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Subclass of pipe_screen
*/
struct i915_screen
{
return "Tungsten Graphics, Inc.";
struct pipe_screen screen;
boolean is_i945;
uint pci_id;
};
/** cast wrapper */
static INLINE struct i915_screen *
i915_screen(struct pipe_screen *pscreen)
{
return (struct i915_screen *) pscreen;
}
static const char *brw_get_name( struct pipe_context *pipe )
{
static char buffer[128];
const char *chipset;
extern struct pipe_screen *
i915_create_screen(struct pipe_winsys *winsys, uint pci_id);
switch (brw_context(pipe)->pci_id) {
case PCI_CHIP_I965_Q:
chipset = "Intel(R) 965Q";
break;
case PCI_CHIP_I965_G:
case PCI_CHIP_I965_G_1:
chipset = "Intel(R) 965G";
break;
case PCI_CHIP_I965_GM:
chipset = "Intel(R) 965GM";
break;
case PCI_CHIP_I965_GME:
chipset = "Intel(R) 965GME/GLE";
break;
default:
chipset = "unknown";
break;
}
sprintf(buffer, "i965 (chipset: %s)", chipset);
return buffer;
#ifdef __cplusplus
}
#endif
void
brw_init_string_functions(struct brw_context *brw)
{
brw->pipe.get_name = brw_get_name;
brw->pipe.get_vendor = brw_get_vendor;
}
#endif /* I915_SCREEN_H */

View file

@ -429,6 +429,8 @@ i915_create_fs_state(struct pipe_context *pipe,
ifs->state = *templ;
tgsi_scan_shader(templ->tokens, &ifs->info);
/* The shader's compiled to i915 instructions here */
i915_translate_fragment_program(i915, ifs);
@ -530,8 +532,7 @@ static void i915_set_sampler_texture(struct pipe_context *pipe,
{
struct i915_context *i915 = i915_context(pipe);
pipe_texture_reference(pipe,
(struct pipe_texture **) &i915->texture[sampler],
pipe_texture_reference((struct pipe_texture **) &i915->texture[sampler],
texture);
i915->dirty |= I915_NEW_TEXTURE;

View file

@ -43,7 +43,7 @@
*/
static void calculate_vertex_layout( struct i915_context *i915 )
{
const struct pipe_shader_state *fs = &i915->fs->state;
const struct i915_fragment_shader *fs = i915->fs;
const enum interp_mode colorInterp = i915->rasterizer->color_interp;
struct vertex_info vinfo;
boolean texCoords[8], colors[2], fog, needW;
@ -57,18 +57,18 @@ static void calculate_vertex_layout( struct i915_context *i915 )
/* Determine which fragment program inputs are needed. Setup HW vertex
* layout below, in the HW-specific attribute order.
*/
for (i = 0; i < fs->num_inputs; i++) {
switch (fs->input_semantic_name[i]) {
for (i = 0; i < fs->info.num_inputs; i++) {
switch (fs->info.input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
break;
case TGSI_SEMANTIC_COLOR:
assert(fs->input_semantic_index[i] < 2);
colors[fs->input_semantic_index[i]] = TRUE;
assert(fs->info.input_semantic_index[i] < 2);
colors[fs->info.input_semantic_index[i]] = TRUE;
break;
case TGSI_SEMANTIC_GENERIC:
/* usually a texcoord */
{
const uint unit = fs->input_semantic_index[i];
const uint unit = fs->info.input_semantic_index[i];
assert(unit < 8);
texCoords[unit] = TRUE;
needW = TRUE;

View file

@ -40,6 +40,7 @@
#include "i915_context.h"
#include "i915_texture.h"
#include "i915_debug.h"
#include "i915_screen.h"
static unsigned minify( unsigned d )
@ -187,7 +188,7 @@ static const int step_offsets[6][2] = {
static boolean
i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
i915_miptree_layout(struct i915_texture * tex)
{
struct pipe_texture *pt = &tex->base;
unsigned level;
@ -311,7 +312,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
static boolean
i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
i945_miptree_layout(struct i915_texture * tex)
{
struct pipe_texture *pt = &tex->base;
unsigned level;
@ -479,23 +480,25 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
static struct pipe_texture *
i915_texture_create(struct pipe_context *pipe,
const struct pipe_texture *templat)
i915_texture_create_screen(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
if (tex) {
struct i915_context *i915 = i915_context(pipe);
struct i915_screen *i915screen = i915_screen(screen);
struct pipe_winsys *ws = screen->winsys;
tex->base = *templat;
tex->base.refcount = 1;
tex->base.screen = screen;
if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
i915_miptree_layout(pipe, tex))
tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex->pitch * tex->base.cpp *
tex->total_height);
if (i915screen->is_i945 ? i945_miptree_layout(tex) :
i915_miptree_layout(tex))
tex->buffer = ws->buffer_create(ws, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex->pitch * tex->base.cpp *
tex->total_height);
if (!tex->buffer) {
FREE(tex);
@ -508,7 +511,8 @@ i915_texture_create(struct pipe_context *pipe,
static void
i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
i915_texture_release_screen(struct pipe_screen *screen,
struct pipe_texture **pt)
{
if (!*pt)
return;
@ -525,7 +529,7 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
pipe_buffer_reference(screen->winsys, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
@ -548,11 +552,12 @@ i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
* XXX note: same as code in sp_surface.c
*/
static struct pipe_surface *
i915_get_tex_surface(struct pipe_context *pipe,
struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice)
i915_get_tex_surface_screen(struct pipe_screen *screen,
struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice)
{
struct i915_texture *tex = (struct i915_texture *)pt;
struct pipe_winsys *ws = screen->winsys;
struct pipe_surface *ps;
unsigned offset; /* in bytes */
@ -569,11 +574,11 @@ i915_get_tex_surface(struct pipe_context *pipe,
assert(zslice == 0);
}
ps = pipe->winsys->surface_alloc(pipe->winsys);
ps = ws->surface_alloc(ws);
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
@ -585,12 +590,17 @@ i915_get_tex_surface(struct pipe_context *pipe,
}
void
i915_init_texture_functions(struct i915_context *i915)
{
i915->pipe.texture_create = i915_texture_create;
i915->pipe.texture_release = i915_texture_release;
i915->pipe.texture_update = i915_texture_update;
i915->pipe.get_tex_surface = i915_get_tex_surface;
}
void
i915_init_screen_texture_functions(struct pipe_screen *screen)
{
screen->texture_create = i915_texture_create_screen;
screen->texture_release = i915_texture_release_screen;
screen->get_tex_surface = i915_get_tex_surface_screen;
}

View file

@ -28,11 +28,16 @@
#ifndef I915_TEXTURE_H
#define I915_TEXTURE_H
struct pipe_context;
struct i915_context;
struct pipe_screen;
extern void
i915_init_texture_functions(struct i915_context *i915);
extern void
i915_init_screen_texture_functions(struct pipe_screen *screen);
#endif /* I915_TEXTURE_H */

View file

@ -40,6 +40,11 @@
#include "pipe/p_defines.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Pipe drivers are (meant to be!) independent of both GL and the
* window system. The window system provides a buffer manager and a
* set of additional hooks for things like command buffer submission,
@ -52,6 +57,7 @@
struct pipe_buffer;
struct pipe_winsys;
struct pipe_screen;
/**
@ -107,9 +113,12 @@ struct i915_winsys {
#define I915_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
struct pipe_context *i915_create( struct pipe_winsys *,
struct i915_winsys *,
unsigned pci_id );
struct pipe_context *i915_create_context( struct pipe_screen *,
struct pipe_winsys *,
struct i915_winsys * );
#ifdef __cplusplus
}
#endif
#endif

View file

@ -6,7 +6,7 @@ LIBNAME = i965simple
C_SOURCES = \
brw_blit.c \
brw_flush.c \
brw_strings.c \
brw_screen.c \
brw_surface.c \
brw_cc.c \
brw_clip.c \
@ -30,7 +30,6 @@ C_SOURCES = \
brw_sf.c \
brw_sf_emit.c \
brw_sf_state.c \
brw_shader_info.c \
brw_state.c \
brw_state_batch.c \
brw_state_cache.c \

View file

@ -29,13 +29,11 @@ i965simple = env.ConvenienceLibrary(
'brw_sf.c',
'brw_sf_emit.c',
'brw_sf_state.c',
'brw_shader_info.c',
'brw_state.c',
'brw_state_batch.c',
'brw_state_cache.c',
'brw_state_pool.c',
'brw_state_upload.c',
'brw_strings.c',
'brw_surface.c',
'brw_tex_layout.c',
'brw_urb.c',

View file

@ -40,15 +40,14 @@
#include "pipe/p_winsys.h"
#include "pipe/p_context.h"
#include "pipe/p_util.h"
#include "pipe/p_screen.h"
/***************************************
* Mesa's Driver Functions
***************************************/
#ifndef BRW_DEBUG
int BRW_DEBUG = (0);
#endif
static void brw_destroy(struct pipe_context *pipe)
{
struct brw_context *brw = brw_context(pipe);
@ -56,6 +55,7 @@ static void brw_destroy(struct pipe_context *pipe)
FREE(brw);
}
static void brw_clear(struct pipe_context *pipe, struct pipe_surface *ps,
unsigned clearValue)
{
@ -71,163 +71,31 @@ static void brw_clear(struct pipe_context *pipe, struct pipe_surface *ps,
}
static int
brw_get_param(struct pipe_context *pipe, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
return 8;
case PIPE_CAP_NPOT_TEXTURES:
return 1;
case PIPE_CAP_TWO_SIDED_STENCIL:
return 1;
case PIPE_CAP_GLSL:
return 0;
case PIPE_CAP_S3TC:
return 0;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
case PIPE_CAP_POINT_SPRITE:
return 0;
case PIPE_CAP_MAX_RENDER_TARGETS:
return 1;
case PIPE_CAP_OCCLUSION_QUERY:
return 0;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1;
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
return 11; /* max 1024x1024 */
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 11; /* max 1024x1024 */
default:
return 0;
}
}
static float
brw_get_paramf(struct pipe_context *pipe, int param)
{
switch (param) {
case PIPE_CAP_MAX_LINE_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_LINE_WIDTH_AA:
return 7.5;
case PIPE_CAP_MAX_POINT_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_POINT_WIDTH_AA:
return 255.0;
case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
return 4.0;
case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
return 16.0;
default:
return 0;
}
}
static boolean
brw_is_format_supported( struct pipe_context *pipe,
enum pipe_format format, uint type )
{
#if 0
/* XXX: This is broken -- rewrite if still needed. */
static const unsigned tex_supported[] = {
PIPE_FORMAT_U_R8_G8_B8_A8,
PIPE_FORMAT_U_A8_R8_G8_B8,
PIPE_FORMAT_U_R5_G6_B5,
PIPE_FORMAT_U_L8,
PIPE_FORMAT_U_A8,
PIPE_FORMAT_U_I8,
PIPE_FORMAT_U_L8_A8,
PIPE_FORMAT_YCBCR,
PIPE_FORMAT_YCBCR_REV,
PIPE_FORMAT_S8_Z24,
};
/* Actually a lot more than this - add later:
*/
static const unsigned render_supported[] = {
PIPE_FORMAT_U_A8_R8_G8_B8,
PIPE_FORMAT_U_R5_G6_B5,
};
/*
*/
static const unsigned z_stencil_supported[] = {
PIPE_FORMAT_U_Z16,
PIPE_FORMAT_U_Z32,
PIPE_FORMAT_S8_Z24,
};
switch (type) {
case PIPE_RENDER_FORMAT:
*numFormats = Elements(render_supported);
return render_supported;
case PIPE_TEX_FORMAT:
*numFormats = Elements(tex_supported);
return render_supported;
case PIPE_Z_STENCIL_FORMAT:
*numFormats = Elements(render_supported);
return render_supported;
default:
*numFormats = 0;
return NULL;
}
#else
switch (format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
case PIPE_FORMAT_R5G6B5_UNORM:
case PIPE_FORMAT_S8Z24_UNORM:
return TRUE;
default:
return FALSE;
};
return FALSE;
#endif
}
struct pipe_context *brw_create(struct pipe_winsys *pipe_winsys,
struct pipe_context *brw_create(struct pipe_screen *screen,
struct brw_winsys *brw_winsys,
unsigned pci_id)
{
struct brw_context *brw;
pipe_winsys->printf(pipe_winsys,
"%s: creating brw_context with pci id 0x%x\n",
__FUNCTION__, pci_id);
screen->winsys->printf(screen->winsys,
"%s: creating brw_context with pci id 0x%x\n",
__FUNCTION__, pci_id);
brw = CALLOC_STRUCT(brw_context);
if (brw == NULL)
return NULL;
brw->winsys = brw_winsys;
brw->pipe.winsys = pipe_winsys;
brw->pipe.winsys = screen->winsys;
brw->pipe.screen = screen;
brw->pipe.destroy = brw_destroy;
brw->pipe.is_format_supported = brw_is_format_supported;
brw->pipe.get_param = brw_get_param;
brw->pipe.get_paramf = brw_get_paramf;
brw->pipe.clear = brw_clear;
brw_init_surface_functions(brw);
brw_init_texture_functions(brw);
brw_init_state_functions(brw);
brw_init_flush_functions(brw);
brw_init_string_functions(brw);
brw_init_draw_functions( brw );

View file

@ -38,6 +38,8 @@
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
#include "tgsi/util/tgsi_scan.h"
#include "brw_structs.h"
#include "brw_winsys.h"
@ -195,33 +197,22 @@ struct brw_state_flags {
};
struct brw_shader_info {
int nr_regs[8]; /* TGSI_FILE_* */
};
struct brw_vertex_program {
struct pipe_shader_state program;
struct brw_shader_info info;
struct tgsi_shader_info info;
int id;
};
struct brw_fragment_program {
struct pipe_shader_state program;
struct brw_shader_info info;
struct tgsi_shader_info info;
boolean UsesDepth;
boolean UsesKill;
boolean ComputesDepth;
boolean UsesDepth; /* XXX add this to tgsi_shader_info? */
int id;
};
struct pipe_setup_linkage {
struct {
unsigned vp_output:5;
@ -502,7 +493,7 @@ struct brw_context
/* Arrays with buffer objects to copy non-bufferobj arrays into
* for upload:
*/
struct pipe_vertex_buffer *vbo_array[PIPE_ATTRIB_MAX];
const struct pipe_vertex_buffer *vbo_array[PIPE_ATTRIB_MAX];
struct brw_vertex_element_state inputs[PIPE_ATTRIB_MAX];

View file

@ -256,7 +256,7 @@ boolean brw_upload_vertex_elements( struct brw_context *brw )
struct brw_vertex_element_packet vep;
unsigned i;
unsigned nr_enabled = brw->attribs.VertexProgram->program.num_inputs;
unsigned nr_enabled = brw->attribs.VertexProgram->info.num_inputs;
memset(&vep, 0, sizeof(vep));

View file

@ -0,0 +1,235 @@
/**************************************************************************
*
* Copyright 2008 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "brw_context.h"
#include "brw_screen.h"
#include "brw_tex_layout.h"
static const char *
brw_get_vendor( struct pipe_screen *screen )
{
return "Tungsten Graphics, Inc.";
}
static const char *
brw_get_name( struct pipe_screen *screen )
{
static char buffer[128];
const char *chipset;
switch (brw_screen(screen)->pci_id) {
case PCI_CHIP_I965_Q:
chipset = "Intel(R) 965Q";
break;
case PCI_CHIP_I965_G:
case PCI_CHIP_I965_G_1:
chipset = "Intel(R) 965G";
break;
case PCI_CHIP_I965_GM:
chipset = "Intel(R) 965GM";
break;
case PCI_CHIP_I965_GME:
chipset = "Intel(R) 965GME/GLE";
break;
default:
chipset = "unknown";
break;
}
sprintf(buffer, "i965 (chipset: %s)", chipset);
return buffer;
}
static int
brw_get_param(struct pipe_screen *screen, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
return 8;
case PIPE_CAP_NPOT_TEXTURES:
return 1;
case PIPE_CAP_TWO_SIDED_STENCIL:
return 1;
case PIPE_CAP_GLSL:
return 0;
case PIPE_CAP_S3TC:
return 0;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
case PIPE_CAP_POINT_SPRITE:
return 0;
case PIPE_CAP_MAX_RENDER_TARGETS:
return 1;
case PIPE_CAP_OCCLUSION_QUERY:
return 0;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1;
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
return 11; /* max 1024x1024 */
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 11; /* max 1024x1024 */
default:
return 0;
}
}
static float
brw_get_paramf(struct pipe_screen *screen, int param)
{
switch (param) {
case PIPE_CAP_MAX_LINE_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_LINE_WIDTH_AA:
return 7.5;
case PIPE_CAP_MAX_POINT_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_POINT_WIDTH_AA:
return 255.0;
case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
return 4.0;
case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
return 16.0;
default:
return 0;
}
}
static boolean
brw_is_format_supported( struct pipe_screen *screen,
enum pipe_format format, uint type )
{
#if 0
/* XXX: This is broken -- rewrite if still needed. */
static const unsigned tex_supported[] = {
PIPE_FORMAT_U_R8_G8_B8_A8,
PIPE_FORMAT_U_A8_R8_G8_B8,
PIPE_FORMAT_U_R5_G6_B5,
PIPE_FORMAT_U_L8,
PIPE_FORMAT_U_A8,
PIPE_FORMAT_U_I8,
PIPE_FORMAT_U_L8_A8,
PIPE_FORMAT_YCBCR,
PIPE_FORMAT_YCBCR_REV,
PIPE_FORMAT_S8_Z24,
};
/* Actually a lot more than this - add later:
*/
static const unsigned render_supported[] = {
PIPE_FORMAT_U_A8_R8_G8_B8,
PIPE_FORMAT_U_R5_G6_B5,
};
/*
*/
static const unsigned z_stencil_supported[] = {
PIPE_FORMAT_U_Z16,
PIPE_FORMAT_U_Z32,
PIPE_FORMAT_S8_Z24,
};
switch (type) {
case PIPE_RENDER_FORMAT:
*numFormats = Elements(render_supported);
return render_supported;
case PIPE_TEX_FORMAT:
*numFormats = Elements(tex_supported);
return render_supported;
case PIPE_Z_STENCIL_FORMAT:
*numFormats = Elements(render_supported);
return render_supported;
default:
*numFormats = 0;
return NULL;
}
#else
switch (format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
case PIPE_FORMAT_R5G6B5_UNORM:
case PIPE_FORMAT_S8Z24_UNORM:
return TRUE;
default:
return FALSE;
};
return FALSE;
#endif
}
static void
brw_destroy_screen( struct pipe_screen *screen )
{
FREE(screen);
}
/**
* Create a new brw_screen object
*/
struct pipe_screen *
brw_create_screen(struct pipe_winsys *winsys, uint pci_id)
{
struct brw_screen *brwscreen = CALLOC_STRUCT(brw_screen);
if (!brwscreen)
return NULL;
brwscreen->pci_id = pci_id;
brwscreen->screen.winsys = winsys;
brwscreen->screen.destroy = brw_destroy_screen;
brwscreen->screen.get_name = brw_get_name;
brwscreen->screen.get_vendor = brw_get_vendor;
brwscreen->screen.get_param = brw_get_param;
brwscreen->screen.get_paramf = brw_get_paramf;
brwscreen->screen.is_format_supported = brw_is_format_supported;
brw_init_screen_texture_funcs(&brwscreen->screen);
return &brwscreen->screen;
}

View file

@ -1,6 +1,6 @@
/**************************************************************************
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@ -25,59 +25,44 @@
*
**************************************************************************/
#include "i915_context.h"
#include "i915_reg.h"
#ifndef BRW_SCREEN_H
#define BRW_SCREEN_H
static const char *i915_get_vendor( struct pipe_context *pipe )
#include "pipe/p_screen.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Subclass of pipe_screen
*/
struct brw_screen
{
return "Tungsten Graphics, Inc.";
struct pipe_screen screen;
uint pci_id;
};
/** cast wrapper */
static INLINE struct brw_screen *
brw_screen(struct pipe_screen *pscreen)
{
return (struct brw_screen *) pscreen;
}
static const char *i915_get_name( struct pipe_context *pipe )
{
static char buffer[128];
const char *chipset;
extern struct pipe_screen *
brw_create_screen(struct pipe_winsys *winsys, uint pci_id);
switch (i915_context(pipe)->pci_id) {
case PCI_CHIP_I915_G:
chipset = "915G";
break;
case PCI_CHIP_I915_GM:
chipset = "915GM";
break;
case PCI_CHIP_I945_G:
chipset = "945G";
break;
case PCI_CHIP_I945_GM:
chipset = "945GM";
break;
case PCI_CHIP_I945_GME:
chipset = "945GME";
break;
case PCI_CHIP_G33_G:
chipset = "G33";
break;
case PCI_CHIP_Q35_G:
chipset = "Q35";
break;
case PCI_CHIP_Q33_G:
chipset = "Q33";
break;
default:
chipset = "unknown";
break;
}
sprintf(buffer, "i915 (chipset: %s)", chipset);
return buffer;
#ifdef __cplusplus
}
#endif
void
i915_init_string_functions(struct i915_context *i915)
{
i915->pipe.get_name = i915_get_name;
i915->pipe.get_vendor = i915_get_vendor;
}
#endif /* BRW_SCREEN_H */

View file

@ -133,7 +133,7 @@ static void upload_sf_prog( struct brw_context *brw )
key.vp_output_count = brw->vs.prog_data->outputs_written;
/* BRW_NEW_FS */
key.fp_input_count = brw->attribs.FragmentProgram->info.nr_regs[TGSI_FILE_INPUT];
key.fp_input_count = brw->attribs.FragmentProgram->info.file_max[TGSI_FILE_INPUT] + 1;
/* BRW_NEW_REDUCED_PRIMITIVE */

View file

@ -6,8 +6,9 @@
#include "tgsi/util/tgsi_parse.h"
/**
* XXX this obsolete new and no longer compiled.
*/
void brw_shader_info(const struct tgsi_token *tokens,
struct brw_shader_info *info )
{

View file

@ -175,8 +175,12 @@ static void * brw_create_fs_state(struct pipe_context *pipe,
brw_fp->program = *shader;
brw_fp->id = brw_context(pipe)->program_id++;
tgsi_scan_shader(shader->tokens, &brw_fp->info);
#if 0
brw_shader_info(shader->tokens,
&brw_fp->info);
&brw_fp->info2);
#endif
tgsi_dump(shader->tokens, 0);
@ -211,9 +215,13 @@ static void *brw_create_vs_state(struct pipe_context *pipe,
*/
brw_vp->program = *shader;
brw_vp->id = brw_context(pipe)->program_id++;
brw_shader_info(shader->tokens,
&brw_vp->info);
tgsi_scan_shader(shader->tokens, &brw_vp->info);
#if 0
brw_shader_info(shader->tokens,
&brw_vp->info2);
#endif
tgsi_dump(shader->tokens, 0);
return (void *)brw_vp;
@ -328,8 +336,7 @@ static void brw_set_sampler_texture(struct pipe_context *pipe,
{
struct brw_context *brw = brw_context(pipe);
pipe_texture_reference(pipe,
(struct pipe_texture **) &brw->attribs.Texture[unit],
pipe_texture_reference((struct pipe_texture **) &brw->attribs.Texture[unit],
texture);
brw->state.dirty.brw |= BRW_NEW_TEXTURE;

View file

@ -148,11 +148,4 @@ void brw_invalidate_pools( struct brw_context *brw );
void brw_clear_batch_cache_flush( struct brw_context *brw );
/* brw_shader_info.c
*/
void brw_shader_info(const struct tgsi_token *tokens,
struct brw_shader_info *info );
#endif

View file

@ -164,6 +164,7 @@ brw_surface_fill(struct pipe_context *pipe,
void
brw_init_surface_functions(struct brw_context *brw)
{
(void) brw_surface_data; /* silence warning */
brw->pipe.surface_copy = brw_surface_copy;
brw->pipe.surface_fill = brw_surface_fill;
}

View file

@ -71,8 +71,6 @@ static unsigned minify( unsigned d )
}
static boolean brw_miptree_layout(struct pipe_context *, struct brw_texture *);
static void intel_miptree_set_image_offset(struct brw_texture *tex,
unsigned level,
unsigned img,
@ -199,7 +197,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
}
}
static boolean brw_miptree_layout(struct pipe_context *pipe, struct brw_texture *tex)
static boolean brw_miptree_layout(struct brw_texture *tex)
{
struct pipe_texture *pt = &tex->base;
/* XXX: these vary depending on image format:
@ -301,20 +299,21 @@ static boolean brw_miptree_layout(struct pipe_context *pipe, struct brw_texture
static struct pipe_texture *
brw_texture_create(struct pipe_context *pipe,
const struct pipe_texture *templat)
brw_texture_create_screen(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
struct pipe_winsys *ws = screen->winsys;
struct brw_texture *tex = CALLOC_STRUCT(brw_texture);
if (tex) {
tex->base = *templat;
tex->base.refcount = 1;
if (brw_miptree_layout(pipe, tex))
tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex->pitch * tex->base.cpp *
tex->total_height);
if (brw_miptree_layout(tex))
tex->buffer = ws->buffer_create(ws, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex->pitch * tex->base.cpp *
tex->total_height);
if (!tex->buffer) {
FREE(tex);
@ -327,7 +326,8 @@ brw_texture_create(struct pipe_context *pipe,
static void
brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
brw_texture_release_screen(struct pipe_screen *screen,
struct pipe_texture **pt)
{
if (!*pt)
return;
@ -337,6 +337,7 @@ brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
__FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
*/
if (--(*pt)->refcount <= 0) {
struct pipe_winsys *ws = screen->winsys;
struct brw_texture *tex = (struct brw_texture *)*pt;
uint i;
@ -344,7 +345,7 @@ brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
pipe_buffer_reference(ws, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
@ -363,14 +364,12 @@ brw_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
}
/*
* XXX note: same as code in sp_surface.c
*/
static struct pipe_surface *
brw_get_tex_surface(struct pipe_context *pipe,
struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice)
brw_get_tex_surface_screen(struct pipe_screen *screen,
struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice)
{
struct pipe_winsys *ws = screen->winsys;
struct brw_texture *tex = (struct brw_texture *)pt;
struct pipe_surface *ps;
unsigned offset; /* in bytes */
@ -388,11 +387,11 @@ brw_get_tex_surface(struct pipe_context *pipe,
assert(zslice == 0);
}
ps = pipe->winsys->surface_alloc(pipe->winsys);
ps = ws->surface_alloc(ws);
if (ps) {
assert(ps->format);
assert(ps->refcount);
pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
@ -407,8 +406,15 @@ brw_get_tex_surface(struct pipe_context *pipe,
void
brw_init_texture_functions(struct brw_context *brw)
{
brw->pipe.texture_create = brw_texture_create;
brw->pipe.texture_release = brw_texture_release;
brw->pipe.texture_update = brw_texture_update;
brw->pipe.get_tex_surface = brw_get_tex_surface;
}
void
brw_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = brw_texture_create_screen;
screen->texture_release = brw_texture_release_screen;
screen->get_tex_surface = brw_get_tex_surface_screen;
}

View file

@ -1,12 +1,44 @@
/*
Copyright (C) Intel Corp. 2006. All Rights Reserved.
Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
develop this 3D driver.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**********************************************************************/
#ifndef BRW_TEX_LAYOUT_H
#define BRW_TEX_LAYOUT_H
struct brw_context;
struct pipe_screen;
extern void
brw_init_texture_functions(struct brw_context *brw);
extern void
brw_init_screen_texture_funcs(struct pipe_screen *screen);
#endif

View file

@ -50,8 +50,8 @@ static void do_vs_prog( struct brw_context *brw,
brw_init_compile(&c.func);
c.vp = vp;
c.prog_data.outputs_written = vp->program.num_outputs;
c.prog_data.inputs_read = vp->program.num_inputs;
c.prog_data.outputs_written = vp->info.num_outputs;
c.prog_data.inputs_read = vp->info.num_inputs;
#if 0
if (c.key.copy_edgeflag) {

View file

@ -52,7 +52,7 @@ struct brw_vs_compile {
struct brw_vs_prog_key key;
struct brw_vs_prog_data prog_data;
struct brw_vertex_program *vp;
const struct brw_vertex_program *vp;
unsigned nr_inputs;

View file

@ -86,7 +86,7 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c,
/* Allocate input regs:
*/
c->nr_inputs = c->vp->program.num_inputs;
c->nr_inputs = c->vp->info.num_inputs;
for (i = 0; i < c->nr_inputs; i++) {
c->regs[TGSI_FILE_INPUT][i] = brw_vec8_grf(reg, 0);
reg++;
@ -99,7 +99,7 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c,
c->nr_outputs = 0;
c->first_output = reg;
mrf = 4;
for (i = 0; i < c->vp->program.num_outputs; i++) {
for (i = 0; i < c->vp->info.num_outputs; i++) {
c->nr_outputs++;
#if 0
if (i == VERT_RESULT_HPOS) {
@ -1051,7 +1051,7 @@ static void process_instruction(struct brw_vs_compile *c,
{
struct brw_reg args[3], dst;
struct brw_compile *p = &c->func;
struct brw_indirect stack_index = brw_indirect(0, 0);
/*struct brw_indirect stack_index = brw_indirect(0, 0);*/
unsigned i;
unsigned index;
unsigned file;

View file

@ -53,6 +53,8 @@
struct pipe_buffer;
struct pipe_fence_handle;
struct pipe_winsys;
struct pipe_screen;
/* The pipe driver currently understands the following chipsets:
*/
@ -181,7 +183,7 @@ struct brw_winsys {
#define BRW_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
struct pipe_context *brw_create(struct pipe_winsys *,
struct pipe_context *brw_create(struct pipe_screen *,
struct brw_winsys *,
unsigned pci_id);

View file

@ -94,11 +94,11 @@ static void brw_wm_populate_key( struct brw_context *brw,
/* Build the index for table lookup
*/
/* BRW_NEW_DEPTH_STENCIL */
if (fp->UsesKill ||
if (fp->info.uses_kill ||
brw->attribs.DepthStencil->alpha.enabled)
lookup |= IZ_PS_KILL_ALPHATEST_BIT;
if (fp->ComputesDepth)
if (fp->info.writes_z)
lookup |= IZ_PS_COMPUTES_DEPTH_BIT;
if (brw->attribs.DepthStencil->depth.enabled)

View file

@ -259,9 +259,12 @@ static void prealloc_reg(struct brw_wm_compile *c)
/* Then a copy of our part of the CURBE entry:
*/
{
int nr_constants = c->fp->info.nr_regs[TGSI_FILE_CONSTANT];
int nr_constants = c->fp->info.file_max[TGSI_FILE_CONSTANT] + 1;
int index = 0;
/* XXX number of constants, or highest numbered constant? */
assert(nr_constants == c->fp->info.file_count[TGSI_FILE_CONSTANT]);
c->prog_data.max_const = 4*nr_constants;
for (i = 0; i < nr_constants; i++) {
for (j = 0; j < 4; j++, index++)
@ -282,13 +285,14 @@ static void prealloc_reg(struct brw_wm_compile *c)
/* Next we receive the plane coefficients for parameter
* interpolation:
*/
for (i = 0; i < c->fp->info.nr_regs[TGSI_FILE_INPUT]; i++) {
assert(c->fp->info.file_max[TGSI_FILE_INPUT] == c->fp->info.num_inputs);
for (i = 0; i < c->fp->info.file_max[TGSI_FILE_INPUT] + 1; i++) {
c->payload_coef[i] = brw_vec8_grf(c->reg_index, 0);
c->reg_index += 2;
}
c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2;
c->prog_data.urb_read_length = (c->fp->program.num_inputs + 1) * 2;
c->prog_data.urb_read_length = (c->fp->info.num_inputs + 1) * 2;
c->prog_data.curb_read_length = nr_curbe_regs;
/* That's the end of the payload, now we can start allocating registers.
@ -302,11 +306,17 @@ static void prealloc_reg(struct brw_wm_compile *c)
/* Now allocate room for the interpolated inputs and staging
* registers for the outputs:
*/
for (i = 0; i < c->fp->info.nr_regs[TGSI_FILE_INPUT]; i++)
/* XXX do we want to loop over the _number_ of inputs/outputs or loop
* to the highest input/output index that's used?
* Probably the same, actually.
*/
assert(c->fp->info.file_max[TGSI_FILE_INPUT] + 1 == c->fp->info.num_inputs);
assert(c->fp->info.file_max[TGSI_FILE_OUTPUT] + 1 == c->fp->info.num_outputs);
for (i = 0; i < c->fp->info.file_max[TGSI_FILE_INPUT] + 1; i++)
for (j = 0; j < 4; j++)
c->wm_regs[TGSI_FILE_INPUT][i][j] = brw_vec8_grf( c->reg_index++, 0 );
for (i = 0; i < c->fp->info.nr_regs[TGSI_FILE_OUTPUT]; i++)
for (i = 0; i < c->fp->info.file_max[TGSI_FILE_OUTPUT] + 1; i++)
for (j = 0; j < 4; j++)
c->wm_regs[TGSI_FILE_OUTPUT][i][j] = brw_vec8_grf( c->reg_index++, 0 );

View file

@ -117,11 +117,11 @@ static void upload_wm_unit(struct brw_context *brw )
if (fp->UsesDepth)
wm.wm5.program_uses_depth = 1; /* as far as we can tell */
if (fp->ComputesDepth)
if (fp->info.writes_z)
wm.wm5.program_computes_depth = 1;
/* BRW_NEW_ALPHA_TEST */
if (fp->UsesKill ||
if (fp->info.uses_kill ||
brw->attribs.DepthStencil->alpha.enabled)
wm.wm5.program_uses_killpixel = 1;

View file

@ -27,6 +27,7 @@ C_SOURCES = \
sp_quad_output.c \
sp_quad_stencil.c \
sp_quad_stipple.c \
sp_screen.c \
sp_state_blend.c \
sp_state_clip.c \
sp_state_derived.c \

View file

@ -47,29 +47,6 @@
/**
* Query format support for creating a texture, drawing surface, etc.
* \param format the format to test
* \param type one of PIPE_TEXTURE, PIPE_SURFACE
*/
static boolean
softpipe_is_format_supported( struct pipe_context *pipe,
enum pipe_format format, uint type )
{
switch (type) {
case PIPE_TEXTURE:
/* softpipe supports all texture formats */
return TRUE;
case PIPE_SURFACE:
/* softpipe supports all (off-screen) surface formats */
return TRUE;
default:
assert(0);
return FALSE;
}
}
/**
* Map any drawing surfaces which aren't already mapped
*/
@ -143,76 +120,10 @@ static void softpipe_destroy( struct pipe_context *pipe )
}
static const char *softpipe_get_name( struct pipe_context *pipe )
{
return "softpipe";
}
static const char *softpipe_get_vendor( struct pipe_context *pipe )
{
return "Tungsten Graphics, Inc.";
}
static int softpipe_get_param(struct pipe_context *pipe, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
return 8;
case PIPE_CAP_NPOT_TEXTURES:
return 1;
case PIPE_CAP_TWO_SIDED_STENCIL:
return 1;
case PIPE_CAP_GLSL:
return 1;
case PIPE_CAP_S3TC:
return 0;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
case PIPE_CAP_POINT_SPRITE:
return 1;
case PIPE_CAP_MAX_RENDER_TARGETS:
return 1;
case PIPE_CAP_OCCLUSION_QUERY:
return 1;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1;
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
return 12; /* max 2Kx2K */
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 12; /* max 2Kx2K */
default:
return 0;
}
}
static float softpipe_get_paramf(struct pipe_context *pipe, int param)
{
switch (param) {
case PIPE_CAP_MAX_LINE_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_LINE_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAP_MAX_POINT_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_POINT_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
return 0.0;
case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
return 16.0; /* arbitrary */
default:
return 0;
}
}
struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
struct softpipe_winsys *softpipe_winsys )
struct pipe_context *
softpipe_create( struct pipe_screen *screen,
struct pipe_winsys *pipe_winsys,
struct softpipe_winsys *softpipe_winsys )
{
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
uint i;
@ -226,15 +137,9 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->dump_fs = GETENV( "GALLIUM_DUMP_FS" ) != NULL;
softpipe->pipe.winsys = pipe_winsys;
softpipe->pipe.screen = screen;
softpipe->pipe.destroy = softpipe_destroy;
/* queries */
softpipe->pipe.is_format_supported = softpipe_is_format_supported;
softpipe->pipe.get_name = softpipe_get_name;
softpipe->pipe.get_vendor = softpipe_get_vendor;
softpipe->pipe.get_param = softpipe_get_param;
softpipe->pipe.get_paramf = softpipe_get_paramf;
/* state setters */
softpipe->pipe.create_blend_state = softpipe_create_blend_state;
softpipe->pipe.bind_blend_state = softpipe_bind_blend_state;
@ -279,12 +184,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.flush = softpipe_flush;
softpipe_init_query_funcs( softpipe );
/* textures */
softpipe->pipe.texture_create = softpipe_texture_create;
softpipe->pipe.texture_release = softpipe_texture_release;
softpipe->pipe.texture_update = softpipe_texture_update;
softpipe->pipe.get_tex_surface = softpipe_get_tex_surface;
softpipe_init_texture_funcs( softpipe );
/*
* Alloc caches for accessing drawing surfaces and textures.
@ -337,9 +237,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe);
#endif
/* sp_prim_setup can do wide points (don't convert to quads) */
draw_convert_wide_points(softpipe->draw, FALSE);
sp_init_surface_functions(softpipe);
return &softpipe->pipe;

View file

@ -96,7 +96,7 @@ shade_quad_llvm(struct quad_stage *qs,
if (qss->colorOutSlot >= 0) {
unsigned i;
/* XXX need to handle multiple color outputs someday */
allvmrt(qss->stage.softpipe->fs->shader.output_semantic_name[qss->colorOutSlot]
allvmrt(qss->stage.softpipe->fs->info.output_semantic_name[qss->colorOutSlot]
== TGSI_SEMANTIC_COLOR);
for (i = 0; i < QUAD_SIZE; ++i) {
quad->outputs.color[0][i] = dests[i][qss->colorOutSlot][0];

View file

@ -514,7 +514,7 @@ setup_fragcoord_coeff(struct setup_stage *setup, uint slot)
static void setup_tri_coefficients( struct setup_stage *setup )
{
struct softpipe_context *softpipe = setup->softpipe;
const struct pipe_shader_state *fs = &softpipe->fs->shader;
const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
uint fragSlot;
@ -525,7 +525,7 @@ static void setup_tri_coefficients( struct setup_stage *setup )
/* setup interpolation for all the remaining attributes:
*/
for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
const uint vertSlot = vinfo->src_index[fragSlot];
uint j;
@ -549,7 +549,7 @@ static void setup_tri_coefficients( struct setup_stage *setup )
assert(0);
}
if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
@ -757,7 +757,7 @@ static INLINE void
setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
{
struct softpipe_context *softpipe = setup->softpipe;
const struct pipe_shader_state *fs = &setup->softpipe->fs->shader;
const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
uint fragSlot;
@ -779,7 +779,7 @@ setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
/* setup interpolation for all the remaining attributes:
*/
for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
const uint vertSlot = vinfo->src_index[fragSlot];
uint j;
@ -803,7 +803,7 @@ setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
assert(0);
}
if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
@ -967,7 +967,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
{
struct setup_stage *setup = setup_stage( stage );
struct softpipe_context *softpipe = setup->softpipe;
const struct pipe_shader_state *fs = &softpipe->fs->shader;
const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_header *v0 = prim->v[0];
const int sizeAttr = setup->softpipe->psize_slot;
const float size
@ -1002,7 +1002,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
const_coeff(setup, &setup->posCoef, 0, 2);
const_coeff(setup, &setup->posCoef, 0, 3);
for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
const uint vertSlot = vinfo->src_index[fragSlot];
uint j;
@ -1025,7 +1025,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
assert(0);
}
if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
@ -1163,13 +1163,13 @@ static void setup_begin( struct draw_stage *stage )
{
struct setup_stage *setup = setup_stage(stage);
struct softpipe_context *sp = setup->softpipe;
const struct pipe_shader_state *fs = &setup->softpipe->fs->shader;
const struct sp_fragment_shader *fs = setup->softpipe->fs;
if (sp->dirty) {
softpipe_update_derived(sp);
}
setup->quad.nr_attrs = fs->num_inputs;
setup->quad.nr_attrs = fs->info.num_inputs;
sp->quad.first->begin(sp->quad.first);

View file

@ -60,8 +60,8 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp->depth_stencil->depth.enabled &&
sp->framebuffer.zsbuf &&
!sp->depth_stencil->alpha.enabled &&
!sp->fs->uses_kill &&
!sp->fs->writes_z;
!sp->fs->info.uses_kill &&
!sp->fs->info.writes_z;
/* build up the pipeline in reverse order... */

View file

@ -91,7 +91,7 @@ shade_quad(
/* store result color */
if (qss->colorOutSlot >= 0) {
/* XXX need to handle multiple color outputs someday */
assert(qss->stage.softpipe->fs->shader.output_semantic_name[qss->colorOutSlot]
assert(qss->stage.softpipe->fs->info.output_semantic_name[qss->colorOutSlot]
== TGSI_SEMANTIC_COLOR);
memcpy(
quad->outputs.color,
@ -148,8 +148,8 @@ static void shade_begin(struct quad_stage *qs)
/* find output slots for depth, color */
qss->colorOutSlot = -1;
qss->depthOutSlot = -1;
for (i = 0; i < qss->stage.softpipe->fs->shader.num_outputs; i++) {
switch (qss->stage.softpipe->fs->shader.output_semantic_name[i]) {
for (i = 0; i < qss->stage.softpipe->fs->info.num_outputs; i++) {
switch (qss->stage.softpipe->fs->info.output_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
qss->depthOutSlot = i;
break;

View file

@ -0,0 +1,165 @@
/**************************************************************************
*
* Copyright 2008 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
#include "sp_texture.h"
#include "sp_winsys.h"
static const char *
softpipe_get_vendor(struct pipe_screen *screen)
{
return "Tungsten Graphics, Inc.";
}
static const char *
softpipe_get_name(struct pipe_screen *screen)
{
return "softpipe";
}
static int
softpipe_get_param(struct pipe_screen *screen, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
return 8;
case PIPE_CAP_NPOT_TEXTURES:
return 1;
case PIPE_CAP_TWO_SIDED_STENCIL:
return 1;
case PIPE_CAP_GLSL:
return 1;
case PIPE_CAP_S3TC:
return 0;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
case PIPE_CAP_POINT_SPRITE:
return 1;
case PIPE_CAP_MAX_RENDER_TARGETS:
return 1;
case PIPE_CAP_OCCLUSION_QUERY:
return 1;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1;
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
return 12; /* max 2Kx2K */
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 12; /* max 2Kx2K */
default:
return 0;
}
}
static float
softpipe_get_paramf(struct pipe_screen *screen, int param)
{
switch (param) {
case PIPE_CAP_MAX_LINE_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_LINE_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAP_MAX_POINT_WIDTH:
/* fall-through */
case PIPE_CAP_MAX_POINT_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
return 0.0;
case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
return 16.0; /* arbitrary */
default:
return 0;
}
}
/**
* Query format support for creating a texture, drawing surface, etc.
* \param format the format to test
* \param type one of PIPE_TEXTURE, PIPE_SURFACE
*/
static boolean
softpipe_is_format_supported( struct pipe_screen *screen,
enum pipe_format format, uint type )
{
switch (type) {
case PIPE_TEXTURE:
/* softpipe supports all texture formats */
return TRUE;
case PIPE_SURFACE:
/* softpipe supports all (off-screen) surface formats */
return TRUE;
default:
assert(0);
return FALSE;
}
}
static void
softpipe_destroy_screen( struct pipe_screen *screen )
{
FREE(screen);
}
/**
* Create a new pipe_screen object
* Note: we're not presently subclassing pipe_screen (no softpipe_screen).
*/
struct pipe_screen *
softpipe_create_screen(struct pipe_winsys *winsys)
{
struct pipe_screen *screen = CALLOC_STRUCT(pipe_screen);
if (!screen)
return NULL;
screen->winsys = winsys;
screen->destroy = softpipe_destroy_screen;
screen->get_name = softpipe_get_name;
screen->get_vendor = softpipe_get_vendor;
screen->get_param = softpipe_get_param;
screen->get_paramf = softpipe_get_paramf;
screen->is_format_supported = softpipe_is_format_supported;
softpipe_init_screen_texture_funcs(screen);
return screen;
}

Some files were not shown because too many files have changed in this diff Show more