updated mesa to 6.5.3
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21351 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -38,17 +38,11 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef CAPI
|
||||
#undef CAPI
|
||||
#endif
|
||||
#define CAPI
|
||||
|
||||
#define GL_CORE_SGI 1
|
||||
#define GL_CORE_MESA 2
|
||||
#define GL_CORE_APPLE 4
|
||||
|
||||
typedef struct __GLcontextRec __GLcontext;
|
||||
typedef struct __GLinterfaceRec __GLinterface;
|
||||
|
||||
/*
|
||||
** This file defines the interface between the GL core and the surrounding
|
||||
@@ -186,334 +180,4 @@ typedef struct __GLcontextModesRec {
|
||||
#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
|
||||
#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
** Structure used for allocating and freeing drawable private memory.
|
||||
** (like software buffers, for example).
|
||||
**
|
||||
** The memory allocation routines are provided by the surrounding
|
||||
** "operating system" code, and they are to be used for allocating
|
||||
** software buffers and things which are associated with the drawable,
|
||||
** and used by any context which draws to that drawable. There are
|
||||
** separate memory allocation functions for drawables and contexts
|
||||
** since drawables and contexts can be created and destroyed independently
|
||||
** of one another, and the "operating system" may want to use separate
|
||||
** allocation arenas for each.
|
||||
**
|
||||
** The freePrivate function is filled in by the core routines when they
|
||||
** allocates software buffers, and stick them in "private". The freePrivate
|
||||
** function will destroy anything allocated to this drawable (to be called
|
||||
** when the drawable is destroyed).
|
||||
*/
|
||||
typedef struct __GLdrawableRegionRec __GLdrawableRegion;
|
||||
typedef struct __GLdrawableBufferRec __GLdrawableBuffer;
|
||||
typedef struct __GLdrawablePrivateRec __GLdrawablePrivate;
|
||||
|
||||
typedef struct __GLregionRectRec {
|
||||
/* lower left (inside the rectangle) */
|
||||
GLint x0, y0;
|
||||
/* upper right (outside the rectangle) */
|
||||
GLint x1, y1;
|
||||
} __GLregionRect;
|
||||
|
||||
struct __GLdrawableRegionRec {
|
||||
GLint numRects;
|
||||
__GLregionRect *rects;
|
||||
__GLregionRect boundingRect;
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/* masks for the buffers */
|
||||
#define __GL_FRONT_BUFFER_MASK 0x00000001
|
||||
#define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001
|
||||
#define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002
|
||||
#define __GL_BACK_BUFFER_MASK 0x00000004
|
||||
#define __GL_BACK_LEFT_BUFFER_MASK 0x00000004
|
||||
#define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008
|
||||
#define __GL_ACCUM_BUFFER_MASK 0x00000010
|
||||
#define __GL_DEPTH_BUFFER_MASK 0x00000020
|
||||
#define __GL_STENCIL_BUFFER_MASK 0x00000040
|
||||
#define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i))
|
||||
|
||||
#define __GL_ALL_BUFFER_MASK 0xffffffff
|
||||
|
||||
/* what Resize routines return if resize resorted to fallback case */
|
||||
#define __GL_BUFFER_FALLBACK 0x10
|
||||
|
||||
typedef void (*__GLbufFallbackInitFn)(__GLdrawableBuffer *buf,
|
||||
__GLdrawablePrivate *glPriv, GLint bits);
|
||||
typedef void (*__GLbufMainInitFn)(__GLdrawableBuffer *buf,
|
||||
__GLdrawablePrivate *glPriv, GLint bits,
|
||||
__GLbufFallbackInitFn back);
|
||||
|
||||
/*
|
||||
** A drawable buffer
|
||||
**
|
||||
** This data structure describes the context side of a drawable.
|
||||
**
|
||||
** According to the spec there could be multiple contexts bound to the same
|
||||
** drawable at the same time (from different threads). In order to avoid
|
||||
** multiple-access conflicts, locks are used to serialize access. When a
|
||||
** thread needs to access (read or write) a member of the drawable, it takes
|
||||
** a lock first. Some of the entries in the drawable are treated "mostly
|
||||
** constant", so we take the freedom of allowing access to them without
|
||||
** taking a lock (for optimization reasons).
|
||||
**
|
||||
** For more details regarding locking, see buffers.h in the GL core
|
||||
*/
|
||||
struct __GLdrawableBufferRec {
|
||||
/*
|
||||
** Buffer dimensions
|
||||
*/
|
||||
GLint width, height, depth;
|
||||
|
||||
/*
|
||||
** Framebuffer base address
|
||||
*/
|
||||
void *base;
|
||||
|
||||
/*
|
||||
** Framebuffer size (in bytes)
|
||||
*/
|
||||
GLuint size;
|
||||
|
||||
/*
|
||||
** Size (in bytes) of each element in the framebuffer
|
||||
*/
|
||||
GLuint elementSize;
|
||||
GLuint elementSizeLog2;
|
||||
|
||||
/*
|
||||
** Element skip from one scanline to the next.
|
||||
** If the buffer is part of another buffer (for example, fullscreen
|
||||
** front buffer), outerWidth is the width of that buffer.
|
||||
*/
|
||||
GLint outerWidth;
|
||||
|
||||
/*
|
||||
** outerWidth * elementSize
|
||||
*/
|
||||
GLint byteWidth;
|
||||
|
||||
/*
|
||||
** Allocation/deallocation is done based on this handle. A handle
|
||||
** is conceptually different from the framebuffer 'base'.
|
||||
*/
|
||||
void *handle;
|
||||
|
||||
/* imported */
|
||||
GLboolean (*resize)(__GLdrawableBuffer *buf,
|
||||
GLint x, GLint y, GLuint width, GLuint height,
|
||||
__GLdrawablePrivate *glPriv, GLuint bufferMask);
|
||||
void (*lock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
|
||||
void (*unlock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
|
||||
void (*fill)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
|
||||
GLuint val, GLint x, GLint y, GLint w, GLint h);
|
||||
void (*free)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
|
||||
|
||||
/* exported */
|
||||
void (*freePrivate)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
|
||||
#ifdef __cplusplus
|
||||
void *privatePtr;
|
||||
#else
|
||||
void *private;
|
||||
#endif
|
||||
|
||||
/* private */
|
||||
void *other; /* implementation private data */
|
||||
__GLbufMainInitFn mainInit;
|
||||
__GLbufFallbackInitFn fallbackInit;
|
||||
};
|
||||
|
||||
/*
|
||||
** The context side of the drawable private
|
||||
*/
|
||||
struct __GLdrawablePrivateRec {
|
||||
/*
|
||||
** Drawable Modes
|
||||
*/
|
||||
__GLcontextModes *modes;
|
||||
|
||||
/*
|
||||
** Drawable size
|
||||
*/
|
||||
GLuint width, height;
|
||||
|
||||
/*
|
||||
** Origin in screen coordinates of the drawable
|
||||
*/
|
||||
GLint xOrigin, yOrigin;
|
||||
#ifdef __GL_ALIGNED_BUFFERS
|
||||
/*
|
||||
** Drawable offset from screen origin
|
||||
*/
|
||||
GLint xOffset, yOffset;
|
||||
|
||||
/*
|
||||
** Alignment restriction
|
||||
*/
|
||||
GLint xAlignment, yAlignment;
|
||||
#endif
|
||||
/*
|
||||
** Should we invert the y axis?
|
||||
*/
|
||||
GLint yInverted;
|
||||
|
||||
/*
|
||||
** Mask specifying which buffers are renderable by the hw
|
||||
*/
|
||||
GLuint accelBufferMask;
|
||||
|
||||
/*
|
||||
** the buffers themselves
|
||||
*/
|
||||
__GLdrawableBuffer frontBuffer;
|
||||
__GLdrawableBuffer backBuffer;
|
||||
__GLdrawableBuffer accumBuffer;
|
||||
__GLdrawableBuffer depthBuffer;
|
||||
__GLdrawableBuffer stencilBuffer;
|
||||
#if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0)
|
||||
__GLdrawableBuffer *auxBuffer;
|
||||
#endif
|
||||
|
||||
__GLdrawableRegion ownershipRegion;
|
||||
|
||||
/*
|
||||
** Lock for the drawable private structure
|
||||
*/
|
||||
void *lock;
|
||||
#ifdef DEBUG
|
||||
/* lock debugging info */
|
||||
int lockRefCount;
|
||||
int lockLine[10];
|
||||
char *lockFile[10];
|
||||
#endif
|
||||
|
||||
/* imported */
|
||||
void *(*malloc)(size_t size);
|
||||
void *(*calloc)(size_t numElem, size_t elemSize);
|
||||
void *(*realloc)(void *oldAddr, size_t newSize);
|
||||
void (*free)(void *addr);
|
||||
|
||||
GLboolean (*addSwapRect)(__GLdrawablePrivate *glPriv,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void (*setClipRect)(__GLdrawablePrivate *glPriv,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void (*updateClipRegion)(__GLdrawablePrivate *glPriv);
|
||||
GLboolean (*resize)(__GLdrawablePrivate *glPriv);
|
||||
void (*getDrawableSize)(__GLdrawablePrivate *glPriv,
|
||||
GLint *x, GLint *y, GLuint *width, GLuint *height);
|
||||
|
||||
void (*lockDP)(__GLdrawablePrivate *glPriv, __GLcontext *gc);
|
||||
void (*unlockDP)(__GLdrawablePrivate *glPriv);
|
||||
|
||||
/* exported */
|
||||
#ifdef __cplusplus
|
||||
void *privatePtr;
|
||||
#else
|
||||
void *private;
|
||||
#endif
|
||||
void (*freePrivate)(__GLdrawablePrivate *);
|
||||
|
||||
/* client data */
|
||||
void *other;
|
||||
};
|
||||
|
||||
/*
|
||||
** Macros to lock/unlock the drawable private
|
||||
*/
|
||||
#if defined(DEBUG)
|
||||
#define __GL_LOCK_DP(glPriv,gc) \
|
||||
(*(glPriv)->lockDP)(glPriv,gc); \
|
||||
(glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
|
||||
(glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
|
||||
(glPriv)->lockRefCount++
|
||||
#define __GL_UNLOCK_DP(glPriv) \
|
||||
(glPriv)->lockRefCount--; \
|
||||
(glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
|
||||
(glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
|
||||
(*(glPriv)->unlockDP)(glPriv)
|
||||
#else /* DEBUG */
|
||||
#define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc)
|
||||
#define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv)
|
||||
#endif /* DEBUG */
|
||||
|
||||
|
||||
/*
|
||||
** Procedures which are imported by the GL from the surrounding
|
||||
** "operating system". Math functions are not considered part of the
|
||||
** "operating system".
|
||||
*/
|
||||
typedef struct __GLimportsRec {
|
||||
/* Memory management */
|
||||
void * (*malloc)(__GLcontext *gc, size_t size);
|
||||
void *(*calloc)(__GLcontext *gc, size_t numElem, size_t elemSize);
|
||||
void *(*realloc)(__GLcontext *gc, void *oldAddr, size_t newSize);
|
||||
void (*free)(__GLcontext *gc, void *addr);
|
||||
|
||||
/* Error handling */
|
||||
void (*warning)(__GLcontext *gc, char *fmt);
|
||||
void (*fatal)(__GLcontext *gc, char *fmt);
|
||||
|
||||
/* other system calls */
|
||||
char *(CAPI *getenv)(__GLcontext *gc, const char *var);
|
||||
int (CAPI *atoi)(__GLcontext *gc, const char *str);
|
||||
int (CAPI *sprintf)(__GLcontext *gc, char *str, const char *fmt, ...);
|
||||
void *(CAPI *fopen)(__GLcontext *gc, const char *path, const char *mode);
|
||||
int (CAPI *fclose)(__GLcontext *gc, void *stream);
|
||||
int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...);
|
||||
|
||||
/* Drawing surface management */
|
||||
__GLdrawablePrivate *(*getDrawablePrivate)(__GLcontext *gc);
|
||||
__GLdrawablePrivate *(*getReadablePrivate)(__GLcontext *gc);
|
||||
|
||||
/* Operating system dependent data goes here */
|
||||
void *other;
|
||||
} __GLimports;
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
** Procedures which are exported by the GL to the surrounding "operating
|
||||
** system" so that it can manage multiple GL context's.
|
||||
*/
|
||||
typedef struct __GLexportsRec {
|
||||
/* Context management (return GL_FALSE on failure) */
|
||||
GLboolean (*destroyContext)(__GLcontext *gc);
|
||||
GLboolean (*loseCurrent)(__GLcontext *gc);
|
||||
/* oldglPriv isn't used anymore, kept for backwards compatibility */
|
||||
GLboolean (*makeCurrent)(__GLcontext *gc);
|
||||
GLboolean (*shareContext)(__GLcontext *gc, __GLcontext *gcShare);
|
||||
GLboolean (*copyContext)(__GLcontext *dst, const __GLcontext *src, GLuint mask);
|
||||
GLboolean (*forceCurrent)(__GLcontext *gc);
|
||||
|
||||
/* Drawing surface notification callbacks */
|
||||
GLboolean (*notifyResize)(__GLcontext *gc);
|
||||
void (*notifyDestroy)(__GLcontext *gc);
|
||||
void (*notifySwapBuffers)(__GLcontext *gc);
|
||||
|
||||
/* Dispatch table override control for external agents like libGLS */
|
||||
struct __GLdispatchStateRec* (*dispatchExec)(__GLcontext *gc);
|
||||
void (*beginDispatchOverride)(__GLcontext *gc);
|
||||
void (*endDispatchOverride)(__GLcontext *gc);
|
||||
} __GLexports;
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
** This must be the first member of a __GLcontext structure. This is the
|
||||
** only part of a context that is exposed to the outside world; everything
|
||||
** else is opaque.
|
||||
*/
|
||||
struct __GLinterfaceRec {
|
||||
__GLimports imports;
|
||||
__GLexports exports;
|
||||
};
|
||||
|
||||
extern __GLcontext *__glCoreCreateContext(__GLimports *, __GLcontextModes *);
|
||||
extern void __glCoreNopDispatch(void);
|
||||
|
||||
#endif /* __gl_core_h_ */
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <Screen.h>
|
||||
|
||||
extern "C" {
|
||||
#include "array_cache/acache.h"
|
||||
#include "extensions.h"
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
#include "main/colormac.h"
|
||||
@@ -35,6 +34,7 @@ extern "C" {
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
#include "vbo/vbo.h"
|
||||
|
||||
|
||||
#if defined(USE_X86_ASM)
|
||||
@@ -55,11 +55,6 @@ extern const char * color_space_name(color_space space);
|
||||
#define BE_BCOMP 0
|
||||
#define BE_ACOMP 3
|
||||
|
||||
#define PACK_B_RGBA32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
|
||||
(color[RCOMP] << 16) | (color[ACOMP] << 24))
|
||||
|
||||
#define PACK_B_RGB32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
|
||||
(color[RCOMP] << 16) | 0xFF000000)
|
||||
#else
|
||||
// Big Endian B_RGBA32 bitmap format
|
||||
#define BE_RCOMP 1
|
||||
@@ -67,11 +62,6 @@ extern const char * color_space_name(color_space space);
|
||||
#define BE_BCOMP 3
|
||||
#define BE_ACOMP 0
|
||||
|
||||
#define PACK_B_RGBA32(color) (color[ACOMP] | (color[RCOMP] << 8) | \
|
||||
(color[GCOMP] << 16) | (color[BCOMP] << 24))
|
||||
|
||||
#define PACK_B_RGB32(color) ((color[RCOMP] << 8) | (color[GCOMP] << 16) | \
|
||||
(color[BCOMP] << 24) | 0xFF000000)
|
||||
#endif
|
||||
|
||||
/**********************************************************************/
|
||||
@@ -213,7 +203,7 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView *view, ulong options, BGLDisp
|
||||
|
||||
/* Initialize the software rasterizer and helper modules. */
|
||||
_swrast_CreateContext(fContext);
|
||||
_ac_CreateContext(fContext);
|
||||
_vbo_CreateContext(fContext);
|
||||
_tnl_CreateContext(fContext);
|
||||
_swsetup_CreateContext(fContext);
|
||||
_swsetup_Wakeup(fContext);
|
||||
@@ -310,7 +300,7 @@ MesaSoftwareRenderer::LockGL()
|
||||
fRenderBuffer->PutMonoValues = put_mono_values_RGB16;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unsupported screen color space %ld\n", cs);
|
||||
fprintf(stderr, "unsupported screen color space %d\n", cs);
|
||||
debugger("unsupported OpenGL color space");
|
||||
break;
|
||||
}
|
||||
@@ -347,9 +337,12 @@ void
|
||||
MesaSoftwareRenderer::SwapBuffers(bool VSync)
|
||||
{
|
||||
CALLED();
|
||||
_mesa_notifySwapBuffers(fContext);
|
||||
|
||||
|
||||
if (fBitmap) {
|
||||
if (fVisual->doubleBufferMode)
|
||||
_mesa_notifySwapBuffers(fContext);
|
||||
|
||||
if (!fDirectModeEnabled || fInfo == NULL) {
|
||||
GLView()->LockLooper();
|
||||
GLView()->DrawBitmap(fBitmap);
|
||||
@@ -627,7 +620,7 @@ MesaSoftwareRenderer::UpdateState(GLcontext *ctx, GLuint new_state)
|
||||
CALLED();
|
||||
_swrast_InvalidateState(ctx, new_state);
|
||||
_swsetup_InvalidateState(ctx, new_state);
|
||||
_ac_InvalidateState(ctx, new_state);
|
||||
_vbo_InvalidateState(ctx, new_state);
|
||||
_tnl_InvalidateState(ctx, new_state);
|
||||
}
|
||||
|
||||
@@ -636,6 +629,8 @@ GLboolean
|
||||
MesaSoftwareRenderer::RenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *render,
|
||||
GLenum internalFormat, GLuint width, GLuint height)
|
||||
{
|
||||
render->Width = width;
|
||||
render->Height = height;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@@ -652,3 +647,4 @@ MesaSoftwareRenderer::DirectConnected(direct_buffer_info *info)
|
||||
{
|
||||
fInfo = info;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ UseHeaders [ FDirName $(SUBDIR) shader grammar ] ;
|
||||
UseHeaders [ FDirName $(SUBDIR) shader slang ] ;
|
||||
UseHeaders [ FDirName $(SUBDIR) swrast ] ;
|
||||
UseHeaders [ FDirName $(SUBDIR) swrast_setup ] ;
|
||||
UseHeaders [ FDirName $(SUBDIR) vbo ] ;
|
||||
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) array_cache ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) drivers common ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) glapi ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) main ] ;
|
||||
@@ -33,6 +33,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) shader slang ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) swrast ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) swrast_setup ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) tnl ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) vbo ] ;
|
||||
|
||||
{
|
||||
local defines ;
|
||||
@@ -83,11 +84,6 @@ if $(TARGET_ARCH) = x86 {
|
||||
read_rgba_span_x86.S
|
||||
|
||||
t_vertex_sse.c
|
||||
t_vb_arbprogram_sse.c
|
||||
t_vtx_x86.c
|
||||
t_vtx_x86_gcc.S
|
||||
|
||||
slang_execute_x86.c
|
||||
|
||||
x86sse.c
|
||||
;
|
||||
@@ -158,12 +154,13 @@ StaticLibrary libmesa.a :
|
||||
lines.c
|
||||
matrix.c
|
||||
mipmap.c
|
||||
occlude.c
|
||||
pixel.c
|
||||
points.c
|
||||
polygon.c
|
||||
queryobj.c
|
||||
rastpos.c
|
||||
renderbuffer.c
|
||||
shaders.c
|
||||
state.c
|
||||
stencil.c
|
||||
texcompress.c
|
||||
@@ -189,20 +186,10 @@ StaticLibrary libmesa.a :
|
||||
m_vector.c
|
||||
m_xform.c
|
||||
|
||||
# array_cache
|
||||
ac_context.c
|
||||
ac_import.c
|
||||
|
||||
# tnl
|
||||
t_array_api.c
|
||||
t_array_import.c
|
||||
t_context.c
|
||||
t_draw.c
|
||||
t_pipeline.c
|
||||
t_save_api.c
|
||||
t_save_loopback.c
|
||||
t_save_playback.c
|
||||
t_vb_arbprogram.c
|
||||
t_vb_arbshader.c
|
||||
t_vb_cull.c
|
||||
t_vb_fog.c
|
||||
t_vb_light.c
|
||||
@@ -216,17 +203,12 @@ StaticLibrary libmesa.a :
|
||||
t_vp_build.c
|
||||
t_vertex.c
|
||||
t_vertex_generic.c
|
||||
t_vtx_api.c
|
||||
t_vtx_generic.c
|
||||
t_vtx_eval.c
|
||||
t_vtx_exec.c
|
||||
|
||||
# swrast
|
||||
s_aaline.c
|
||||
s_aatriangle.c
|
||||
s_accum.c
|
||||
s_alpha.c
|
||||
s_arbshader.c
|
||||
s_atifragshader.c
|
||||
s_bitmap.c
|
||||
s_blend.c
|
||||
@@ -238,11 +220,11 @@ StaticLibrary libmesa.a :
|
||||
s_drawpix.c
|
||||
s_feedback.c
|
||||
s_fog.c
|
||||
s_fragprog.c
|
||||
s_imaging.c
|
||||
s_lines.c
|
||||
s_logic.c
|
||||
s_masking.c
|
||||
s_nvfragprog.c
|
||||
s_points.c
|
||||
s_readpix.c
|
||||
s_span.c
|
||||
@@ -263,35 +245,56 @@ StaticLibrary libmesa.a :
|
||||
atifragshader.c
|
||||
nvfragparse.c
|
||||
nvprogram.c
|
||||
nvvertexec.c
|
||||
nvvertparse.c
|
||||
prog_execute.c
|
||||
prog_instruction.c
|
||||
prog_parameter.c
|
||||
prog_print.c
|
||||
prog_statevars.c
|
||||
program.c
|
||||
shaderobjects.c
|
||||
shaderobjects_3dlabs.c
|
||||
shader_api.c
|
||||
|
||||
# shader/grammar
|
||||
grammar_mesa.c
|
||||
|
||||
# shader/slang
|
||||
slang_analyse.c
|
||||
slang_assemble.c
|
||||
slang_assemble_assignment.c
|
||||
slang_assemble_conditional.c
|
||||
slang_assemble_constructor.c
|
||||
slang_assemble_typeinfo.c
|
||||
slang_builtin.c
|
||||
slang_codegen.c
|
||||
slang_compile.c
|
||||
slang_compile_function.c
|
||||
slang_compile_operation.c
|
||||
slang_compile_struct.c
|
||||
slang_compile_variable.c
|
||||
slang_execute.c
|
||||
slang_export.c
|
||||
slang_emit.c
|
||||
slang_ir.c
|
||||
slang_label.c
|
||||
slang_library_noise.c
|
||||
slang_library_texsample.c
|
||||
slang_link.c
|
||||
slang_log.c
|
||||
slang_mem.c
|
||||
slang_preprocess.c
|
||||
slang_print.c
|
||||
slang_simplify.c
|
||||
slang_storage.c
|
||||
slang_typeinfo.c
|
||||
slang_utility.c
|
||||
slang_vartable.c
|
||||
|
||||
# vbo
|
||||
vbo_context.c
|
||||
vbo_exec.c
|
||||
vbo_exec_api.c
|
||||
vbo_exec_array.c
|
||||
vbo_exec_draw.c
|
||||
vbo_exec_eval.c
|
||||
vbo_rebase.c
|
||||
vbo_save.c
|
||||
vbo_save_api.c
|
||||
vbo_save_draw.c
|
||||
vbo_save_loopback.c
|
||||
vbo_split.c
|
||||
vbo_split_copy.c
|
||||
vbo_split_inplace.c
|
||||
|
||||
$(arch_sources)
|
||||
|
||||
|
||||
@@ -1,375 +0,0 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 5.1
|
||||
*
|
||||
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <[email protected]>
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "macros.h"
|
||||
#include "imports.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
#include "array_cache/ac_context.h"
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the array fallbacks. That is, by default the fallback arrays
|
||||
* point into the current vertex attribute values in ctx->Current.Attrib[]
|
||||
*/
|
||||
static void _ac_fallbacks_init( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
struct gl_client_array *cl;
|
||||
GLuint i;
|
||||
|
||||
cl = &ac->Fallback.Normal;
|
||||
cl->Size = 3;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Fallback.Color;
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Fallback.SecondaryColor;
|
||||
cl->Size = 3;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Fallback.FogCoord;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) &ctx->Current.Attrib[VERT_ATTRIB_FOG];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Fallback.Index;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) &ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++) {
|
||||
cl = &ac->Fallback.TexCoord[i];
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
}
|
||||
|
||||
cl = &ac->Fallback.EdgeFlag;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_UNSIGNED_BYTE;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) &ctx->Current.EdgeFlag;
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
|
||||
cl = &ac->Fallback.Attrib[i];
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) ctx->Current.Attrib[i];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the array cache pointers, types, strides, etc.
|
||||
*/
|
||||
static void _ac_cache_init( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
struct gl_client_array *cl;
|
||||
GLuint size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES;
|
||||
GLuint i;
|
||||
|
||||
cl = &ac->Cache.Vertex;
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 4 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.Normal;
|
||||
cl->Size = 3;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 3 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.Color;
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 4 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.SecondaryColor;
|
||||
cl->Size = 3;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 4 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.FogCoord;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.Index;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
|
||||
cl = &ac->Cache.TexCoord[i];
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 4 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
}
|
||||
|
||||
cl = &ac->Cache.EdgeFlag;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_UNSIGNED_BYTE;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = sizeof(GLubyte);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
for (i = 0 ; i < VERT_ATTRIB_MAX; i++) {
|
||||
cl = &ac->Cache.Attrib[i];
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 4 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* This storage used to hold translated client data if type or stride
|
||||
* need to be fixed.
|
||||
*/
|
||||
static void _ac_elts_init( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
GLuint size = 1000;
|
||||
|
||||
ac->Elts = (GLuint *)MALLOC( sizeof(GLuint) * size );
|
||||
ac->elt_size = size;
|
||||
}
|
||||
|
||||
static void _ac_raw_init( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
GLuint i;
|
||||
|
||||
ac->Raw.Color = ac->Fallback.Color;
|
||||
ac->Raw.EdgeFlag = ac->Fallback.EdgeFlag;
|
||||
ac->Raw.FogCoord = ac->Fallback.FogCoord;
|
||||
ac->Raw.Index = ac->Fallback.Index;
|
||||
ac->Raw.Normal = ac->Fallback.Normal;
|
||||
ac->Raw.SecondaryColor = ac->Fallback.SecondaryColor;
|
||||
ac->Raw.Vertex = ctx->Array.ArrayObj->Vertex;
|
||||
|
||||
ac->IsCached.Color = GL_FALSE;
|
||||
ac->IsCached.EdgeFlag = GL_FALSE;
|
||||
ac->IsCached.FogCoord = GL_FALSE;
|
||||
ac->IsCached.Index = GL_FALSE;
|
||||
ac->IsCached.Normal = GL_FALSE;
|
||||
ac->IsCached.SecondaryColor = GL_FALSE;
|
||||
ac->IsCached.Vertex = GL_FALSE;
|
||||
|
||||
for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++) {
|
||||
ac->Raw.TexCoord[i] = ac->Fallback.TexCoord[i];
|
||||
ac->IsCached.TexCoord[i] = GL_FALSE;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < VERT_ATTRIB_MAX ; i++) {
|
||||
ac->Raw.Attrib[i] = ac->Fallback.Attrib[i];
|
||||
ac->IsCached.Attrib[i] = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
GLboolean _ac_CreateContext( GLcontext *ctx )
|
||||
{
|
||||
ctx->acache_context = CALLOC(sizeof(ACcontext));
|
||||
if (ctx->acache_context) {
|
||||
_ac_cache_init( ctx );
|
||||
_ac_fallbacks_init( ctx );
|
||||
_ac_raw_init( ctx );
|
||||
_ac_elts_init( ctx );
|
||||
return GL_TRUE;
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
void _ac_DestroyContext( GLcontext *ctx )
|
||||
{
|
||||
struct gl_buffer_object *nullObj = ctx->Array.NullBufferObj;
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
GLint i;
|
||||
|
||||
/* only free vertex data if it's really a pointer to vertex data and
|
||||
* not an offset into a buffer object.
|
||||
*/
|
||||
if (ac->Cache.Vertex.Ptr && ac->Cache.Vertex.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Vertex.Ptr );
|
||||
if (ac->Cache.Normal.Ptr && ac->Cache.Normal.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Normal.Ptr );
|
||||
if (ac->Cache.Color.Ptr && ac->Cache.Color.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Color.Ptr );
|
||||
if (ac->Cache.SecondaryColor.Ptr && ac->Cache.SecondaryColor.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.SecondaryColor.Ptr );
|
||||
if (ac->Cache.EdgeFlag.Ptr && ac->Cache.EdgeFlag.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.EdgeFlag.Ptr );
|
||||
if (ac->Cache.Index.Ptr && ac->Cache.Index.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Index.Ptr );
|
||||
if (ac->Cache.FogCoord.Ptr && ac->Cache.FogCoord.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.FogCoord.Ptr );
|
||||
|
||||
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
|
||||
if (ac->Cache.TexCoord[i].Ptr && ac->Cache.TexCoord[i].BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.TexCoord[i].Ptr );
|
||||
}
|
||||
|
||||
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
|
||||
if (ac->Cache.Attrib[i].Ptr && ac->Cache.Attrib[i].BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Attrib[i].Ptr );
|
||||
}
|
||||
|
||||
if (ac->Elts)
|
||||
FREE( ac->Elts );
|
||||
|
||||
/* Free the context structure itself */
|
||||
FREE(ac);
|
||||
ctx->acache_context = NULL;
|
||||
}
|
||||
|
||||
void _ac_InvalidateState( GLcontext *ctx, GLuint new_state )
|
||||
{
|
||||
AC_CONTEXT(ctx)->NewState |= new_state;
|
||||
AC_CONTEXT(ctx)->NewArrayState |= ctx->Array.NewState;
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 5.1
|
||||
*
|
||||
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef _AC_CONTEXT_H
|
||||
#define _AC_CONTEXT_H
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
#include "array_cache/acache.h"
|
||||
|
||||
/* These are used to make the ctx->Current values look like
|
||||
* arrays (with zero StrideB).
|
||||
*/
|
||||
struct ac_arrays {
|
||||
struct gl_client_array Vertex;
|
||||
struct gl_client_array Normal;
|
||||
struct gl_client_array Color;
|
||||
struct gl_client_array SecondaryColor;
|
||||
struct gl_client_array FogCoord;
|
||||
struct gl_client_array Index;
|
||||
struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
|
||||
struct gl_client_array EdgeFlag;
|
||||
struct gl_client_array Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
|
||||
};
|
||||
|
||||
struct ac_array_pointers {
|
||||
struct gl_client_array *Vertex;
|
||||
struct gl_client_array *Normal;
|
||||
struct gl_client_array *Color;
|
||||
struct gl_client_array *SecondaryColor;
|
||||
struct gl_client_array *FogCoord;
|
||||
struct gl_client_array *Index;
|
||||
struct gl_client_array *TexCoord[MAX_TEXTURE_COORD_UNITS];
|
||||
struct gl_client_array *EdgeFlag;
|
||||
struct gl_client_array *Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
|
||||
};
|
||||
|
||||
struct ac_array_flags {
|
||||
GLboolean Vertex;
|
||||
GLboolean Normal;
|
||||
GLboolean Color;
|
||||
GLboolean SecondaryColor;
|
||||
GLboolean FogCoord;
|
||||
GLboolean Index;
|
||||
GLboolean TexCoord[MAX_TEXTURE_COORD_UNITS];
|
||||
GLboolean EdgeFlag;
|
||||
GLboolean Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
GLuint NewState; /* not needed? */
|
||||
GLuint NewArrayState;
|
||||
|
||||
/* Facility for importing and caching array data:
|
||||
*/
|
||||
struct ac_arrays Fallback;
|
||||
struct ac_arrays Cache;
|
||||
struct ac_arrays Raw;
|
||||
struct ac_array_flags IsCached;
|
||||
GLuint start;
|
||||
GLuint count;
|
||||
|
||||
/* Facility for importing element lists:
|
||||
*/
|
||||
GLuint *Elts;
|
||||
GLuint elt_size;
|
||||
|
||||
} ACcontext;
|
||||
|
||||
#define AC_CONTEXT(ctx) ((ACcontext *)ctx->acache_context)
|
||||
|
||||
#endif
|
||||
@@ -1,922 +0,0 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <[email protected]>
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "macros.h"
|
||||
#include "imports.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
#include "math/m_translate.h"
|
||||
#include "array_cache/ac_context.h"
|
||||
#include "math/m_translate.h"
|
||||
|
||||
#define STRIDE_ARRAY( array, offset ) \
|
||||
do { \
|
||||
GLubyte *tmp = ADD_POINTERS( (array).BufferObj->Data, (array).Ptr ) \
|
||||
+ (offset) * (array).StrideB; \
|
||||
(array).Ptr = tmp; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Set the array pointer back to its source when the cached data is
|
||||
* invalidated:
|
||||
*/
|
||||
static void
|
||||
reset_texcoord( GLcontext *ctx, GLuint unit )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->TexCoord[unit].Enabled) {
|
||||
ac->Raw.TexCoord[unit] = ctx->Array.ArrayObj->TexCoord[unit];
|
||||
STRIDE_ARRAY(ac->Raw.TexCoord[unit], ac->start);
|
||||
}
|
||||
else {
|
||||
ac->Raw.TexCoord[unit] = ac->Fallback.TexCoord[unit];
|
||||
|
||||
if (ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3] != 1.0)
|
||||
ac->Raw.TexCoord[unit].Size = 4;
|
||||
else if (ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2] != 0.0)
|
||||
ac->Raw.TexCoord[unit].Size = 3;
|
||||
else
|
||||
ac->Raw.TexCoord[unit].Size = 2;
|
||||
}
|
||||
|
||||
ac->IsCached.TexCoord[unit] = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_TEXCOORD(unit);
|
||||
}
|
||||
|
||||
static void
|
||||
reset_vertex( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
ASSERT(ctx->Array.ArrayObj->Vertex.Enabled
|
||||
|| (ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled));
|
||||
ac->Raw.Vertex = ctx->Array.ArrayObj->Vertex;
|
||||
STRIDE_ARRAY(ac->Raw.Vertex, ac->start);
|
||||
ac->IsCached.Vertex = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_VERTEX;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_normal( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->Normal.Enabled) {
|
||||
ac->Raw.Normal = ctx->Array.ArrayObj->Normal;
|
||||
STRIDE_ARRAY(ac->Raw.Normal, ac->start);
|
||||
}
|
||||
else {
|
||||
ac->Raw.Normal = ac->Fallback.Normal;
|
||||
}
|
||||
|
||||
ac->IsCached.Normal = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_NORMAL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_color( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->Color.Enabled) {
|
||||
ac->Raw.Color = ctx->Array.ArrayObj->Color;
|
||||
STRIDE_ARRAY(ac->Raw.Color, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.Color = ac->Fallback.Color;
|
||||
|
||||
ac->IsCached.Color = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_COLOR0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_secondarycolor( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->SecondaryColor.Enabled) {
|
||||
ac->Raw.SecondaryColor = ctx->Array.ArrayObj->SecondaryColor;
|
||||
STRIDE_ARRAY(ac->Raw.SecondaryColor, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.SecondaryColor = ac->Fallback.SecondaryColor;
|
||||
|
||||
ac->IsCached.SecondaryColor = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_COLOR1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_index( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->Index.Enabled) {
|
||||
ac->Raw.Index = ctx->Array.ArrayObj->Index;
|
||||
STRIDE_ARRAY(ac->Raw.Index, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.Index = ac->Fallback.Index;
|
||||
|
||||
ac->IsCached.Index = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_INDEX;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_fogcoord( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->FogCoord.Enabled) {
|
||||
ac->Raw.FogCoord = ctx->Array.ArrayObj->FogCoord;
|
||||
STRIDE_ARRAY(ac->Raw.FogCoord, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.FogCoord = ac->Fallback.FogCoord;
|
||||
|
||||
ac->IsCached.FogCoord = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_FOGCOORD;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_edgeflag( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->EdgeFlag.Enabled) {
|
||||
ac->Raw.EdgeFlag = ctx->Array.ArrayObj->EdgeFlag;
|
||||
STRIDE_ARRAY(ac->Raw.EdgeFlag, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.EdgeFlag = ac->Fallback.EdgeFlag;
|
||||
|
||||
ac->IsCached.EdgeFlag = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_EDGEFLAG;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \param index the generic vertex array number.
|
||||
*/
|
||||
static void
|
||||
reset_attrib( GLcontext *ctx, GLuint index )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->VertexAttrib[index].Enabled) {
|
||||
ac->Raw.Attrib[index] = ctx->Array.ArrayObj->VertexAttrib[index];
|
||||
STRIDE_ARRAY(ac->Raw.Attrib[index], ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.Attrib[index] = ac->Fallback.Attrib[index];
|
||||
|
||||
ac->IsCached.Attrib[index] = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_ATTRIB(index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generic import function for color data
|
||||
*/
|
||||
static void
|
||||
import( const GLcontext *ctx,
|
||||
GLenum destType,
|
||||
struct gl_client_array *to,
|
||||
const struct gl_client_array *from )
|
||||
{
|
||||
const ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (destType == 0)
|
||||
destType = from->Type;
|
||||
|
||||
switch (destType) {
|
||||
case GL_FLOAT:
|
||||
_math_trans_4fn( (GLfloat (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = 4 * sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
break;
|
||||
|
||||
case GL_UNSIGNED_BYTE:
|
||||
_math_trans_4ub( (GLubyte (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = 4 * sizeof(GLubyte);
|
||||
to->Type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case GL_UNSIGNED_SHORT:
|
||||
_math_trans_4us( (GLushort (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = 4 * sizeof(GLushort);
|
||||
to->Type = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
|
||||
default:
|
||||
_mesa_problem(ctx, "Unexpected dest format in import()");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Functions to import array ranges with specified types and strides.
|
||||
* For example, if the vertex data is GLshort[2] and we want GLfloat[3]
|
||||
* we'll use an import function to do the data conversion.
|
||||
*/
|
||||
|
||||
static void
|
||||
import_texcoord( GLcontext *ctx, GLuint unit, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.TexCoord[unit];
|
||||
struct gl_client_array *to = &ac->Cache.TexCoord[unit];
|
||||
(void) type; (void) stride;
|
||||
|
||||
ASSERT(unit < ctx->Const.MaxTextureCoordUnits);
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
|
||||
ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize);
|
||||
|
||||
_math_trans_4f( (GLfloat (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->Size = from->Size;
|
||||
to->StrideB = 4 * sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.TexCoord[unit] = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_vertex( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Vertex;
|
||||
struct gl_client_array *to = &ac->Cache.Vertex;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
|
||||
|
||||
_math_trans_4f( (GLfloat (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->Size = from->Size;
|
||||
to->StrideB = 4 * sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.Vertex = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_normal( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Normal;
|
||||
struct gl_client_array *to = &ac->Cache.Normal;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == 3*sizeof(GLfloat) || stride == 0);
|
||||
|
||||
_math_trans_3fn((GLfloat (*)[3]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = 3 * sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.Normal = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_color( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Color;
|
||||
struct gl_client_array *to = &ac->Cache.Color;
|
||||
(void) stride;
|
||||
|
||||
import( ctx, type, to, from );
|
||||
|
||||
ac->IsCached.Color = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_index( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Index;
|
||||
struct gl_client_array *to = &ac->Cache.Index;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_UNSIGNED_INT);
|
||||
ASSERT(stride == sizeof(GLuint) || stride == 0);
|
||||
|
||||
_math_trans_1ui( (GLuint *) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = sizeof(GLuint);
|
||||
to->Type = GL_UNSIGNED_INT;
|
||||
ac->IsCached.Index = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_secondarycolor( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.SecondaryColor;
|
||||
struct gl_client_array *to = &ac->Cache.SecondaryColor;
|
||||
(void) stride;
|
||||
|
||||
import( ctx, type, to, from );
|
||||
|
||||
ac->IsCached.SecondaryColor = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_fogcoord( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.FogCoord;
|
||||
struct gl_client_array *to = &ac->Cache.FogCoord;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == sizeof(GLfloat) || stride == 0);
|
||||
|
||||
_math_trans_1f( (GLfloat *) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.FogCoord = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_edgeflag( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.EdgeFlag;
|
||||
struct gl_client_array *to = &ac->Cache.EdgeFlag;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_UNSIGNED_BYTE);
|
||||
ASSERT(stride == sizeof(GLubyte) || stride == 0);
|
||||
|
||||
_math_trans_1ub( (GLubyte *) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = sizeof(GLubyte);
|
||||
to->Type = GL_UNSIGNED_BYTE;
|
||||
ac->IsCached.EdgeFlag = GL_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* \param index the generic vertex array number
|
||||
*/
|
||||
static void
|
||||
import_attrib( GLcontext *ctx, GLuint index, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Attrib[index];
|
||||
struct gl_client_array *to = &ac->Cache.Attrib[index];
|
||||
(void) type; (void) stride;
|
||||
|
||||
ASSERT(index < MAX_VERTEX_PROGRAM_ATTRIBS);
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
|
||||
ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize);
|
||||
|
||||
if (from->Normalized) {
|
||||
_math_trans_4fn( (GLfloat (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
}
|
||||
else {
|
||||
_math_trans_4f( (GLfloat (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
}
|
||||
|
||||
to->Size = from->Size;
|
||||
to->StrideB = 4 * sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.Attrib[index] = GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Externals to request arrays with specific properties:
|
||||
*/
|
||||
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_texcoord( GLcontext *ctx,
|
||||
GLuint unit,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
ASSERT(unit < MAX_TEXTURE_COORD_UNITS);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_TEXCOORD(unit))
|
||||
reset_texcoord( ctx, unit );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.TexCoord[unit].Size > (GLint) reqsize)
|
||||
return NULL;
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.TexCoord[unit].Type != type ||
|
||||
(reqstride != 0 && ac->Raw.TexCoord[unit].StrideB != (GLint)reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.TexCoord[unit])
|
||||
import_texcoord(ctx, unit, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.TexCoord[unit];
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.TexCoord[unit];
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_vertex( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_VERTEX)
|
||||
reset_vertex( ctx );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.Vertex.Size > (GLint) reqsize)
|
||||
return NULL;
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.Vertex.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.Vertex.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Vertex)
|
||||
import_vertex(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Vertex;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Vertex;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_normal( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_NORMAL)
|
||||
reset_normal( ctx );
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.Normal.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.Normal.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Normal)
|
||||
import_normal(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Normal;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_color( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_COLOR0)
|
||||
reset_color( ctx );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.Color.Size > (GLint) reqsize) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if ((type != 0 && ac->Raw.Color.Type != type) ||
|
||||
(reqstride != 0 && ac->Raw.Color.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Color) {
|
||||
import_color(ctx, type, reqstride );
|
||||
}
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Color;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Color;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_index( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_INDEX)
|
||||
reset_index( ctx );
|
||||
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.Index.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.Index.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Index)
|
||||
import_index(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Index;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Index;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_secondarycolor( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_COLOR1)
|
||||
reset_secondarycolor( ctx );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.SecondaryColor.Size > (GLint) reqsize)
|
||||
return NULL;
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if ((type != 0 && ac->Raw.SecondaryColor.Type != type) ||
|
||||
(reqstride != 0 && ac->Raw.SecondaryColor.StrideB != (GLint)reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.SecondaryColor)
|
||||
import_secondarycolor(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.SecondaryColor;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.SecondaryColor;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_fogcoord( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_FOGCOORD)
|
||||
reset_fogcoord( ctx );
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.FogCoord.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.FogCoord.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.FogCoord)
|
||||
import_fogcoord(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.FogCoord;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.FogCoord;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_edgeflag( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_EDGEFLAG)
|
||||
reset_edgeflag( ctx );
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.EdgeFlag.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.EdgeFlag.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.EdgeFlag)
|
||||
import_edgeflag(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.EdgeFlag;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.EdgeFlag;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For GL_ARB/NV_vertex_program
|
||||
* \param index index of the vertex array, starting at zero.
|
||||
*/
|
||||
struct gl_client_array *
|
||||
_ac_import_attrib( GLcontext *ctx,
|
||||
GLuint index,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
ASSERT(index < VERT_ATTRIB_MAX);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index))
|
||||
reset_attrib( ctx, index );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.Attrib[index].Size > (GLint) reqsize)
|
||||
return NULL;
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.Attrib[index].Type != type ||
|
||||
(reqstride != 0 && ac->Raw.Attrib[index].StrideB != (GLint)reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Attrib[index])
|
||||
import_attrib(ctx, index, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Attrib[index];
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Attrib[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Clients must call this function to validate state and set bounds
|
||||
* before importing any data:
|
||||
*/
|
||||
void
|
||||
_ac_import_range( GLcontext *ctx, GLuint start, GLuint count )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (!ctx->Array.LockCount) {
|
||||
/* Not locked, discard cached data. Changes to lock
|
||||
* status are caught via. _ac_invalidate_state().
|
||||
*/
|
||||
ac->NewArrayState = _NEW_ARRAY_ALL;
|
||||
ac->start = start;
|
||||
ac->count = count;
|
||||
}
|
||||
else {
|
||||
/* Locked, discard data for any disabled arrays. Require that
|
||||
* the whole locked range always be dealt with, otherwise hard to
|
||||
* maintain cached data in the face of clipping.
|
||||
*/
|
||||
ac->NewArrayState |= ~ctx->Array.ArrayObj->_Enabled;
|
||||
ac->start = ctx->Array.LockFirst;
|
||||
ac->count = ctx->Array.LockCount;
|
||||
ASSERT(ac->start == start); /* hmm? */
|
||||
ASSERT(ac->count == count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Additional convienence function for importing the element list
|
||||
* for glDrawElements() and glDrawRangeElements().
|
||||
*/
|
||||
CONST void *
|
||||
_ac_import_elements( GLcontext *ctx,
|
||||
GLenum new_type,
|
||||
GLuint count,
|
||||
GLenum old_type,
|
||||
CONST void *indices )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (old_type == new_type)
|
||||
return indices;
|
||||
|
||||
if (ac->elt_size < count * sizeof(GLuint)) {
|
||||
if (ac->Elts) FREE(ac->Elts);
|
||||
while (ac->elt_size < count * sizeof(GLuint))
|
||||
ac->elt_size *= 2;
|
||||
ac->Elts = (GLuint *) MALLOC(ac->elt_size);
|
||||
}
|
||||
|
||||
switch (new_type) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
case GL_UNSIGNED_INT: {
|
||||
GLuint *out = (GLuint *)ac->Elts;
|
||||
GLuint i;
|
||||
|
||||
switch (old_type) {
|
||||
case GL_UNSIGNED_BYTE: {
|
||||
CONST GLubyte *in = (CONST GLubyte *)indices;
|
||||
for (i = 0 ; i < count ; i++)
|
||||
out[i] = in[i];
|
||||
break;
|
||||
}
|
||||
case GL_UNSIGNED_SHORT: {
|
||||
CONST GLushort *in = (CONST GLushort *)indices;
|
||||
for (i = 0 ; i < count ; i++)
|
||||
out[i] = in[i];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return (CONST void *)out;
|
||||
}
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.1
|
||||
*
|
||||
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef _ARRAYCACHE_H
|
||||
#define _ARRAYCACHE_H
|
||||
|
||||
#include "mtypes.h"
|
||||
|
||||
|
||||
extern GLboolean
|
||||
_ac_CreateContext( GLcontext *ctx );
|
||||
|
||||
extern void
|
||||
_ac_DestroyContext( GLcontext *ctx );
|
||||
|
||||
extern void
|
||||
_ac_InvalidateState( GLcontext *ctx, GLuint new_state );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_vertex( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_normal( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_color( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_index( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_secondarycolor( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_fogcoord( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_edgeflag( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_texcoord( GLcontext *ctx,
|
||||
GLuint unit,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_attrib( GLcontext *ctx,
|
||||
GLuint index,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
|
||||
/* Clients must call this function to validate state and set bounds
|
||||
* before importing any data:
|
||||
*/
|
||||
extern void
|
||||
_ac_import_range( GLcontext *ctx, GLuint start, GLuint count );
|
||||
|
||||
|
||||
/* Additional convenience function:
|
||||
*/
|
||||
extern CONST void *
|
||||
_ac_import_elements( GLcontext *ctx,
|
||||
GLenum new_type,
|
||||
GLuint count,
|
||||
GLenum old_type,
|
||||
CONST void *indices );
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -28,8 +28,9 @@
|
||||
#include "buffers.h"
|
||||
#include "context.h"
|
||||
#include "framebuffer.h"
|
||||
#include "occlude.h"
|
||||
#include "program.h"
|
||||
#include "prog_execute.h"
|
||||
#include "queryobj.h"
|
||||
#include "renderbuffer.h"
|
||||
#include "texcompress.h"
|
||||
#include "texformat.h"
|
||||
@@ -43,6 +44,7 @@
|
||||
#include "fbobject.h"
|
||||
#include "texrender.h"
|
||||
#endif
|
||||
#include "shader_api.h"
|
||||
#include "arrayobj.h"
|
||||
|
||||
#include "driverfuncs.h"
|
||||
@@ -127,7 +129,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
|
||||
driver->NewProgram = _mesa_new_program;
|
||||
driver->DeleteProgram = _mesa_delete_program;
|
||||
#if FEATURE_MESA_program_debug
|
||||
driver->GetFragmentProgramRegister = _swrast_get_program_register;
|
||||
driver->GetProgramRegister = _mesa_get_program_register;
|
||||
#endif /* FEATURE_MESA_program_debug */
|
||||
|
||||
/* simple state commands */
|
||||
@@ -248,4 +250,45 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
|
||||
driver->EndList = NULL;
|
||||
driver->BeginCallList = NULL;
|
||||
driver->EndCallList = NULL;
|
||||
|
||||
|
||||
/* XXX temporary here */
|
||||
_mesa_init_glsl_driver_functions(driver);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Plug in Mesa's GLSL functions.
|
||||
*/
|
||||
void
|
||||
_mesa_init_glsl_driver_functions(struct dd_function_table *driver)
|
||||
{
|
||||
driver->AttachShader = _mesa_attach_shader;
|
||||
driver->BindAttribLocation = _mesa_bind_attrib_location;
|
||||
driver->CompileShader = _mesa_compile_shader;
|
||||
driver->CreateProgram = _mesa_create_program;
|
||||
driver->CreateShader = _mesa_create_shader;
|
||||
driver->DeleteProgram2 = _mesa_delete_program2;
|
||||
driver->DeleteShader = _mesa_delete_shader;
|
||||
driver->DetachShader = _mesa_detach_shader;
|
||||
driver->GetActiveAttrib = _mesa_get_active_attrib;
|
||||
driver->GetActiveUniform = _mesa_get_active_uniform;
|
||||
driver->GetAttachedShaders = _mesa_get_attached_shaders;
|
||||
driver->GetAttribLocation = _mesa_get_attrib_location;
|
||||
driver->GetHandle = _mesa_get_handle;
|
||||
driver->GetProgramiv = _mesa_get_programiv;
|
||||
driver->GetProgramInfoLog = _mesa_get_program_info_log;
|
||||
driver->GetShaderiv = _mesa_get_shaderiv;
|
||||
driver->GetShaderInfoLog = _mesa_get_shader_info_log;
|
||||
driver->GetShaderSource = _mesa_get_shader_source;
|
||||
driver->GetUniformfv = _mesa_get_uniformfv;
|
||||
driver->GetUniformLocation = _mesa_get_uniform_location;
|
||||
driver->IsProgram = _mesa_is_program;
|
||||
driver->IsShader = _mesa_is_shader;
|
||||
driver->LinkProgram = _mesa_link_program;
|
||||
driver->ShaderSource = _mesa_shader_source;
|
||||
driver->Uniform = _mesa_uniform;
|
||||
driver->UniformMatrix = _mesa_uniform_matrix;
|
||||
driver->UseProgram = _mesa_use_program;
|
||||
driver->ValidateProgram = _mesa_validate_program;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.1
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -29,4 +29,8 @@
|
||||
extern void
|
||||
_mesa_init_driver_functions(struct dd_function_table *driver);
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_init_glsl_driver_functions(struct dd_function_table *driver);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -240,6 +240,7 @@ _glapi_check_multithread(void)
|
||||
else if (knownID != _glthread_GetID()) {
|
||||
ThreadSafe = GL_TRUE;
|
||||
_glapi_set_dispatch(NULL);
|
||||
_glapi_set_context(NULL);
|
||||
}
|
||||
}
|
||||
else if (!_glapi_get_dispatch()) {
|
||||
@@ -1003,7 +1004,6 @@ _glapi_check_table(const struct _glapi_table *table)
|
||||
GLuint offset = (secondaryColor3fFunc - (char *) table) / sizeof(void *);
|
||||
assert(secondaryColor3fOffset == _gloffset_SecondaryColor3fEXT);
|
||||
assert(secondaryColor3fOffset == offset);
|
||||
assert(_glapi_get_proc_address("glSecondaryColor3fEXT") == (_glapi_proc) &glSecondaryColor3fEXT);
|
||||
}
|
||||
{
|
||||
GLuint pointParameterivOffset = _glapi_get_proc_offset("glPointParameterivNV");
|
||||
@@ -1011,7 +1011,6 @@ _glapi_check_table(const struct _glapi_table *table)
|
||||
GLuint offset = (pointParameterivFunc - (char *) table) / sizeof(void *);
|
||||
assert(pointParameterivOffset == _gloffset_PointParameterivNV);
|
||||
assert(pointParameterivOffset == offset);
|
||||
assert(_glapi_get_proc_address("glPointParameterivNV") == (_glapi_proc) &glPointParameterivNV);
|
||||
}
|
||||
{
|
||||
GLuint setFenceOffset = _glapi_get_proc_offset("glSetFenceNV");
|
||||
|
||||
@@ -30,7 +30,11 @@
|
||||
# define _GLAPI_TABLE_H_
|
||||
|
||||
#ifndef GLAPIENTRYP
|
||||
#define GLAPIENTRYP
|
||||
# ifndef GLAPIENTRY
|
||||
# define GLAPIENTRY
|
||||
# endif
|
||||
|
||||
# define GLAPIENTRYP GLAPIENTRY *
|
||||
#endif
|
||||
|
||||
typedef void (*_glapi_proc)(void); /* generic function pointer */
|
||||
@@ -704,7 +708,7 @@ struct _glapi_table
|
||||
void (GLAPIENTRYP GetProgramStringNV)(GLuint id, GLenum pname, GLubyte * program); /* 664 */
|
||||
void (GLAPIENTRYP GetProgramivNV)(GLuint id, GLenum pname, GLint * params); /* 665 */
|
||||
void (GLAPIENTRYP GetTrackMatrixivNV)(GLenum target, GLuint address, GLenum pname, GLint * params); /* 666 */
|
||||
void (GLAPIENTRYP GetVertexAttribPointervNV)(GLuint index, GLenum pname, GLvoid ** params); /* 667 */
|
||||
void (GLAPIENTRYP GetVertexAttribPointervNV)(GLuint index, GLenum pname, GLvoid ** pointer); /* 667 */
|
||||
void (GLAPIENTRYP GetVertexAttribdvNV)(GLuint index, GLenum pname, GLdouble * params); /* 668 */
|
||||
void (GLAPIENTRYP GetVertexAttribfvNV)(GLuint index, GLenum pname, GLfloat * params); /* 669 */
|
||||
void (GLAPIENTRYP GetVertexAttribivNV)(GLuint index, GLenum pname, GLint * params); /* 670 */
|
||||
|
||||
@@ -4865,14 +4865,19 @@ KEYWORD1 void KEYWORD2 NAME(GetTrackMatrixivNV)(GLenum target, GLuint address, G
|
||||
DISPATCH(GetTrackMatrixivNV, (target, address, pname, params), (F, "glGetTrackMatrixivNV(0x%x, %d, 0x%x, %p);\n", target, address, pname, (const void *) params));
|
||||
}
|
||||
|
||||
KEYWORD1 void KEYWORD2 NAME(GetVertexAttribPointervARB)(GLuint index, GLenum pname, GLvoid ** params)
|
||||
KEYWORD1 void KEYWORD2 NAME(GetVertexAttribPointerv)(GLuint index, GLenum pname, GLvoid ** pointer)
|
||||
{
|
||||
DISPATCH(GetVertexAttribPointervNV, (index, pname, params), (F, "glGetVertexAttribPointervARB(%d, 0x%x, %p);\n", index, pname, (const void *) params));
|
||||
DISPATCH(GetVertexAttribPointervNV, (index, pname, pointer), (F, "glGetVertexAttribPointerv(%d, 0x%x, %p);\n", index, pname, (const void *) pointer));
|
||||
}
|
||||
|
||||
KEYWORD1 void KEYWORD2 NAME(GetVertexAttribPointervNV)(GLuint index, GLenum pname, GLvoid ** params)
|
||||
KEYWORD1 void KEYWORD2 NAME(GetVertexAttribPointervARB)(GLuint index, GLenum pname, GLvoid ** pointer)
|
||||
{
|
||||
DISPATCH(GetVertexAttribPointervNV, (index, pname, params), (F, "glGetVertexAttribPointervNV(%d, 0x%x, %p);\n", index, pname, (const void *) params));
|
||||
DISPATCH(GetVertexAttribPointervNV, (index, pname, pointer), (F, "glGetVertexAttribPointervARB(%d, 0x%x, %p);\n", index, pname, (const void *) pointer));
|
||||
}
|
||||
|
||||
KEYWORD1 void KEYWORD2 NAME(GetVertexAttribPointervNV)(GLuint index, GLenum pname, GLvoid ** pointer)
|
||||
{
|
||||
DISPATCH(GetVertexAttribPointervNV, (index, pname, pointer), (F, "glGetVertexAttribPointervNV(%d, 0x%x, %p);\n", index, pname, (const void *) pointer));
|
||||
}
|
||||
|
||||
KEYWORD1 void KEYWORD2 NAME(GetVertexAttribdvNV)(GLuint index, GLenum pname, GLdouble * params)
|
||||
@@ -6577,6 +6582,7 @@ static _glapi_proc UNUSED_TABLE_NAME[] = {
|
||||
TABLE_ENTRY(BindProgramARB),
|
||||
TABLE_ENTRY(DeleteProgramsARB),
|
||||
TABLE_ENTRY(GenProgramsARB),
|
||||
TABLE_ENTRY(GetVertexAttribPointerv),
|
||||
TABLE_ENTRY(GetVertexAttribPointervARB),
|
||||
TABLE_ENTRY(IsProgramARB),
|
||||
TABLE_ENTRY(PointParameteri),
|
||||
|
||||
@@ -1086,6 +1086,7 @@ static const char gl_string_table[] =
|
||||
"glBindProgramARB\0"
|
||||
"glDeleteProgramsARB\0"
|
||||
"glGenProgramsARB\0"
|
||||
"glGetVertexAttribPointerv\0"
|
||||
"glGetVertexAttribPointervARB\0"
|
||||
"glIsProgramARB\0"
|
||||
"glPointParameteri\0"
|
||||
@@ -2229,11 +2230,12 @@ static const glprocs_table_t static_functions[] = {
|
||||
NAME_FUNC_OFFSET(18432, glDeleteProgramsNV, glDeleteProgramsNV, NULL, _gloffset_DeleteProgramsNV),
|
||||
NAME_FUNC_OFFSET(18452, glGenProgramsNV, glGenProgramsNV, NULL, _gloffset_GenProgramsNV),
|
||||
NAME_FUNC_OFFSET(18469, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
|
||||
NAME_FUNC_OFFSET(18498, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV),
|
||||
NAME_FUNC_OFFSET(18513, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV),
|
||||
NAME_FUNC_OFFSET(18531, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV),
|
||||
NAME_FUNC_OFFSET(18550, gl_dispatch_stub_749, gl_dispatch_stub_749, NULL, _gloffset_BlendEquationSeparateEXT),
|
||||
NAME_FUNC_OFFSET(18574, gl_dispatch_stub_749, gl_dispatch_stub_749, NULL, _gloffset_BlendEquationSeparateEXT),
|
||||
NAME_FUNC_OFFSET(18495, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
|
||||
NAME_FUNC_OFFSET(18524, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV),
|
||||
NAME_FUNC_OFFSET(18539, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV),
|
||||
NAME_FUNC_OFFSET(18557, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV),
|
||||
NAME_FUNC_OFFSET(18576, gl_dispatch_stub_749, gl_dispatch_stub_749, NULL, _gloffset_BlendEquationSeparateEXT),
|
||||
NAME_FUNC_OFFSET(18600, gl_dispatch_stub_749, gl_dispatch_stub_749, NULL, _gloffset_BlendEquationSeparateEXT),
|
||||
NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)
|
||||
};
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ static void GLAPIENTRY
|
||||
loopback_Color3iv_f( const GLint *v )
|
||||
{
|
||||
COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]),
|
||||
INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]) );
|
||||
INT_TO_FLOAT(v[2]), 1.0 );
|
||||
}
|
||||
|
||||
static void GLAPIENTRY
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
static void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Current.EdgeFlag = b;
|
||||
ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] = (GLfloat)b;
|
||||
}
|
||||
|
||||
static void GLAPIENTRY _mesa_noop_Indexf( GLfloat f )
|
||||
|
||||
@@ -114,40 +114,34 @@ _mesa_initialize_array_object( GLcontext *ctx,
|
||||
obj->Vertex.StrideB = 0;
|
||||
obj->Vertex.Ptr = NULL;
|
||||
obj->Vertex.Enabled = GL_FALSE;
|
||||
obj->Vertex.Flags = CA_CLIENT_DATA;
|
||||
obj->Normal.Type = GL_FLOAT;
|
||||
obj->Normal.Stride = 0;
|
||||
obj->Normal.StrideB = 0;
|
||||
obj->Normal.Ptr = NULL;
|
||||
obj->Normal.Enabled = GL_FALSE;
|
||||
obj->Normal.Flags = CA_CLIENT_DATA;
|
||||
obj->Color.Size = 4;
|
||||
obj->Color.Type = GL_FLOAT;
|
||||
obj->Color.Stride = 0;
|
||||
obj->Color.StrideB = 0;
|
||||
obj->Color.Ptr = NULL;
|
||||
obj->Color.Enabled = GL_FALSE;
|
||||
obj->Color.Flags = CA_CLIENT_DATA;
|
||||
obj->SecondaryColor.Size = 4;
|
||||
obj->SecondaryColor.Type = GL_FLOAT;
|
||||
obj->SecondaryColor.Stride = 0;
|
||||
obj->SecondaryColor.StrideB = 0;
|
||||
obj->SecondaryColor.Ptr = NULL;
|
||||
obj->SecondaryColor.Enabled = GL_FALSE;
|
||||
obj->SecondaryColor.Flags = CA_CLIENT_DATA;
|
||||
obj->FogCoord.Size = 1;
|
||||
obj->FogCoord.Type = GL_FLOAT;
|
||||
obj->FogCoord.Stride = 0;
|
||||
obj->FogCoord.StrideB = 0;
|
||||
obj->FogCoord.Ptr = NULL;
|
||||
obj->FogCoord.Enabled = GL_FALSE;
|
||||
obj->FogCoord.Flags = CA_CLIENT_DATA;
|
||||
obj->Index.Type = GL_FLOAT;
|
||||
obj->Index.Stride = 0;
|
||||
obj->Index.StrideB = 0;
|
||||
obj->Index.Ptr = NULL;
|
||||
obj->Index.Enabled = GL_FALSE;
|
||||
obj->Index.Flags = CA_CLIENT_DATA;
|
||||
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
|
||||
obj->TexCoord[i].Size = 4;
|
||||
obj->TexCoord[i].Type = GL_FLOAT;
|
||||
@@ -155,13 +149,11 @@ _mesa_initialize_array_object( GLcontext *ctx,
|
||||
obj->TexCoord[i].StrideB = 0;
|
||||
obj->TexCoord[i].Ptr = NULL;
|
||||
obj->TexCoord[i].Enabled = GL_FALSE;
|
||||
obj->TexCoord[i].Flags = CA_CLIENT_DATA;
|
||||
}
|
||||
obj->EdgeFlag.Stride = 0;
|
||||
obj->EdgeFlag.StrideB = 0;
|
||||
obj->EdgeFlag.Ptr = NULL;
|
||||
obj->EdgeFlag.Enabled = GL_FALSE;
|
||||
obj->EdgeFlag.Flags = CA_CLIENT_DATA;
|
||||
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
|
||||
obj->VertexAttrib[i].Size = 4;
|
||||
obj->VertexAttrib[i].Type = GL_FLOAT;
|
||||
@@ -170,7 +162,6 @@ _mesa_initialize_array_object( GLcontext *ctx,
|
||||
obj->VertexAttrib[i].Ptr = NULL;
|
||||
obj->VertexAttrib[i].Enabled = GL_FALSE;
|
||||
obj->VertexAttrib[i].Normalized = GL_FALSE;
|
||||
obj->VertexAttrib[i].Flags = CA_CLIENT_DATA;
|
||||
}
|
||||
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -138,9 +138,9 @@ _mesa_PushAttrib(GLbitfield mask)
|
||||
attr->Blend = ctx->Color.BlendEnabled;
|
||||
attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled;
|
||||
attr->ColorMaterial = ctx->Light.ColorMaterialEnabled;
|
||||
attr->ColorTable = ctx->Pixel.ColorTableEnabled;
|
||||
attr->PostColorMatrixColorTable = ctx->Pixel.PostColorMatrixColorTableEnabled;
|
||||
attr->PostConvolutionColorTable = ctx->Pixel.PostConvolutionColorTableEnabled;
|
||||
for (i = 0; i < COLORTABLE_MAX; i++) {
|
||||
attr->ColorTable[i] = ctx->Pixel.ColorTableEnabled[i];
|
||||
}
|
||||
attr->Convolution1D = ctx->Pixel.Convolution1DEnabled;
|
||||
attr->Convolution2D = ctx->Pixel.Convolution2DEnabled;
|
||||
attr->Separable2D = ctx->Pixel.Separable2DEnabled;
|
||||
@@ -432,14 +432,15 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
|
||||
|
||||
TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial,
|
||||
GL_COLOR_MATERIAL);
|
||||
TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled, enable->ColorTable,
|
||||
TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION],
|
||||
enable->ColorTable[COLORTABLE_PRECONVOLUTION],
|
||||
GL_COLOR_TABLE);
|
||||
TEST_AND_UPDATE(ctx->Pixel.PostColorMatrixColorTableEnabled,
|
||||
enable->PostColorMatrixColorTable,
|
||||
GL_POST_COLOR_MATRIX_COLOR_TABLE);
|
||||
TEST_AND_UPDATE(ctx->Pixel.PostConvolutionColorTableEnabled,
|
||||
enable->PostConvolutionColorTable,
|
||||
TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION],
|
||||
enable->ColorTable[COLORTABLE_POSTCONVOLUTION],
|
||||
GL_POST_CONVOLUTION_COLOR_TABLE);
|
||||
TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX],
|
||||
enable->ColorTable[COLORTABLE_POSTCOLORMATRIX],
|
||||
GL_POST_COLOR_MATRIX_COLOR_TABLE);
|
||||
TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE);
|
||||
TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST);
|
||||
TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER);
|
||||
@@ -764,6 +765,7 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
|
||||
_mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod);
|
||||
_mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod);
|
||||
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel);
|
||||
if (target != GL_TEXTURE_RECTANGLE_ARB)
|
||||
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel);
|
||||
if (ctx->Extensions.EXT_texture_filter_anisotropic) {
|
||||
_mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT,
|
||||
@@ -1285,6 +1287,12 @@ _mesa_PushClientAttrib(GLbitfield mask)
|
||||
attr = MALLOC_STRUCT( gl_array_attrib );
|
||||
obj = MALLOC_STRUCT( gl_array_object );
|
||||
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
/* increment ref counts since we're copying pointers to these objects */
|
||||
ctx->Array.ArrayBufferObj->RefCount++;
|
||||
ctx->Array.ElementArrayBufferObj->RefCount++;
|
||||
#endif
|
||||
|
||||
MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
|
||||
MEMCPY( obj, ctx->Array.ArrayObj, sizeof(struct gl_array_object) );
|
||||
|
||||
@@ -1359,6 +1367,13 @@ _mesa_PopClientAttrib(void)
|
||||
|
||||
_mesa_BindVertexArrayAPPLE( data->ArrayObj->Name );
|
||||
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
_mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB,
|
||||
data->ArrayBufferObj->Name);
|
||||
_mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
|
||||
data->ElementArrayBufferObj->Name);
|
||||
#endif
|
||||
|
||||
MEMCPY( ctx->Array.ArrayObj, data->ArrayObj,
|
||||
sizeof( struct gl_array_object ) );
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ buffer_object_subdata_range_good( GLcontext * ctx, GLenum target,
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
|
||||
return NULL;
|
||||
}
|
||||
if ((GLuint) (offset + size) > bufObj->Size) {
|
||||
if (offset + size > bufObj->Size) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||
"%s(size + offset > buffer size)", caller);
|
||||
return NULL;
|
||||
@@ -297,7 +297,7 @@ _mesa_buffer_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
|
||||
(void) ctx; (void) target;
|
||||
|
||||
/* this should have been caught in _mesa_BufferSubData() */
|
||||
ASSERT((GLuint) (size + offset) <= bufObj->Size);
|
||||
ASSERT(size + offset <= bufObj->Size);
|
||||
|
||||
if (bufObj->Data) {
|
||||
_mesa_memcpy( (GLubyte *) bufObj->Data + offset, data, size );
|
||||
|
||||
@@ -140,6 +140,9 @@ _mesa_Clear( GLbitfield mask )
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0)
|
||||
return;
|
||||
|
||||
if (ctx->RenderMode == GL_RENDER) {
|
||||
GLbitfield bufferMask;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -291,15 +291,17 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
||||
GLsizei width, GLenum format, GLenum type,
|
||||
const GLvoid *data )
|
||||
{
|
||||
static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 };
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||
struct gl_texture_object *texObj = NULL;
|
||||
struct gl_color_table *table = NULL;
|
||||
GLboolean proxy = GL_FALSE;
|
||||
GLint baseFormat;
|
||||
GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
|
||||
GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
|
||||
const GLfloat *scale = one, *bias = zero;
|
||||
GLint comps;
|
||||
|
||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */
|
||||
|
||||
switch (target) {
|
||||
@@ -350,18 +352,12 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
||||
table = &ctx->Texture.Palette;
|
||||
break;
|
||||
case GL_COLOR_TABLE:
|
||||
table = &ctx->ColorTable;
|
||||
rScale = ctx->Pixel.ColorTableScale[0];
|
||||
gScale = ctx->Pixel.ColorTableScale[1];
|
||||
bScale = ctx->Pixel.ColorTableScale[2];
|
||||
aScale = ctx->Pixel.ColorTableScale[3];
|
||||
rBias = ctx->Pixel.ColorTableBias[0];
|
||||
gBias = ctx->Pixel.ColorTableBias[1];
|
||||
bBias = ctx->Pixel.ColorTableBias[2];
|
||||
aBias = ctx->Pixel.ColorTableBias[3];
|
||||
table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
|
||||
scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION];
|
||||
bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION];
|
||||
break;
|
||||
case GL_PROXY_COLOR_TABLE:
|
||||
table = &ctx->ProxyColorTable;
|
||||
table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION];
|
||||
proxy = GL_TRUE;
|
||||
break;
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
@@ -370,14 +366,8 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
||||
return;
|
||||
}
|
||||
table = &(texUnit->ColorTable);
|
||||
rScale = ctx->Pixel.TextureColorTableScale[0];
|
||||
gScale = ctx->Pixel.TextureColorTableScale[1];
|
||||
bScale = ctx->Pixel.TextureColorTableScale[2];
|
||||
aScale = ctx->Pixel.TextureColorTableScale[3];
|
||||
rBias = ctx->Pixel.TextureColorTableBias[0];
|
||||
gBias = ctx->Pixel.TextureColorTableBias[1];
|
||||
bBias = ctx->Pixel.TextureColorTableBias[2];
|
||||
aBias = ctx->Pixel.TextureColorTableBias[3];
|
||||
scale = ctx->Pixel.TextureColorTableScale;
|
||||
bias = ctx->Pixel.TextureColorTableBias;
|
||||
break;
|
||||
case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
|
||||
if (!ctx->Extensions.SGI_texture_color_table) {
|
||||
@@ -388,33 +378,21 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
||||
proxy = GL_TRUE;
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE:
|
||||
table = &ctx->PostConvolutionColorTable;
|
||||
rScale = ctx->Pixel.PCCTscale[0];
|
||||
gScale = ctx->Pixel.PCCTscale[1];
|
||||
bScale = ctx->Pixel.PCCTscale[2];
|
||||
aScale = ctx->Pixel.PCCTscale[3];
|
||||
rBias = ctx->Pixel.PCCTbias[0];
|
||||
gBias = ctx->Pixel.PCCTbias[1];
|
||||
bBias = ctx->Pixel.PCCTbias[2];
|
||||
aBias = ctx->Pixel.PCCTbias[3];
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
|
||||
scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION];
|
||||
bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION];
|
||||
break;
|
||||
case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
|
||||
table = &ctx->ProxyPostConvolutionColorTable;
|
||||
table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION];
|
||||
proxy = GL_TRUE;
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE:
|
||||
table = &ctx->PostColorMatrixColorTable;
|
||||
rScale = ctx->Pixel.PCMCTscale[0];
|
||||
gScale = ctx->Pixel.PCMCTscale[1];
|
||||
bScale = ctx->Pixel.PCMCTscale[2];
|
||||
aScale = ctx->Pixel.PCMCTscale[3];
|
||||
rBias = ctx->Pixel.PCMCTbias[0];
|
||||
gBias = ctx->Pixel.PCMCTbias[1];
|
||||
bBias = ctx->Pixel.PCMCTbias[2];
|
||||
aBias = ctx->Pixel.PCMCTbias[3];
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
|
||||
scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
|
||||
bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX];
|
||||
break;
|
||||
case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
|
||||
table = &ctx->ProxyPostColorMatrixColorTable;
|
||||
table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
|
||||
proxy = GL_TRUE;
|
||||
break;
|
||||
default:
|
||||
@@ -472,8 +450,8 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
||||
_mesa_free_colortable_data(table);
|
||||
|
||||
if (width > 0) {
|
||||
table->TableF = _mesa_malloc(comps * width * sizeof(GLfloat));
|
||||
table->TableUB = _mesa_malloc(comps * width * sizeof(GLubyte));
|
||||
table->TableF = (GLfloat *) _mesa_malloc(comps * width * sizeof(GLfloat));
|
||||
table->TableUB = (GLubyte *) _mesa_malloc(comps * width * sizeof(GLubyte));
|
||||
|
||||
if (!table->TableF || !table->TableUB) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
|
||||
@@ -483,10 +461,10 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
|
||||
store_colortable_entries(ctx, table,
|
||||
0, width, /* start, count */
|
||||
format, type, data,
|
||||
rScale, rBias,
|
||||
gScale, gBias,
|
||||
bScale, bBias,
|
||||
aScale, aBias);
|
||||
scale[0], bias[0],
|
||||
scale[1], bias[1],
|
||||
scale[2], bias[2],
|
||||
scale[3], bias[3]);
|
||||
}
|
||||
} /* proxy */
|
||||
|
||||
@@ -510,12 +488,14 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
|
||||
GLsizei count, GLenum format, GLenum type,
|
||||
const GLvoid *data )
|
||||
{
|
||||
static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 };
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||
struct gl_texture_object *texObj = NULL;
|
||||
struct gl_color_table *table = NULL;
|
||||
GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
|
||||
GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
|
||||
const GLfloat *scale = one, *bias = zero;
|
||||
|
||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
||||
|
||||
switch (target) {
|
||||
@@ -543,15 +523,9 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
|
||||
table = &ctx->Texture.Palette;
|
||||
break;
|
||||
case GL_COLOR_TABLE:
|
||||
table = &ctx->ColorTable;
|
||||
rScale = ctx->Pixel.ColorTableScale[0];
|
||||
gScale = ctx->Pixel.ColorTableScale[1];
|
||||
bScale = ctx->Pixel.ColorTableScale[2];
|
||||
aScale = ctx->Pixel.ColorTableScale[3];
|
||||
rBias = ctx->Pixel.ColorTableBias[0];
|
||||
gBias = ctx->Pixel.ColorTableBias[1];
|
||||
bBias = ctx->Pixel.ColorTableBias[2];
|
||||
aBias = ctx->Pixel.ColorTableBias[3];
|
||||
table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
|
||||
scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION];
|
||||
bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION];
|
||||
break;
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
if (!ctx->Extensions.SGI_texture_color_table) {
|
||||
@@ -559,36 +533,18 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
|
||||
return;
|
||||
}
|
||||
table = &(texUnit->ColorTable);
|
||||
rScale = ctx->Pixel.TextureColorTableScale[0];
|
||||
gScale = ctx->Pixel.TextureColorTableScale[1];
|
||||
bScale = ctx->Pixel.TextureColorTableScale[2];
|
||||
aScale = ctx->Pixel.TextureColorTableScale[3];
|
||||
rBias = ctx->Pixel.TextureColorTableBias[0];
|
||||
gBias = ctx->Pixel.TextureColorTableBias[1];
|
||||
bBias = ctx->Pixel.TextureColorTableBias[2];
|
||||
aBias = ctx->Pixel.TextureColorTableBias[3];
|
||||
scale = ctx->Pixel.TextureColorTableScale;
|
||||
bias = ctx->Pixel.TextureColorTableBias;
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE:
|
||||
table = &ctx->PostConvolutionColorTable;
|
||||
rScale = ctx->Pixel.PCCTscale[0];
|
||||
gScale = ctx->Pixel.PCCTscale[1];
|
||||
bScale = ctx->Pixel.PCCTscale[2];
|
||||
aScale = ctx->Pixel.PCCTscale[3];
|
||||
rBias = ctx->Pixel.PCCTbias[0];
|
||||
gBias = ctx->Pixel.PCCTbias[1];
|
||||
bBias = ctx->Pixel.PCCTbias[2];
|
||||
aBias = ctx->Pixel.PCCTbias[3];
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
|
||||
scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION];
|
||||
bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION];
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE:
|
||||
table = &ctx->PostColorMatrixColorTable;
|
||||
rScale = ctx->Pixel.PCMCTscale[0];
|
||||
gScale = ctx->Pixel.PCMCTscale[1];
|
||||
bScale = ctx->Pixel.PCMCTscale[2];
|
||||
aScale = ctx->Pixel.PCMCTscale[3];
|
||||
rBias = ctx->Pixel.PCMCTbias[0];
|
||||
gBias = ctx->Pixel.PCMCTbias[1];
|
||||
bBias = ctx->Pixel.PCMCTbias[2];
|
||||
aBias = ctx->Pixel.PCMCTbias[3];
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
|
||||
scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
|
||||
bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX];
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
|
||||
@@ -623,10 +579,10 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
|
||||
|
||||
store_colortable_entries(ctx, table, start, count,
|
||||
format, type, data,
|
||||
rScale, rBias,
|
||||
gScale, gBias,
|
||||
bScale, bBias,
|
||||
aScale, aBias);
|
||||
scale[0], bias[0],
|
||||
scale[1], bias[1],
|
||||
scale[2], bias[2],
|
||||
scale[3], bias[3]);
|
||||
|
||||
if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) {
|
||||
/* per-texture object palette */
|
||||
@@ -700,7 +656,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
|
||||
table = &ctx->Texture.Palette;
|
||||
break;
|
||||
case GL_COLOR_TABLE:
|
||||
table = &ctx->ColorTable;
|
||||
table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
|
||||
break;
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
if (!ctx->Extensions.SGI_texture_color_table) {
|
||||
@@ -710,10 +666,10 @@ _mesa_GetColorTable( GLenum target, GLenum format,
|
||||
table = &(texUnit->ColorTable);
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE:
|
||||
table = &ctx->PostConvolutionColorTable;
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE:
|
||||
table = &ctx->PostColorMatrixColorTable;
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
|
||||
@@ -722,6 +678,10 @@ _mesa_GetColorTable( GLenum target, GLenum format,
|
||||
|
||||
ASSERT(table);
|
||||
|
||||
if (table->Size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (table->_BaseFormat) {
|
||||
case GL_ALPHA:
|
||||
{
|
||||
@@ -827,16 +787,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
|
||||
switch (target) {
|
||||
case GL_COLOR_TABLE_SGI:
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
ctx->Pixel.ColorTableScale[0] = params[0];
|
||||
ctx->Pixel.ColorTableScale[1] = params[1];
|
||||
ctx->Pixel.ColorTableScale[2] = params[2];
|
||||
ctx->Pixel.ColorTableScale[3] = params[3];
|
||||
COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION], params);
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
ctx->Pixel.ColorTableBias[0] = params[0];
|
||||
ctx->Pixel.ColorTableBias[1] = params[1];
|
||||
ctx->Pixel.ColorTableBias[2] = params[2];
|
||||
ctx->Pixel.ColorTableBias[3] = params[3];
|
||||
COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION], params);
|
||||
}
|
||||
else {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
|
||||
@@ -849,16 +803,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
|
||||
return;
|
||||
}
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
ctx->Pixel.TextureColorTableScale[0] = params[0];
|
||||
ctx->Pixel.TextureColorTableScale[1] = params[1];
|
||||
ctx->Pixel.TextureColorTableScale[2] = params[2];
|
||||
ctx->Pixel.TextureColorTableScale[3] = params[3];
|
||||
COPY_4V(ctx->Pixel.TextureColorTableScale, params);
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
ctx->Pixel.TextureColorTableBias[0] = params[0];
|
||||
ctx->Pixel.TextureColorTableBias[1] = params[1];
|
||||
ctx->Pixel.TextureColorTableBias[2] = params[2];
|
||||
ctx->Pixel.TextureColorTableBias[3] = params[3];
|
||||
COPY_4V(ctx->Pixel.TextureColorTableBias, params);
|
||||
}
|
||||
else {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
|
||||
@@ -867,16 +815,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
ctx->Pixel.PCCTscale[0] = params[0];
|
||||
ctx->Pixel.PCCTscale[1] = params[1];
|
||||
ctx->Pixel.PCCTscale[2] = params[2];
|
||||
ctx->Pixel.PCCTscale[3] = params[3];
|
||||
COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION], params);
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
ctx->Pixel.PCCTbias[0] = params[0];
|
||||
ctx->Pixel.PCCTbias[1] = params[1];
|
||||
ctx->Pixel.PCCTbias[2] = params[2];
|
||||
ctx->Pixel.PCCTbias[3] = params[3];
|
||||
COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION], params);
|
||||
}
|
||||
else {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
|
||||
@@ -885,16 +827,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
ctx->Pixel.PCMCTscale[0] = params[0];
|
||||
ctx->Pixel.PCMCTscale[1] = params[1];
|
||||
ctx->Pixel.PCMCTscale[2] = params[2];
|
||||
ctx->Pixel.PCMCTscale[3] = params[3];
|
||||
COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX], params);
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
ctx->Pixel.PCMCTbias[0] = params[0];
|
||||
ctx->Pixel.PCMCTbias[1] = params[1];
|
||||
ctx->Pixel.PCMCTbias[2] = params[2];
|
||||
ctx->Pixel.PCMCTbias[3] = params[3];
|
||||
COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX], params);
|
||||
}
|
||||
else {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
|
||||
@@ -981,24 +917,18 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
|
||||
table = &ctx->Texture.Palette;
|
||||
break;
|
||||
case GL_COLOR_TABLE:
|
||||
table = &ctx->ColorTable;
|
||||
table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
params[0] = ctx->Pixel.ColorTableScale[0];
|
||||
params[1] = ctx->Pixel.ColorTableScale[1];
|
||||
params[2] = ctx->Pixel.ColorTableScale[2];
|
||||
params[3] = ctx->Pixel.ColorTableScale[3];
|
||||
COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]);
|
||||
return;
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
params[0] = ctx->Pixel.ColorTableBias[0];
|
||||
params[1] = ctx->Pixel.ColorTableBias[1];
|
||||
params[2] = ctx->Pixel.ColorTableBias[2];
|
||||
params[3] = ctx->Pixel.ColorTableBias[3];
|
||||
COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case GL_PROXY_COLOR_TABLE:
|
||||
table = &ctx->ProxyColorTable;
|
||||
table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION];
|
||||
break;
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
if (!ctx->Extensions.SGI_texture_color_table) {
|
||||
@@ -1007,17 +937,11 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
|
||||
}
|
||||
table = &(texUnit->ColorTable);
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
params[0] = ctx->Pixel.TextureColorTableScale[0];
|
||||
params[1] = ctx->Pixel.TextureColorTableScale[1];
|
||||
params[2] = ctx->Pixel.TextureColorTableScale[2];
|
||||
params[3] = ctx->Pixel.TextureColorTableScale[3];
|
||||
COPY_4V(params, ctx->Pixel.TextureColorTableScale);
|
||||
return;
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
params[0] = ctx->Pixel.TextureColorTableBias[0];
|
||||
params[1] = ctx->Pixel.TextureColorTableBias[1];
|
||||
params[2] = ctx->Pixel.TextureColorTableBias[2];
|
||||
params[3] = ctx->Pixel.TextureColorTableBias[3];
|
||||
COPY_4V(params, ctx->Pixel.TextureColorTableBias);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -1029,44 +953,32 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
|
||||
table = &(texUnit->ProxyColorTable);
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE:
|
||||
table = &ctx->PostConvolutionColorTable;
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
params[0] = ctx->Pixel.PCCTscale[0];
|
||||
params[1] = ctx->Pixel.PCCTscale[1];
|
||||
params[2] = ctx->Pixel.PCCTscale[2];
|
||||
params[3] = ctx->Pixel.PCCTscale[3];
|
||||
COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]);
|
||||
return;
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
params[0] = ctx->Pixel.PCCTbias[0];
|
||||
params[1] = ctx->Pixel.PCCTbias[1];
|
||||
params[2] = ctx->Pixel.PCCTbias[2];
|
||||
params[3] = ctx->Pixel.PCCTbias[3];
|
||||
COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
|
||||
table = &ctx->ProxyPostConvolutionColorTable;
|
||||
table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION];
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE:
|
||||
table = &ctx->PostColorMatrixColorTable;
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
params[0] = ctx->Pixel.PCMCTscale[0];
|
||||
params[1] = ctx->Pixel.PCMCTscale[1];
|
||||
params[2] = ctx->Pixel.PCMCTscale[2];
|
||||
params[3] = ctx->Pixel.PCMCTscale[3];
|
||||
COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]);
|
||||
return;
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
params[0] = ctx->Pixel.PCMCTbias[0];
|
||||
params[1] = ctx->Pixel.PCMCTbias[1];
|
||||
params[2] = ctx->Pixel.PCMCTbias[2];
|
||||
params[3] = ctx->Pixel.PCMCTbias[3];
|
||||
COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
|
||||
table = &ctx->ProxyPostColorMatrixColorTable;
|
||||
table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)");
|
||||
@@ -1155,24 +1067,26 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
|
||||
table = &ctx->Texture.Palette;
|
||||
break;
|
||||
case GL_COLOR_TABLE:
|
||||
table = &ctx->ColorTable;
|
||||
table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
params[0] = (GLint) ctx->Pixel.ColorTableScale[0];
|
||||
params[1] = (GLint) ctx->Pixel.ColorTableScale[1];
|
||||
params[2] = (GLint) ctx->Pixel.ColorTableScale[2];
|
||||
params[3] = (GLint) ctx->Pixel.ColorTableScale[3];
|
||||
GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION];
|
||||
params[0] = (GLint) scale[0];
|
||||
params[1] = (GLint) scale[1];
|
||||
params[2] = (GLint) scale[2];
|
||||
params[3] = (GLint) scale[3];
|
||||
return;
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
params[0] = (GLint) ctx->Pixel.ColorTableBias[0];
|
||||
params[1] = (GLint) ctx->Pixel.ColorTableBias[1];
|
||||
params[2] = (GLint) ctx->Pixel.ColorTableBias[2];
|
||||
params[3] = (GLint) ctx->Pixel.ColorTableBias[3];
|
||||
GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION];
|
||||
params[0] = (GLint) bias[0];
|
||||
params[1] = (GLint) bias[1];
|
||||
params[2] = (GLint) bias[2];
|
||||
params[3] = (GLint) bias[3];
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case GL_PROXY_COLOR_TABLE:
|
||||
table = &ctx->ProxyColorTable;
|
||||
table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION];
|
||||
break;
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
if (!ctx->Extensions.SGI_texture_color_table) {
|
||||
@@ -1203,44 +1117,48 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
|
||||
table = &(texUnit->ProxyColorTable);
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE:
|
||||
table = &ctx->PostConvolutionColorTable;
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
params[0] = (GLint) ctx->Pixel.PCCTscale[0];
|
||||
params[1] = (GLint) ctx->Pixel.PCCTscale[1];
|
||||
params[2] = (GLint) ctx->Pixel.PCCTscale[2];
|
||||
params[3] = (GLint) ctx->Pixel.PCCTscale[3];
|
||||
GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION];
|
||||
params[0] = (GLint) scale[0];
|
||||
params[1] = (GLint) scale[1];
|
||||
params[2] = (GLint) scale[2];
|
||||
params[3] = (GLint) scale[3];
|
||||
return;
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
params[0] = (GLint) ctx->Pixel.PCCTbias[0];
|
||||
params[1] = (GLint) ctx->Pixel.PCCTbias[1];
|
||||
params[2] = (GLint) ctx->Pixel.PCCTbias[2];
|
||||
params[3] = (GLint) ctx->Pixel.PCCTbias[3];
|
||||
GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION];
|
||||
params[0] = (GLint) bias[0];
|
||||
params[1] = (GLint) bias[1];
|
||||
params[2] = (GLint) bias[2];
|
||||
params[3] = (GLint) bias[3];
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
|
||||
table = &ctx->ProxyPostConvolutionColorTable;
|
||||
table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION];
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE:
|
||||
table = &ctx->PostColorMatrixColorTable;
|
||||
table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
|
||||
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
|
||||
params[0] = (GLint) ctx->Pixel.PCMCTscale[0];
|
||||
params[1] = (GLint) ctx->Pixel.PCMCTscale[1];
|
||||
params[2] = (GLint) ctx->Pixel.PCMCTscale[2];
|
||||
params[3] = (GLint) ctx->Pixel.PCMCTscale[3];
|
||||
GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
|
||||
params[0] = (GLint) scale[0];
|
||||
params[0] = (GLint) scale[1];
|
||||
params[0] = (GLint) scale[2];
|
||||
params[0] = (GLint) scale[3];
|
||||
return;
|
||||
}
|
||||
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
|
||||
params[0] = (GLint) ctx->Pixel.PCMCTbias[0];
|
||||
params[1] = (GLint) ctx->Pixel.PCMCTbias[1];
|
||||
params[2] = (GLint) ctx->Pixel.PCMCTbias[2];
|
||||
params[3] = (GLint) ctx->Pixel.PCMCTbias[3];
|
||||
GLfloat *bias = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
|
||||
params[0] = (GLint) bias[0];
|
||||
params[1] = (GLint) bias[1];
|
||||
params[2] = (GLint) bias[2];
|
||||
params[3] = (GLint) bias[3];
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
|
||||
table = &ctx->ProxyPostColorMatrixColorTable;
|
||||
table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)");
|
||||
@@ -1316,13 +1234,11 @@ _mesa_free_colortable_data( struct gl_color_table *p )
|
||||
void
|
||||
_mesa_init_colortables( GLcontext * ctx )
|
||||
{
|
||||
/* Color tables */
|
||||
_mesa_init_colortable(&ctx->ColorTable);
|
||||
_mesa_init_colortable(&ctx->ProxyColorTable);
|
||||
_mesa_init_colortable(&ctx->PostConvolutionColorTable);
|
||||
_mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable);
|
||||
_mesa_init_colortable(&ctx->PostColorMatrixColorTable);
|
||||
_mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable);
|
||||
GLuint i;
|
||||
for (i = 0; i < COLORTABLE_MAX; i++) {
|
||||
_mesa_init_colortable(&ctx->ColorTable[i]);
|
||||
_mesa_init_colortable(&ctx->ProxyColorTable[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1332,10 +1248,9 @@ _mesa_init_colortables( GLcontext * ctx )
|
||||
void
|
||||
_mesa_free_colortables_data( GLcontext *ctx )
|
||||
{
|
||||
_mesa_free_colortable_data(&ctx->ColorTable);
|
||||
_mesa_free_colortable_data(&ctx->ProxyColorTable);
|
||||
_mesa_free_colortable_data(&ctx->PostConvolutionColorTable);
|
||||
_mesa_free_colortable_data(&ctx->ProxyPostConvolutionColorTable);
|
||||
_mesa_free_colortable_data(&ctx->PostColorMatrixColorTable);
|
||||
_mesa_free_colortable_data(&ctx->ProxyPostColorMatrixColorTable);
|
||||
GLuint i;
|
||||
for (i = 0; i < COLORTABLE_MAX; i++) {
|
||||
_mesa_free_colortable_data(&ctx->ColorTable[i]);
|
||||
_mesa_free_colortable_data(&ctx->ProxyColorTable[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,21 +196,19 @@
|
||||
/** For any program target/extension */
|
||||
/*@{*/
|
||||
#define MAX_PROGRAM_LOCAL_PARAMS 128 /* KW: power of two */
|
||||
#define MAX_PROGRAM_ENV_PARAMS 128
|
||||
#define MAX_PROGRAM_MATRICES 8
|
||||
#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4
|
||||
#define MAX_PROGRAM_CALL_DEPTH 8
|
||||
/*@}*/
|
||||
|
||||
/** For GL_ARB_fragment_shader */
|
||||
/*@{*/
|
||||
#define MAX_FRAGMENT_UNIFORM_COMPONENTS 64
|
||||
#define MAX_PROGRAM_TEMPS 128
|
||||
#define MAX_PROGRAM_ADDRESS_REGS 2
|
||||
#define MAX_UNIFORMS 128
|
||||
#define MAX_VARYING 8
|
||||
/*@}*/
|
||||
|
||||
/** For GL_ARB_vertex_shader */
|
||||
/*@{*/
|
||||
#define MAX_VERTEX_ATTRIBS 16
|
||||
#define MAX_VERTEX_UNIFORM_COMPONENTS 512
|
||||
#define MAX_VARYING_FLOATS 32
|
||||
#define MAX_VERTEX_TEXTURE_IMAGE_UNITS 0
|
||||
#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS)
|
||||
/*@}*/
|
||||
@@ -218,7 +216,7 @@
|
||||
|
||||
/** For GL_ARB_draw_buffers */
|
||||
/*@{*/
|
||||
#define MAX_DRAW_BUFFERS 1
|
||||
#define MAX_DRAW_BUFFERS 4
|
||||
/*@}*/
|
||||
|
||||
|
||||
@@ -302,6 +300,7 @@
|
||||
#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL
|
||||
#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader)
|
||||
#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects
|
||||
#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects
|
||||
|
||||
#define FEATURE_EXT_framebuffer_blit _HAVE_FULL_GL
|
||||
#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
#include "fbobject.h"
|
||||
#include "feedback.h"
|
||||
#include "fog.h"
|
||||
#include "framebuffer.h"
|
||||
#include "get.h"
|
||||
#include "glthread.h"
|
||||
#include "glapioffsets.h"
|
||||
@@ -106,13 +107,13 @@
|
||||
#include "lines.h"
|
||||
#include "macros.h"
|
||||
#include "matrix.h"
|
||||
#include "occlude.h"
|
||||
#include "pixel.h"
|
||||
#include "points.h"
|
||||
#include "polygon.h"
|
||||
#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
|
||||
#include "program.h"
|
||||
#endif
|
||||
#include "queryobj.h"
|
||||
#include "rastpos.h"
|
||||
#include "simple_list.h"
|
||||
#include "state.h"
|
||||
@@ -131,7 +132,7 @@
|
||||
#include "math/m_xform.h"
|
||||
#include "math/mathmod.h"
|
||||
#endif
|
||||
#include "shaderobjects.h"
|
||||
#include "shader_api.h"
|
||||
|
||||
#ifdef USE_SPARC_ASM
|
||||
#include "sparc/sparc.h"
|
||||
@@ -153,171 +154,6 @@ static void
|
||||
free_shared_state( GLcontext *ctx, struct gl_shared_state *ss );
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/** \name OpenGL SI-style interface (new in Mesa 3.5)
|
||||
*
|
||||
* \if subset
|
||||
* \note Most of these functions are never called in the Mesa subset.
|
||||
* \endif
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* Destroy context callback.
|
||||
*
|
||||
* \param gc context.
|
||||
* \return GL_TRUE on success, or GL_FALSE on failure.
|
||||
*
|
||||
* \ifnot subset
|
||||
* Called by window system/device driver (via __GLexports::destroyCurrent) when
|
||||
* the rendering context is to be destroyed.
|
||||
* \endif
|
||||
*
|
||||
* Frees the context data and the context structure.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_destroyContext(__GLcontext *gc)
|
||||
{
|
||||
if (gc) {
|
||||
_mesa_free_context_data(gc);
|
||||
_mesa_free(gc);
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unbind context callback.
|
||||
*
|
||||
* \param gc context.
|
||||
* \return GL_TRUE on success, or GL_FALSE on failure.
|
||||
*
|
||||
* \ifnot subset
|
||||
* Called by window system/device driver (via __GLexports::loseCurrent)
|
||||
* when the rendering context is made non-current.
|
||||
* \endif
|
||||
*
|
||||
* No-op
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_loseCurrent(__GLcontext *gc)
|
||||
{
|
||||
/* XXX unbind context from thread */
|
||||
(void) gc;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind context callback.
|
||||
*
|
||||
* \param gc context.
|
||||
* \return GL_TRUE on success, or GL_FALSE on failure.
|
||||
*
|
||||
* \ifnot subset
|
||||
* Called by window system/device driver (via __GLexports::makeCurrent)
|
||||
* when the rendering context is made current.
|
||||
* \endif
|
||||
*
|
||||
* No-op
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_makeCurrent(__GLcontext *gc)
|
||||
{
|
||||
/* XXX bind context to thread */
|
||||
(void) gc;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Share context callback.
|
||||
*
|
||||
* \param gc context.
|
||||
* \param gcShare shared context.
|
||||
* \return GL_TRUE on success, or GL_FALSE on failure.
|
||||
*
|
||||
* \ifnot subset
|
||||
* Called by window system/device driver (via __GLexports::shareContext)
|
||||
* \endif
|
||||
*
|
||||
* Update the shared context reference count, gl_shared_state::RefCount.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_shareContext(__GLcontext *gc, __GLcontext *gcShare)
|
||||
{
|
||||
if (gc && gcShare && gc->Shared && gcShare->Shared) {
|
||||
gc->Shared->RefCount--;
|
||||
if (gc->Shared->RefCount == 0) {
|
||||
free_shared_state(gc, gc->Shared);
|
||||
}
|
||||
gc->Shared = gcShare->Shared;
|
||||
gc->Shared->RefCount++;
|
||||
return GL_TRUE;
|
||||
}
|
||||
else {
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if _HAVE_FULL_GL
|
||||
/**
|
||||
* Copy context callback.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_copyContext(__GLcontext *dst, const __GLcontext *src, GLuint mask)
|
||||
{
|
||||
if (dst && src) {
|
||||
_mesa_copy_context( src, dst, mask );
|
||||
return GL_TRUE;
|
||||
}
|
||||
else {
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/** No-op */
|
||||
GLboolean
|
||||
_mesa_forceCurrent(__GLcontext *gc)
|
||||
{
|
||||
(void) gc;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Windows/buffer resizing notification callback.
|
||||
*
|
||||
* \param gc GL context.
|
||||
* \return GL_TRUE on success, or GL_FALSE on failure.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_notifyResize(__GLcontext *gc)
|
||||
{
|
||||
GLint x, y;
|
||||
GLuint width, height;
|
||||
__GLdrawablePrivate *d = gc->imports.getDrawablePrivate(gc);
|
||||
if (!d || !d->getDrawableSize)
|
||||
return GL_FALSE;
|
||||
d->getDrawableSize( d, &x, &y, &width, &height );
|
||||
/* update viewport, resize software buffers, etc. */
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Window/buffer destruction notification callback.
|
||||
*
|
||||
* \param gc GL context.
|
||||
*
|
||||
* Called when the context's window/buffer is going to be destroyed.
|
||||
*
|
||||
* No-op
|
||||
*/
|
||||
void
|
||||
_mesa_notifyDestroy(__GLcontext *gc)
|
||||
{
|
||||
/* Unbind from it. */
|
||||
(void) gc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swap buffers notification callback.
|
||||
*
|
||||
@@ -332,105 +168,6 @@ _mesa_notifySwapBuffers(__GLcontext *gc)
|
||||
FLUSH_VERTICES( gc, 0 );
|
||||
}
|
||||
|
||||
/** No-op */
|
||||
struct __GLdispatchStateRec *
|
||||
_mesa_dispatchExec(__GLcontext *gc)
|
||||
{
|
||||
(void) gc;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** No-op */
|
||||
void
|
||||
_mesa_beginDispatchOverride(__GLcontext *gc)
|
||||
{
|
||||
(void) gc;
|
||||
}
|
||||
|
||||
/** No-op */
|
||||
void
|
||||
_mesa_endDispatchOverride(__GLcontext *gc)
|
||||
{
|
||||
(void) gc;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ifnot subset
|
||||
* Setup the exports.
|
||||
*
|
||||
* The window system will call these functions when it needs Mesa to do
|
||||
* something.
|
||||
*
|
||||
* \note Device drivers should override these functions! For example,
|
||||
* the Xlib driver should plug in the XMesa*-style functions into this
|
||||
* structure. The XMesa-style functions should then call the _mesa_*
|
||||
* version of these functions. This is an approximation to OO design
|
||||
* (inheritance and virtual functions).
|
||||
* \endif
|
||||
*
|
||||
* \if subset
|
||||
* No-op.
|
||||
*
|
||||
* \endif
|
||||
*/
|
||||
static void
|
||||
_mesa_init_default_exports(__GLexports *exports)
|
||||
{
|
||||
#if _HAVE_FULL_GL
|
||||
exports->destroyContext = _mesa_destroyContext;
|
||||
exports->loseCurrent = _mesa_loseCurrent;
|
||||
exports->makeCurrent = _mesa_makeCurrent;
|
||||
exports->shareContext = _mesa_shareContext;
|
||||
exports->copyContext = _mesa_copyContext;
|
||||
exports->forceCurrent = _mesa_forceCurrent;
|
||||
exports->notifyResize = _mesa_notifyResize;
|
||||
exports->notifyDestroy = _mesa_notifyDestroy;
|
||||
exports->notifySwapBuffers = _mesa_notifySwapBuffers;
|
||||
exports->dispatchExec = _mesa_dispatchExec;
|
||||
exports->beginDispatchOverride = _mesa_beginDispatchOverride;
|
||||
exports->endDispatchOverride = _mesa_endDispatchOverride;
|
||||
#else
|
||||
(void) exports;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Exported OpenGL SI interface.
|
||||
*/
|
||||
__GLcontext *
|
||||
__glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes)
|
||||
{
|
||||
GLcontext *ctx;
|
||||
|
||||
ctx = (GLcontext *) (*imports->calloc)(NULL, 1, sizeof(GLcontext));
|
||||
if (ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* XXX doesn't work at this time */
|
||||
_mesa_initialize_context(ctx, modes, NULL, NULL, NULL);
|
||||
ctx->imports = *imports;
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exported OpenGL SI interface.
|
||||
*/
|
||||
void
|
||||
__glCoreNopDispatch(void)
|
||||
{
|
||||
#if 0
|
||||
/* SI */
|
||||
__gl_dispatch = __glNopDispatchState;
|
||||
#else
|
||||
/* Mesa */
|
||||
_glapi_set_dispatch(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/** \name GL Visual allocation/destruction */
|
||||
@@ -625,6 +362,8 @@ one_time_init( GLcontext *ctx )
|
||||
assert( sizeof(GLint) == 4 );
|
||||
assert( sizeof(GLuint) == 4 );
|
||||
|
||||
_mesa_init_sqrt_table();
|
||||
|
||||
#if _HAVE_FULL_GL
|
||||
_math_init();
|
||||
|
||||
@@ -705,7 +444,7 @@ alloc_shared_state( GLcontext *ctx )
|
||||
ss->ArrayObjects = _mesa_NewHashTable();
|
||||
|
||||
#if FEATURE_ARB_shader_objects
|
||||
ss->GL2Objects = _mesa_NewHashTable ();
|
||||
ss->ShaderObjects = _mesa_NewHashTable();
|
||||
#endif
|
||||
|
||||
ss->Default1D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_1D);
|
||||
@@ -782,8 +521,8 @@ alloc_shared_state( GLcontext *ctx )
|
||||
_mesa_DeleteHashTable (ss->ArrayObjects);
|
||||
|
||||
#if FEATURE_ARB_shader_objects
|
||||
if (ss->GL2Objects)
|
||||
_mesa_DeleteHashTable (ss->GL2Objects);
|
||||
if (ss->ShaderObjects)
|
||||
_mesa_DeleteHashTable (ss->ShaderObjects);
|
||||
#endif
|
||||
|
||||
#if FEATURE_EXT_framebuffer_object
|
||||
@@ -877,13 +616,22 @@ delete_arrayobj_cb(GLuint id, void *data, void *userData)
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for deleting an shader object. Called by _mesa_HashDeleteAll().
|
||||
* Callback for deleting shader and shader programs objects.
|
||||
* Called by _mesa_HashDeleteAll().
|
||||
*/
|
||||
static void
|
||||
delete_shaderobj_cb(GLuint id, void *data, void *userData)
|
||||
delete_shader_cb(GLuint id, void *data, void *userData)
|
||||
{
|
||||
/* XXX probably need to fix this */
|
||||
_mesa_free(data);
|
||||
GLcontext *ctx = (GLcontext *) userData;
|
||||
struct gl_shader *sh = (struct gl_shader *) data;
|
||||
if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) {
|
||||
_mesa_free_shader(ctx, sh);
|
||||
}
|
||||
else {
|
||||
struct gl_shader_program *shProg = (struct gl_shader_program *) data;
|
||||
ASSERT(shProg->Type == GL_SHADER_PROGRAM_MESA);
|
||||
_mesa_free_shader_program(ctx, shProg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -948,8 +696,8 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
|
||||
_mesa_DeleteHashTable(ss->ArrayObjects);
|
||||
|
||||
#if FEATURE_ARB_shader_objects
|
||||
_mesa_HashDeleteAll(ss->GL2Objects, delete_shaderobj_cb, ctx);
|
||||
_mesa_DeleteHashTable(ss->GL2Objects);
|
||||
_mesa_HashDeleteAll(ss->ShaderObjects, delete_shader_cb, ctx);
|
||||
_mesa_DeleteHashTable(ss->ShaderObjects);
|
||||
#endif
|
||||
|
||||
#if FEATURE_EXT_framebuffer_object
|
||||
@@ -981,9 +729,8 @@ _mesa_init_current( GLcontext *ctx )
|
||||
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], 0.0, 0.0, 1.0, 1.0 );
|
||||
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR0], 1.0, 1.0, 1.0, 1.0 );
|
||||
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR1], 0.0, 0.0, 0.0, 1.0 );
|
||||
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_FOG], 0.0, 0.0, 0.0, 0.0 );
|
||||
ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = 1.0;
|
||||
ctx->Current.EdgeFlag = GL_TRUE;
|
||||
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX], 1.0, 0.0, 0.0, 1.0 );
|
||||
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG], 1.0, 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -1058,39 +805,34 @@ _mesa_init_constants( GLcontext *ctx )
|
||||
ctx->Const.VertexProgram.MaxTexInstructions = 0;
|
||||
ctx->Const.VertexProgram.MaxTexIndirections = 0;
|
||||
ctx->Const.VertexProgram.MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
|
||||
ctx->Const.VertexProgram.MaxTemps = MAX_NV_VERTEX_PROGRAM_TEMPS;
|
||||
ctx->Const.VertexProgram.MaxTemps = MAX_PROGRAM_TEMPS;
|
||||
ctx->Const.VertexProgram.MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS;
|
||||
ctx->Const.VertexProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
|
||||
ctx->Const.VertexProgram.MaxEnvParams = MAX_NV_VERTEX_PROGRAM_PARAMS;
|
||||
ctx->Const.VertexProgram.MaxEnvParams = MAX_PROGRAM_ENV_PARAMS;
|
||||
ctx->Const.VertexProgram.MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
|
||||
ctx->Const.VertexProgram.MaxUniformComponents = MAX_VERTEX_UNIFORM_COMPONENTS;
|
||||
ctx->Const.VertexProgram.MaxUniformComponents = 4 * MAX_UNIFORMS;
|
||||
init_natives(&ctx->Const.VertexProgram);
|
||||
#endif
|
||||
|
||||
#if FEATURE_ARB_fragment_program
|
||||
ctx->Const.FragmentProgram.MaxInstructions = MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS;
|
||||
ctx->Const.FragmentProgram.MaxAluInstructions = MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS;
|
||||
ctx->Const.FragmentProgram.MaxTexInstructions = MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS;
|
||||
ctx->Const.FragmentProgram.MaxTexIndirections = MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS;
|
||||
ctx->Const.FragmentProgram.MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
|
||||
ctx->Const.FragmentProgram.MaxTemps = MAX_NV_FRAGMENT_PROGRAM_TEMPS;
|
||||
ctx->Const.FragmentProgram.MaxTemps = MAX_PROGRAM_TEMPS;
|
||||
ctx->Const.FragmentProgram.MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
|
||||
ctx->Const.FragmentProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
|
||||
ctx->Const.FragmentProgram.MaxEnvParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
|
||||
ctx->Const.FragmentProgram.MaxEnvParams = MAX_PROGRAM_ENV_PARAMS;
|
||||
ctx->Const.FragmentProgram.MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
|
||||
ctx->Const.FragmentProgram.MaxUniformComponents = MAX_FRAGMENT_UNIFORM_COMPONENTS;
|
||||
ctx->Const.FragmentProgram.MaxUniformComponents = 4 * MAX_UNIFORMS;
|
||||
init_natives(&ctx->Const.FragmentProgram);
|
||||
#endif
|
||||
ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
|
||||
ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
|
||||
|
||||
/* If we're running in the X server, do bounds checking to prevent
|
||||
* segfaults and server crashes!
|
||||
*/
|
||||
#if defined(XFree86Server)
|
||||
ctx->Const.CheckArrayBounds = GL_TRUE;
|
||||
#else
|
||||
/* CheckArrayBounds is overriden by drivers/x11 for X server */
|
||||
ctx->Const.CheckArrayBounds = GL_FALSE;
|
||||
#endif
|
||||
|
||||
/* GL_ARB_draw_buffers */
|
||||
ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS;
|
||||
@@ -1106,7 +848,7 @@ _mesa_init_constants( GLcontext *ctx )
|
||||
|
||||
#if FEATURE_ARB_vertex_shader
|
||||
ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
|
||||
ctx->Const.MaxVaryingFloats = MAX_VARYING_FLOATS;
|
||||
ctx->Const.MaxVarying = MAX_VARYING;
|
||||
#endif
|
||||
|
||||
/* sanity checks */
|
||||
@@ -1114,6 +856,11 @@ _mesa_init_constants( GLcontext *ctx )
|
||||
ctx->Const.MaxTextureCoordUnits));
|
||||
ASSERT(ctx->Const.FragmentProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
|
||||
ASSERT(ctx->Const.VertexProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
|
||||
|
||||
ASSERT(MAX_NV_FRAGMENT_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS);
|
||||
ASSERT(MAX_NV_VERTEX_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS);
|
||||
ASSERT(MAX_NV_VERTEX_PROGRAM_INPUTS <= VERT_ATTRIB_MAX);
|
||||
ASSERT(MAX_NV_VERTEX_PROGRAM_OUTPUTS <= VERT_RESULT_MAX);
|
||||
}
|
||||
|
||||
|
||||
@@ -1191,7 +938,7 @@ init_attrib_groups( GLcontext *ctx )
|
||||
_mesa_init_query( ctx );
|
||||
_mesa_init_rastpos( ctx );
|
||||
_mesa_init_scissor( ctx );
|
||||
_mesa_init_shaderobjects (ctx);
|
||||
_mesa_init_shader_state( ctx );
|
||||
_mesa_init_stencil( ctx );
|
||||
_mesa_init_transform( ctx );
|
||||
_mesa_init_varray( ctx );
|
||||
@@ -1288,14 +1035,6 @@ _mesa_initialize_context( GLcontext *ctx,
|
||||
assert(driverFunctions->NewTextureObject);
|
||||
assert(driverFunctions->FreeTexImageData);
|
||||
|
||||
/* If the driver wants core Mesa to use special imports, it'll have to
|
||||
* override these defaults.
|
||||
*/
|
||||
_mesa_init_default_imports( &(ctx->imports), driverContext );
|
||||
|
||||
/* initialize the exports (Mesa functions called by the window system) */
|
||||
_mesa_init_default_exports( &(ctx->exports) );
|
||||
|
||||
/* misc one-time initializations */
|
||||
one_time_init(ctx);
|
||||
|
||||
@@ -1351,12 +1090,16 @@ _mesa_initialize_context( GLcontext *ctx,
|
||||
ctx->TnlModule.SwapCount = 0;
|
||||
#endif
|
||||
|
||||
ctx->_MaintainTexEnvProgram = (_mesa_getenv("MESA_TEX_PROG") != NULL);
|
||||
ctx->_UseTexEnvProgram = ctx->_MaintainTexEnvProgram;
|
||||
ctx->FragmentProgram._MaintainTexEnvProgram
|
||||
= (_mesa_getenv("MESA_TEX_PROG") != NULL);
|
||||
ctx->FragmentProgram._UseTexEnvProgram = ctx->FragmentProgram._MaintainTexEnvProgram;
|
||||
|
||||
ctx->_MaintainTnlProgram = (_mesa_getenv("MESA_TNL_PROG") != NULL);
|
||||
if (ctx->_MaintainTnlProgram)
|
||||
ctx->_MaintainTexEnvProgram = 1; /* this is required... */
|
||||
ctx->VertexProgram._MaintainTnlProgram
|
||||
= (_mesa_getenv("MESA_TNL_PROG") != NULL);
|
||||
if (ctx->VertexProgram._MaintainTnlProgram) {
|
||||
/* this is required... */
|
||||
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
|
||||
}
|
||||
|
||||
ctx->FirstTimeCurrent = GL_TRUE;
|
||||
|
||||
@@ -1383,7 +1126,6 @@ _mesa_create_context( const GLvisual *visual,
|
||||
GLcontext *share_list,
|
||||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext)
|
||||
|
||||
{
|
||||
GLcontext *ctx;
|
||||
|
||||
@@ -1419,6 +1161,13 @@ _mesa_free_context_data( GLcontext *ctx )
|
||||
if (ctx == _mesa_get_current_context()) {
|
||||
_mesa_make_current(NULL, NULL, NULL);
|
||||
}
|
||||
else {
|
||||
/* unreference WinSysDraw/Read buffers */
|
||||
_mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer);
|
||||
_mesa_unreference_framebuffer(&ctx->WinSysReadBuffer);
|
||||
_mesa_unreference_framebuffer(&ctx->DrawBuffer);
|
||||
_mesa_unreference_framebuffer(&ctx->ReadBuffer);
|
||||
}
|
||||
|
||||
_mesa_free_lighting_data( ctx );
|
||||
_mesa_free_eval_data( ctx );
|
||||
@@ -1427,6 +1176,7 @@ _mesa_free_context_data( GLcontext *ctx )
|
||||
_mesa_free_viewport_data( ctx );
|
||||
_mesa_free_colortables_data( ctx );
|
||||
_mesa_free_program_data(ctx);
|
||||
_mesa_free_shader_state(ctx);
|
||||
_mesa_free_query_data(ctx);
|
||||
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
@@ -1678,6 +1428,8 @@ void
|
||||
_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
|
||||
GLframebuffer *readBuffer )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(oldCtx);
|
||||
|
||||
if (MESA_VERBOSE & VERBOSE_API)
|
||||
_mesa_debug(newCtx, "_mesa_make_current()\n");
|
||||
|
||||
@@ -1702,6 +1454,13 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
|
||||
_glapi_set_context((void *) newCtx);
|
||||
ASSERT(_mesa_get_current_context() == newCtx);
|
||||
|
||||
if (oldCtx) {
|
||||
_mesa_unreference_framebuffer(&oldCtx->WinSysDrawBuffer);
|
||||
_mesa_unreference_framebuffer(&oldCtx->WinSysReadBuffer);
|
||||
_mesa_unreference_framebuffer(&oldCtx->DrawBuffer);
|
||||
_mesa_unreference_framebuffer(&oldCtx->ReadBuffer);
|
||||
}
|
||||
|
||||
if (!newCtx) {
|
||||
_glapi_set_dispatch(NULL); /* none current */
|
||||
}
|
||||
@@ -1713,18 +1472,18 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
|
||||
|
||||
ASSERT(drawBuffer->Name == 0);
|
||||
ASSERT(readBuffer->Name == 0);
|
||||
newCtx->WinSysDrawBuffer = drawBuffer;
|
||||
newCtx->WinSysReadBuffer = readBuffer;
|
||||
_mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer);
|
||||
_mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer);
|
||||
|
||||
/*
|
||||
* Only set the context's Draw/ReadBuffer fields if they're NULL
|
||||
* or not bound to a user-created FBO.
|
||||
*/
|
||||
if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
|
||||
newCtx->DrawBuffer = drawBuffer;
|
||||
_mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
|
||||
}
|
||||
if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
|
||||
newCtx->ReadBuffer = readBuffer;
|
||||
_mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
|
||||
}
|
||||
|
||||
newCtx->NewState |= _NEW_BUFFERS;
|
||||
@@ -1810,12 +1569,11 @@ _mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare)
|
||||
|
||||
|
||||
/**
|
||||
* Get current context for the calling thread.
|
||||
*
|
||||
* \return pointer to the current GL context.
|
||||
* \return pointer to the current GL context for this thread.
|
||||
*
|
||||
* Calls _glapi_get_context(). This isn't the fastest way to get the current
|
||||
* context. If you need speed, see the #GET_CURRENT_CONTEXT macro in context.h.
|
||||
* context. If you need speed, see the #GET_CURRENT_CONTEXT macro in
|
||||
* context.h.
|
||||
*/
|
||||
GLcontext *
|
||||
_mesa_get_current_context( void )
|
||||
@@ -1823,6 +1581,7 @@ _mesa_get_current_context( void )
|
||||
return (GLcontext *) _glapi_get_context();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get context's current API dispatch table.
|
||||
*
|
||||
@@ -1873,10 +1632,11 @@ _mesa_record_error( GLcontext *ctx, GLenum error )
|
||||
|
||||
/* Call device driver's error handler, if any. This is used on the Mac. */
|
||||
if (ctx->Driver.Error) {
|
||||
(*ctx->Driver.Error)( ctx );
|
||||
ctx->Driver.Error(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute glFinish().
|
||||
*
|
||||
@@ -1889,10 +1649,11 @@ _mesa_Finish( void )
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
||||
if (ctx->Driver.Finish) {
|
||||
(*ctx->Driver.Finish)( ctx );
|
||||
ctx->Driver.Finish(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute glFlush().
|
||||
*
|
||||
@@ -1905,7 +1666,7 @@ _mesa_Flush( void )
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
||||
if (ctx->Driver.Flush) {
|
||||
(*ctx->Driver.Flush)( ctx );
|
||||
ctx->Driver.Flush(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,47 +138,9 @@ _mesa_get_current_context(void);
|
||||
/*@}*/
|
||||
|
||||
|
||||
/** \name OpenGL SI-style export functions */
|
||||
/*@{*/
|
||||
|
||||
extern GLboolean
|
||||
_mesa_destroyContext(__GLcontext *gc);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_loseCurrent(__GLcontext *gc);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_makeCurrent(__GLcontext *gc);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_shareContext(__GLcontext *gc, __GLcontext *gcShare);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_copyContext(__GLcontext *dst, const __GLcontext *src, GLuint mask);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_forceCurrent(__GLcontext *gc);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_notifyResize(__GLcontext *gc);
|
||||
|
||||
extern void
|
||||
_mesa_notifyDestroy(__GLcontext *gc);
|
||||
|
||||
extern void
|
||||
_mesa_notifySwapBuffers(__GLcontext *gc);
|
||||
|
||||
extern struct __GLdispatchStateRec *
|
||||
_mesa_dispatchExec(__GLcontext *gc);
|
||||
|
||||
extern void
|
||||
_mesa_beginDispatchOverride(__GLcontext *gc);
|
||||
|
||||
extern void
|
||||
_mesa_endDispatchOverride(__GLcontext *gc);
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
extern struct _glapi_table *
|
||||
_mesa_get_dispatch(GLcontext *ctx);
|
||||
|
||||
@@ -570,8 +570,8 @@ struct dd_function_table {
|
||||
/** Notify driver that a program string has been specified. */
|
||||
void (*ProgramStringNotify)(GLcontext *ctx, GLenum target,
|
||||
struct gl_program *prog);
|
||||
/** Get value of a fragment program register during program execution. */
|
||||
void (*GetFragmentProgramRegister)(GLcontext *ctx, enum register_file file,
|
||||
/** Get value of a program register during program execution. */
|
||||
void (*GetProgramRegister)(GLcontext *ctx, enum register_file file,
|
||||
GLuint index, GLfloat val[4]);
|
||||
|
||||
/** Query if program can be loaded onto hardware */
|
||||
@@ -821,6 +821,58 @@ struct dd_function_table {
|
||||
void (*BindArrayObject)(GLcontext *ctx, struct gl_array_object *obj);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name GLSL-related functions (ARB extensions and OpenGL 2.x)
|
||||
*/
|
||||
/*@{*/
|
||||
void (*AttachShader)(GLcontext *ctx, GLuint program, GLuint shader);
|
||||
void (*BindAttribLocation)(GLcontext *ctx, GLuint program, GLuint index,
|
||||
const GLcharARB *name);
|
||||
void (*CompileShader)(GLcontext *ctx, GLuint shader);
|
||||
GLuint (*CreateShader)(GLcontext *ctx, GLenum type);
|
||||
GLuint (*CreateProgram)(GLcontext *ctx);
|
||||
void (*DeleteProgram2)(GLcontext *ctx, GLuint program);
|
||||
void (*DeleteShader)(GLcontext *ctx, GLuint shader);
|
||||
void (*DetachShader)(GLcontext *ctx, GLuint program, GLuint shader);
|
||||
void (*GetActiveAttrib)(GLcontext *ctx, GLuint program, GLuint index,
|
||||
GLsizei maxLength, GLsizei * length, GLint * size,
|
||||
GLenum * type, GLcharARB * name);
|
||||
void (*GetActiveUniform)(GLcontext *ctx, GLuint program, GLuint index,
|
||||
GLsizei maxLength, GLsizei *length, GLint *size,
|
||||
GLenum *type, GLcharARB *name);
|
||||
void (*GetAttachedShaders)(GLcontext *ctx, GLuint program, GLsizei maxCount,
|
||||
GLsizei *count, GLuint *obj);
|
||||
GLint (*GetAttribLocation)(GLcontext *ctx, GLuint program,
|
||||
const GLcharARB *name);
|
||||
GLuint (*GetHandle)(GLcontext *ctx, GLenum pname);
|
||||
void (*GetProgramiv)(GLcontext *ctx, GLuint program,
|
||||
GLenum pname, GLint *params);
|
||||
void (*GetProgramInfoLog)(GLcontext *ctx, GLuint program, GLsizei bufSize,
|
||||
GLsizei *length, GLchar *infoLog);
|
||||
void (*GetShaderiv)(GLcontext *ctx, GLuint shader,
|
||||
GLenum pname, GLint *params);
|
||||
void (*GetShaderInfoLog)(GLcontext *ctx, GLuint shader, GLsizei bufSize,
|
||||
GLsizei *length, GLchar *infoLog);
|
||||
void (*GetShaderSource)(GLcontext *ctx, GLuint shader, GLsizei maxLength,
|
||||
GLsizei *length, GLcharARB *sourceOut);
|
||||
void (*GetUniformfv)(GLcontext *ctx, GLuint program, GLint location,
|
||||
GLfloat *params);
|
||||
GLint (*GetUniformLocation)(GLcontext *ctx, GLuint program,
|
||||
const GLcharARB *name);
|
||||
GLboolean (*IsProgram)(GLcontext *ctx, GLuint name);
|
||||
GLboolean (*IsShader)(GLcontext *ctx, GLuint name);
|
||||
void (*LinkProgram)(GLcontext *ctx, GLuint program);
|
||||
void (*ShaderSource)(GLcontext *ctx, GLuint shader, const GLchar *source);
|
||||
void (*Uniform)(GLcontext *ctx, GLint location, GLsizei count,
|
||||
const GLvoid *values, GLenum type);
|
||||
void (*UniformMatrix)(GLcontext *ctx, GLint cols, GLint rows,
|
||||
GLenum matrixType, GLint location, GLsizei count,
|
||||
GLboolean transpose, const GLfloat *values);
|
||||
void (*UseProgram)(GLcontext *ctx, GLuint program);
|
||||
void (*ValidateProgram)(GLcontext *ctx, GLuint program);
|
||||
/* XXX many more to come */
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* \name Support for multiple T&L engines
|
||||
|
||||
@@ -66,10 +66,10 @@
|
||||
#include "dlist.h"
|
||||
#include "macros.h"
|
||||
#include "matrix.h"
|
||||
#include "occlude.h"
|
||||
#include "pixel.h"
|
||||
#include "points.h"
|
||||
#include "polygon.h"
|
||||
#include "queryobj.h"
|
||||
#include "state.h"
|
||||
#include "texobj.h"
|
||||
#include "teximage.h"
|
||||
@@ -343,8 +343,6 @@ typedef enum
|
||||
OPCODE_ATTR_3F_ARB,
|
||||
OPCODE_ATTR_4F_ARB,
|
||||
OPCODE_MATERIAL,
|
||||
OPCODE_INDEX,
|
||||
OPCODE_EDGEFLAG,
|
||||
OPCODE_BEGIN,
|
||||
OPCODE_END,
|
||||
OPCODE_RECTF,
|
||||
@@ -4476,7 +4474,7 @@ save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
|
||||
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
|
||||
|
||||
if (count > 0) {
|
||||
unsigned i;
|
||||
GLint i;
|
||||
const GLfloat * p = params;
|
||||
|
||||
for (i = 0 ; i < count ; i++) {
|
||||
@@ -4710,7 +4708,7 @@ save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
|
||||
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
|
||||
|
||||
if (count > 0) {
|
||||
unsigned i;
|
||||
GLint i;
|
||||
const GLfloat * p = params;
|
||||
|
||||
for (i = 0 ; i < count ; i++) {
|
||||
@@ -5110,45 +5108,19 @@ save_EvalPoint2(GLint x, GLint y)
|
||||
static void GLAPIENTRY
|
||||
save_Indexf(GLfloat x)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
Node *n;
|
||||
SAVE_FLUSH_VERTICES(ctx);
|
||||
n = ALLOC_INSTRUCTION(ctx, OPCODE_INDEX, 1);
|
||||
if (n) {
|
||||
n[1].f = x;
|
||||
}
|
||||
|
||||
ctx->ListState.ActiveIndex = 1;
|
||||
ctx->ListState.CurrentIndex = x;
|
||||
|
||||
if (ctx->ExecuteFlag) {
|
||||
CALL_Indexf(ctx->Exec, (x));
|
||||
}
|
||||
save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x);
|
||||
}
|
||||
|
||||
static void GLAPIENTRY
|
||||
save_Indexfv(const GLfloat * v)
|
||||
{
|
||||
save_Indexf(v[0]);
|
||||
save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]);
|
||||
}
|
||||
|
||||
static void GLAPIENTRY
|
||||
save_EdgeFlag(GLboolean x)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
Node *n;
|
||||
SAVE_FLUSH_VERTICES(ctx);
|
||||
n = ALLOC_INSTRUCTION(ctx, OPCODE_EDGEFLAG, 1);
|
||||
if (n) {
|
||||
n[1].b = x;
|
||||
}
|
||||
|
||||
ctx->ListState.ActiveEdgeFlag = 1;
|
||||
ctx->ListState.CurrentEdgeFlag = x;
|
||||
|
||||
if (ctx->ExecuteFlag) {
|
||||
CALL_EdgeFlag(ctx->Exec, (x));
|
||||
}
|
||||
save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? 1.0 : 0.0);
|
||||
}
|
||||
|
||||
static void GLAPIENTRY
|
||||
@@ -6602,12 +6574,6 @@ execute_list(GLcontext *ctx, GLuint list)
|
||||
CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f));
|
||||
}
|
||||
break;
|
||||
case OPCODE_INDEX:
|
||||
CALL_Indexf(ctx->Exec, (n[1].f));
|
||||
break;
|
||||
case OPCODE_EDGEFLAG:
|
||||
CALL_EdgeFlag(ctx->Exec, (n[1].b));
|
||||
break;
|
||||
case OPCODE_BEGIN:
|
||||
CALL_Begin(ctx->Exec, (n[1].e));
|
||||
break;
|
||||
@@ -6793,9 +6759,6 @@ _mesa_NewList(GLuint list, GLenum mode)
|
||||
for (i = 0; i < MAT_ATTRIB_MAX; i++)
|
||||
ctx->ListState.ActiveMaterialSize[i] = 0;
|
||||
|
||||
ctx->ListState.ActiveIndex = 0;
|
||||
ctx->ListState.ActiveEdgeFlag = 0;
|
||||
|
||||
ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
|
||||
ctx->Driver.NewList(ctx, list, mode);
|
||||
|
||||
@@ -8421,12 +8384,6 @@ print_list(GLcontext *ctx, GLuint list)
|
||||
_mesa_printf("MATERIAL %x %x: %f %f %f %f\n",
|
||||
n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
|
||||
break;
|
||||
case OPCODE_INDEX:
|
||||
_mesa_printf("INDEX: %f\n", n[1].f);
|
||||
break;
|
||||
case OPCODE_EDGEFLAG:
|
||||
_mesa_printf("EDGEFLAG: %d\n", n[1].i);
|
||||
break;
|
||||
case OPCODE_BEGIN:
|
||||
_mesa_printf("BEGIN %x\n", n[1].i);
|
||||
break;
|
||||
|
||||
@@ -49,11 +49,14 @@
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper to enable/disable client-side state.
|
||||
*/
|
||||
static void
|
||||
client_state(GLcontext *ctx, GLenum cap, GLboolean state)
|
||||
{
|
||||
GLuint flag;
|
||||
GLuint *var;
|
||||
GLboolean *var;
|
||||
|
||||
switch (cap) {
|
||||
case GL_VERTEX_ARRAY:
|
||||
@@ -134,17 +137,14 @@ client_state( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
ctx->Array.ArrayObj->_Enabled &= ~flag;
|
||||
|
||||
if (ctx->Driver.Enable) {
|
||||
(*ctx->Driver.Enable)( ctx, cap, state );
|
||||
ctx->Driver.Enable( ctx, cap, state );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable GL capability.
|
||||
*
|
||||
* \param cap capability.
|
||||
*
|
||||
* \sa glEnable().
|
||||
* \param cap state to enable/disable.
|
||||
*
|
||||
* Get's the current context, assures that we're outside glBegin()/glEnd() and
|
||||
* calls client_state().
|
||||
@@ -160,10 +160,7 @@ _mesa_EnableClientState( GLenum cap )
|
||||
|
||||
/**
|
||||
* Disable GL capability.
|
||||
*
|
||||
* \param cap capability.
|
||||
*
|
||||
* \sa glDisable().
|
||||
* \param cap state to enable/disable.
|
||||
*
|
||||
* Get's the current context, assures that we're outside glBegin()/glEnd() and
|
||||
* calls client_state().
|
||||
@@ -195,10 +192,10 @@ _mesa_DisableClientState( GLenum cap )
|
||||
|
||||
|
||||
/**
|
||||
* Perform glEnable() and glDisable() calls.
|
||||
* Helper function to enable or disable state.
|
||||
*
|
||||
* \param ctx GL context.
|
||||
* \param cap capability.
|
||||
* \param cap the state to enable/disable
|
||||
* \param state whether to enable or disable the specified capability.
|
||||
*
|
||||
* Updates the current context and flushes the vertices as needed. For
|
||||
@@ -206,7 +203,8 @@ _mesa_DisableClientState( GLenum cap )
|
||||
* are effectivly present before updating. Notifies the driver via
|
||||
* dd_function_table::Enable.
|
||||
*/
|
||||
void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
void
|
||||
_mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
|
||||
{
|
||||
if (MESA_VERBOSE & VERBOSE_API)
|
||||
_mesa_debug(ctx, "%s %s (newstate is %x)\n",
|
||||
@@ -285,7 +283,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
FLUSH_VERTICES(ctx, _NEW_POLYGON);
|
||||
ctx->Polygon.CullFlag = state;
|
||||
break;
|
||||
|
||||
case GL_CULL_VERTEX_EXT:
|
||||
CHECK_EXTENSION(EXT_cull_vertex, cap);
|
||||
if (ctx->Transform.CullVertexFlag == state)
|
||||
@@ -293,7 +290,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
|
||||
ctx->Transform.CullVertexFlag = state;
|
||||
break;
|
||||
|
||||
case GL_DEPTH_TEST:
|
||||
if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
|
||||
_mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
|
||||
@@ -351,26 +347,18 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_LIGHT);
|
||||
ctx->Light.Enabled = state;
|
||||
|
||||
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
|
||||
ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
|
||||
else
|
||||
ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
|
||||
|
||||
break;
|
||||
case GL_LINE_SMOOTH:
|
||||
if (ctx->Line.SmoothFlag == state)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_LINE);
|
||||
ctx->Line.SmoothFlag = state;
|
||||
ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
|
||||
break;
|
||||
case GL_LINE_STIPPLE:
|
||||
if (ctx->Line.StippleFlag == state)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_LINE);
|
||||
ctx->Line.StippleFlag = state;
|
||||
ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
|
||||
break;
|
||||
case GL_INDEX_LOGIC_OP:
|
||||
if (ctx->Color.IndexLogicOpEnabled == state)
|
||||
@@ -509,21 +497,18 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_POINT);
|
||||
ctx->Point.SmoothFlag = state;
|
||||
ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
|
||||
break;
|
||||
case GL_POLYGON_SMOOTH:
|
||||
if (ctx->Polygon.SmoothFlag == state)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_POLYGON);
|
||||
ctx->Polygon.SmoothFlag = state;
|
||||
ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
|
||||
break;
|
||||
case GL_POLYGON_STIPPLE:
|
||||
if (ctx->Polygon.StippleFlag == state)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_POLYGON);
|
||||
ctx->Polygon.StippleFlag = state;
|
||||
ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
|
||||
break;
|
||||
case GL_POLYGON_OFFSET_POINT:
|
||||
if (ctx->Polygon.OffsetPoint == state)
|
||||
@@ -678,24 +663,24 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
/* GL_SGI_color_table */
|
||||
case GL_COLOR_TABLE_SGI:
|
||||
CHECK_EXTENSION(SGI_color_table, cap);
|
||||
if (ctx->Pixel.ColorTableEnabled == state)
|
||||
if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_PIXEL);
|
||||
ctx->Pixel.ColorTableEnabled = state;
|
||||
ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state;
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
|
||||
CHECK_EXTENSION(SGI_color_table, cap);
|
||||
if (ctx->Pixel.PostConvolutionColorTableEnabled == state)
|
||||
if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_PIXEL);
|
||||
ctx->Pixel.PostConvolutionColorTableEnabled = state;
|
||||
ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state;
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
|
||||
CHECK_EXTENSION(SGI_color_table, cap);
|
||||
if (ctx->Pixel.PostColorMatrixColorTableEnabled == state)
|
||||
if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_PIXEL);
|
||||
ctx->Pixel.PostColorMatrixColorTableEnabled = state;
|
||||
ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state;
|
||||
break;
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
CHECK_EXTENSION(SGI_texture_color_table, cap);
|
||||
@@ -916,11 +901,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_STENCIL);
|
||||
ctx->Stencil.TestTwoSide = state;
|
||||
if (state) {
|
||||
ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
|
||||
} else {
|
||||
ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL;
|
||||
}
|
||||
break;
|
||||
|
||||
#if FEATURE_ARB_fragment_program
|
||||
@@ -973,20 +953,14 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
}
|
||||
|
||||
if (ctx->Driver.Enable) {
|
||||
(*ctx->Driver.Enable)( ctx, cap, state );
|
||||
ctx->Driver.Enable( ctx, cap, state );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable GL capability.
|
||||
*
|
||||
* \param cap capability.
|
||||
*
|
||||
* \sa glEnable().
|
||||
*
|
||||
* Get's the current context, assures that we're outside glBegin()/glEnd() and
|
||||
* calls _mesa_set_enable().
|
||||
* Enable GL capability. Called by glEnable()
|
||||
* \param cap state to enable.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
_mesa_Enable( GLenum cap )
|
||||
@@ -999,14 +973,8 @@ _mesa_Enable( GLenum cap )
|
||||
|
||||
|
||||
/**
|
||||
* Disable GL capability.
|
||||
*
|
||||
* \param cap capability.
|
||||
*
|
||||
* \sa glDisable().
|
||||
*
|
||||
* Get's the current context, assures that we're outside glBegin()/glEnd() and
|
||||
* calls _mesa_set_enable().
|
||||
* Disable GL capability. Called by glDisable()
|
||||
* \param cap state to disable.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
_mesa_Disable( GLenum cap )
|
||||
@@ -1032,10 +1000,11 @@ _mesa_Disable( GLenum cap )
|
||||
return GL_FALSE; \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test whether a capability is enabled.
|
||||
* Return simple enable/disable state.
|
||||
*
|
||||
* \param cap capability.
|
||||
* \param cap state variable to query.
|
||||
*
|
||||
* Returns the state of the specified capability from the current GL context.
|
||||
* For the capabilities associated with extensions verifies that those
|
||||
@@ -1223,13 +1192,13 @@ _mesa_IsEnabled( GLenum cap )
|
||||
/* GL_SGI_color_table */
|
||||
case GL_COLOR_TABLE_SGI:
|
||||
CHECK_EXTENSION(SGI_color_table);
|
||||
return ctx->Pixel.ColorTableEnabled;
|
||||
return ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION];
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
|
||||
CHECK_EXTENSION(SGI_color_table);
|
||||
return ctx->Pixel.PostConvolutionColorTableEnabled;
|
||||
return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION];
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
|
||||
CHECK_EXTENSION(SGI_color_table);
|
||||
return ctx->Pixel.PostColorMatrixColorTableEnabled;
|
||||
return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX];
|
||||
|
||||
/* GL_SGI_texture_color_table */
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
|
||||
@@ -1003,7 +1003,7 @@ LONGSTRING static const char enum_string_table[] =
|
||||
"GL_NOTEQUAL\0"
|
||||
"GL_NO_ERROR\0"
|
||||
"GL_NUM_COMPRESSED_TEXTURE_FORMATS\0"
|
||||
"GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB\0"
|
||||
"GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB\0"
|
||||
"GL_OBJECT_ACTIVE_ATTRIBUTES_ARB\0"
|
||||
"GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\0"
|
||||
"GL_OBJECT_ACTIVE_UNIFORMS_ARB\0"
|
||||
@@ -2744,7 +2744,7 @@ static const enum_elt all_enums[1737] =
|
||||
{ 20205, 0x00000205 }, /* GL_NOTEQUAL */
|
||||
{ 20217, 0x00000000 }, /* GL_NO_ERROR */
|
||||
{ 20229, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
|
||||
{ 20263, 0x000086A2 }, /* GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB */
|
||||
{ 20263, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */
|
||||
{ 20301, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
|
||||
{ 20333, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
|
||||
{ 20375, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
|
||||
@@ -3517,7 +3517,6 @@ static const enum_elt all_enums[1737] =
|
||||
|
||||
static const unsigned reduced_enums[1277] =
|
||||
{
|
||||
30, /* GL_ALL_CLIENT_ATTRIB_BITS */
|
||||
435, /* GL_FALSE */
|
||||
643, /* GL_LINES */
|
||||
645, /* GL_LINE_LOOP */
|
||||
@@ -4794,6 +4793,7 @@ static const unsigned reduced_enums[1277] =
|
||||
1314, /* GL_SCISSOR_BIT */
|
||||
29, /* GL_ALL_ATTRIB_BITS */
|
||||
938, /* GL_MULTISAMPLE_BIT */
|
||||
30, /* GL_ALL_CLIENT_ATTRIB_BITS */
|
||||
};
|
||||
|
||||
#define Elements(x) sizeof(x)/sizeof(*x)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
|
||||
|
||||
#if defined(__linux__) && !defined(XFree86Server)
|
||||
#if defined(__linux__)
|
||||
|
||||
/*
|
||||
* Allocate a large block of memory which can hold code then dole it out
|
||||
|
||||
@@ -136,6 +136,7 @@ static const struct {
|
||||
{ OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
|
||||
{ OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)},
|
||||
{ OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)},
|
||||
{ OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)},
|
||||
{ OFF, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) },
|
||||
{ ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) },
|
||||
{ OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
|
||||
@@ -198,6 +199,9 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
|
||||
#endif
|
||||
#if FEATURE_ARB_shading_language_100
|
||||
ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
|
||||
#endif
|
||||
#if FEATURE_ARB_shading_language_120
|
||||
ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
|
||||
#endif
|
||||
ctx->Extensions.ARB_shadow = GL_TRUE;
|
||||
ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
|
||||
@@ -223,6 +227,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
|
||||
#endif
|
||||
ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
|
||||
ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
|
||||
ctx->Extensions.ATI_separate_stencil = GL_TRUE;
|
||||
ctx->Extensions.EXT_blend_color = GL_TRUE;
|
||||
ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
|
||||
ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
|
||||
@@ -409,7 +414,9 @@ _mesa_enable_2_1_extensions(GLcontext *ctx)
|
||||
#if FEATURE_EXT_texture_sRGB
|
||||
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
|
||||
#endif
|
||||
/* plus: shading language extensions, non-square uniform matrices */
|
||||
#ifdef FEATURE_ARB_shading_language_120
|
||||
ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -165,11 +165,7 @@ _mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
|
||||
if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) {
|
||||
ASSERT(att->Renderbuffer);
|
||||
ASSERT(!att->Texture);
|
||||
att->Renderbuffer->RefCount--;
|
||||
if (att->Renderbuffer->RefCount == 0) {
|
||||
att->Renderbuffer->Delete(att->Renderbuffer);
|
||||
}
|
||||
att->Renderbuffer = NULL;
|
||||
_mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
|
||||
}
|
||||
att->Type = GL_NONE;
|
||||
att->Complete = GL_TRUE;
|
||||
@@ -228,10 +224,9 @@ _mesa_set_renderbuffer_attachment(GLcontext *ctx,
|
||||
/* XXX check if re-doing same attachment, exit early */
|
||||
_mesa_remove_attachment(ctx, att);
|
||||
att->Type = GL_RENDERBUFFER_EXT;
|
||||
att->Renderbuffer = rb;
|
||||
att->Texture = NULL; /* just to be safe */
|
||||
att->Complete = GL_FALSE;
|
||||
rb->RefCount++;
|
||||
_mesa_reference_renderbuffer(&att->Renderbuffer, rb);
|
||||
}
|
||||
|
||||
|
||||
@@ -246,12 +241,9 @@ _mesa_framebuffer_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
|
||||
struct gl_renderbuffer_attachment *att;
|
||||
|
||||
_glthread_LOCK_MUTEX(fb->Mutex);
|
||||
if (rb)
|
||||
_glthread_LOCK_MUTEX(rb->Mutex);
|
||||
|
||||
att = _mesa_get_attachment(ctx, fb, attachment);
|
||||
ASSERT(att);
|
||||
|
||||
if (rb) {
|
||||
_mesa_set_renderbuffer_attachment(ctx, att, rb);
|
||||
}
|
||||
@@ -259,8 +251,6 @@ _mesa_framebuffer_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
|
||||
_mesa_remove_attachment(ctx, att);
|
||||
}
|
||||
|
||||
if (rb)
|
||||
_glthread_UNLOCK_MUTEX(rb->Mutex);
|
||||
_glthread_UNLOCK_MUTEX(fb->Mutex);
|
||||
}
|
||||
|
||||
@@ -559,7 +549,7 @@ _mesa_IsRenderbufferEXT(GLuint renderbuffer)
|
||||
void GLAPIENTRY
|
||||
_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
|
||||
{
|
||||
struct gl_renderbuffer *newRb, *oldRb;
|
||||
struct gl_renderbuffer *newRb;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
@@ -593,21 +583,16 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
|
||||
}
|
||||
ASSERT(newRb->AllocStorage);
|
||||
_mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb);
|
||||
newRb->RefCount = 1; /* referenced by hash table */
|
||||
}
|
||||
newRb->RefCount++;
|
||||
}
|
||||
else {
|
||||
newRb = NULL;
|
||||
}
|
||||
|
||||
oldRb = ctx->CurrentRenderbuffer;
|
||||
if (oldRb) {
|
||||
_mesa_dereference_renderbuffer(&oldRb);
|
||||
}
|
||||
|
||||
ASSERT(newRb != &DummyRenderbuffer);
|
||||
|
||||
ctx->CurrentRenderbuffer = newRb;
|
||||
_mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb);
|
||||
}
|
||||
|
||||
|
||||
@@ -632,14 +617,15 @@ _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers)
|
||||
_mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
|
||||
}
|
||||
|
||||
/* remove from hash table immediately, to free the ID */
|
||||
/* Remove from hash table immediately, to free the ID.
|
||||
* But the object will not be freed until it's no longer
|
||||
* referenced anywhere else.
|
||||
*/
|
||||
_mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]);
|
||||
|
||||
if (rb != &DummyRenderbuffer) {
|
||||
/* But the object will not be freed until it's no longer
|
||||
* bound in any context.
|
||||
*/
|
||||
_mesa_dereference_renderbuffer(&rb);
|
||||
/* no longer referenced by hash table */
|
||||
_mesa_reference_renderbuffer(&rb, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -938,7 +924,7 @@ check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb)
|
||||
void GLAPIENTRY
|
||||
_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
|
||||
{
|
||||
struct gl_framebuffer *newFb, *oldFb;
|
||||
struct gl_framebuffer *newFb;
|
||||
GLboolean bindReadBuf, bindDrawBuf;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
@@ -998,12 +984,6 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
|
||||
}
|
||||
_mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb);
|
||||
}
|
||||
_glthread_LOCK_MUTEX(newFb->Mutex);
|
||||
if (bindReadBuf)
|
||||
newFb->RefCount++;
|
||||
if (bindDrawBuf)
|
||||
newFb->RefCount++;
|
||||
_glthread_UNLOCK_MUTEX(newFb->Mutex);
|
||||
}
|
||||
else {
|
||||
/* Binding the window system framebuffer (which was originally set
|
||||
@@ -1020,22 +1000,14 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
|
||||
*/
|
||||
|
||||
if (bindReadBuf) {
|
||||
oldFb = ctx->ReadBuffer;
|
||||
if (oldFb && oldFb->Name != 0) {
|
||||
_mesa_dereference_framebuffer(&oldFb);
|
||||
}
|
||||
ctx->ReadBuffer = newFb;
|
||||
_mesa_reference_framebuffer(&ctx->ReadBuffer, newFb);
|
||||
}
|
||||
|
||||
if (bindDrawBuf) {
|
||||
oldFb = ctx->DrawBuffer;
|
||||
if (oldFb && oldFb->Name != 0) {
|
||||
/* check if old FB had any texture attachments */
|
||||
check_end_texture_render(ctx, oldFb);
|
||||
check_end_texture_render(ctx, ctx->DrawBuffer);
|
||||
/* check if time to delete this framebuffer */
|
||||
_mesa_dereference_framebuffer(&oldFb);
|
||||
}
|
||||
ctx->DrawBuffer = newFb;
|
||||
_mesa_reference_framebuffer(&ctx->DrawBuffer, newFb);
|
||||
if (newFb->Name != 0) {
|
||||
/* check if newly bound framebuffer has any texture attachments */
|
||||
check_begin_texture_render(ctx, newFb);
|
||||
@@ -1083,7 +1055,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
|
||||
/* But the object will not be freed until it's no longer
|
||||
* bound in any context.
|
||||
*/
|
||||
_mesa_dereference_framebuffer(&fb);
|
||||
_mesa_unreference_framebuffer(&fb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,42 +69,6 @@ compute_depth_max(struct gl_framebuffer *fb)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the framebuffer's _DepthBuffer field, taking care of
|
||||
* reference counts, etc.
|
||||
*/
|
||||
static void
|
||||
set_depth_renderbuffer(struct gl_framebuffer *fb,
|
||||
struct gl_renderbuffer *rb)
|
||||
{
|
||||
if (fb->_DepthBuffer) {
|
||||
_mesa_dereference_renderbuffer(&fb->_DepthBuffer);
|
||||
}
|
||||
fb->_DepthBuffer = rb;
|
||||
if (rb) {
|
||||
rb->RefCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the framebuffer's _StencilBuffer field, taking care of
|
||||
* reference counts, etc.
|
||||
*/
|
||||
static void
|
||||
set_stencil_renderbuffer(struct gl_framebuffer *fb,
|
||||
struct gl_renderbuffer *rb)
|
||||
{
|
||||
if (fb->_StencilBuffer) {
|
||||
_mesa_dereference_renderbuffer(&fb->_StencilBuffer);
|
||||
}
|
||||
fb->_StencilBuffer = rb;
|
||||
if (rb) {
|
||||
rb->RefCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create and initialize a gl_framebuffer object.
|
||||
* This is intended for creating _window_system_ framebuffers, not generic
|
||||
@@ -166,6 +130,8 @@ _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual)
|
||||
|
||||
_glthread_INIT_MUTEX(fb->Mutex);
|
||||
|
||||
fb->RefCount = 1;
|
||||
|
||||
/* save the visual */
|
||||
fb->Visual = *visual;
|
||||
|
||||
@@ -198,7 +164,6 @@ void
|
||||
_mesa_destroy_framebuffer(struct gl_framebuffer *fb)
|
||||
{
|
||||
if (fb) {
|
||||
_glthread_DESTROY_MUTEX(fb->Mutex);
|
||||
_mesa_free_framebuffer_data(fb);
|
||||
_mesa_free(fb);
|
||||
}
|
||||
@@ -215,48 +180,81 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb)
|
||||
GLuint i;
|
||||
|
||||
assert(fb);
|
||||
assert(fb->RefCount == 0);
|
||||
|
||||
_glthread_DESTROY_MUTEX(fb->Mutex);
|
||||
|
||||
for (i = 0; i < BUFFER_COUNT; i++) {
|
||||
struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
|
||||
if (att->Renderbuffer) {
|
||||
struct gl_renderbuffer *rb = att->Renderbuffer;
|
||||
/* remove framebuffer's reference to renderbuffer */
|
||||
_mesa_dereference_renderbuffer(&rb);
|
||||
if (rb && rb->Name == 0) {
|
||||
/* delete window system renderbuffer */
|
||||
_mesa_dereference_renderbuffer(&rb);
|
||||
_mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
|
||||
}
|
||||
if (att->Texture) {
|
||||
/* render to texture */
|
||||
att->Texture->RefCount--;
|
||||
if (att->Texture->RefCount == 0) {
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
if (ctx) {
|
||||
ctx->Driver.DeleteTexture(ctx, att->Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
att->Type = GL_NONE;
|
||||
att->Renderbuffer = NULL;
|
||||
att->Texture = NULL;
|
||||
}
|
||||
|
||||
/* unbind depth/stencil to decr ref counts */
|
||||
set_depth_renderbuffer(fb, NULL);
|
||||
set_stencil_renderbuffer(fb, NULL);
|
||||
/* unbind _Depth/_StencilBuffer to decr ref counts */
|
||||
_mesa_reference_renderbuffer(&fb->_DepthBuffer, NULL);
|
||||
_mesa_reference_renderbuffer(&fb->_StencilBuffer, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrement the reference count on a framebuffer and delete it when
|
||||
* the refcount hits zero.
|
||||
* Note: we pass the address of a pointer and set it to NULL if we delete it.
|
||||
* Set *ptr to point to fb, with refcounting and locking.
|
||||
*/
|
||||
void
|
||||
_mesa_dereference_framebuffer(struct gl_framebuffer **fb)
|
||||
_mesa_reference_framebuffer(struct gl_framebuffer **ptr,
|
||||
struct gl_framebuffer *fb)
|
||||
{
|
||||
assert(ptr);
|
||||
if (*ptr == fb) {
|
||||
/* no change */
|
||||
return;
|
||||
}
|
||||
if (*ptr) {
|
||||
_mesa_unreference_framebuffer(ptr);
|
||||
}
|
||||
assert(!*ptr);
|
||||
assert(fb);
|
||||
_glthread_LOCK_MUTEX(fb->Mutex);
|
||||
fb->RefCount++;
|
||||
_glthread_UNLOCK_MUTEX(fb->Mutex);
|
||||
*ptr = fb;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undo/remove a reference to a framebuffer object.
|
||||
* Decrement the framebuffer object's reference count and delete it when
|
||||
* the refcount hits zero.
|
||||
* Note: we pass the address of a pointer and set it to NULL.
|
||||
*/
|
||||
void
|
||||
_mesa_unreference_framebuffer(struct gl_framebuffer **fb)
|
||||
{
|
||||
assert(fb);
|
||||
if (*fb) {
|
||||
GLboolean deleteFlag = GL_FALSE;
|
||||
|
||||
_glthread_LOCK_MUTEX((*fb)->Mutex);
|
||||
{
|
||||
ASSERT((*fb)->RefCount > 0);
|
||||
(*fb)->RefCount--;
|
||||
deleteFlag = ((*fb)->RefCount == 0);
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX((*fb)->Mutex);
|
||||
|
||||
if (deleteFlag) {
|
||||
if (deleteFlag)
|
||||
(*fb)->Delete(*fb);
|
||||
|
||||
*fb = NULL;
|
||||
}
|
||||
}
|
||||
@@ -535,13 +533,13 @@ _mesa_update_depth_buffer(GLcontext *ctx,
|
||||
/* need to update wrapper */
|
||||
struct gl_renderbuffer *wrapper
|
||||
= _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb);
|
||||
set_depth_renderbuffer(fb, wrapper);
|
||||
_mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper);
|
||||
ASSERT(fb->_DepthBuffer->Wrapped == depthRb);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* depthRb may be null */
|
||||
set_depth_renderbuffer(fb, depthRb);
|
||||
_mesa_reference_renderbuffer(&fb->_DepthBuffer, depthRb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,13 +574,13 @@ _mesa_update_stencil_buffer(GLcontext *ctx,
|
||||
/* need to update wrapper */
|
||||
struct gl_renderbuffer *wrapper
|
||||
= _mesa_new_s8_renderbuffer_wrapper(ctx, stencilRb);
|
||||
set_stencil_renderbuffer(fb, wrapper);
|
||||
_mesa_reference_renderbuffer(&fb->_StencilBuffer, wrapper);
|
||||
ASSERT(fb->_StencilBuffer->Wrapped == stencilRb);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* stencilRb may be null */
|
||||
set_stencil_renderbuffer(fb, stencilRb);
|
||||
_mesa_reference_renderbuffer(&fb->_StencilBuffer, stencilRb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,6 +603,7 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb)
|
||||
GLbitfield bufferMask = fb->_ColorDrawBufferMask[output];
|
||||
GLuint count = 0;
|
||||
GLuint i;
|
||||
if (!fb->DeletePending) {
|
||||
/* We need the inner loop here because glDrawBuffer(GL_FRONT_AND_BACK)
|
||||
* can specify writing to two or four color buffers (for example).
|
||||
*/
|
||||
@@ -612,16 +611,19 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb)
|
||||
const GLuint bufferBit = 1 << i;
|
||||
if (bufferBit & bufferMask) {
|
||||
struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
|
||||
if (rb) {
|
||||
if (rb && rb->Width > 0 && rb->Height > 0) {
|
||||
fb->_ColorDrawBuffers[output][count] = rb;
|
||||
count++;
|
||||
}
|
||||
else {
|
||||
/*_mesa_warning(ctx, "DrawBuffer names a missing buffer!\n");*/
|
||||
/*
|
||||
_mesa_warning(ctx, "DrawBuffer names a missing buffer!\n");
|
||||
*/
|
||||
}
|
||||
bufferMask &= ~bufferBit;
|
||||
}
|
||||
}
|
||||
}
|
||||
fb->_NumColorDrawBuffers[output] = count;
|
||||
}
|
||||
}
|
||||
@@ -635,7 +637,10 @@ static void
|
||||
update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
|
||||
{
|
||||
(void) ctx;
|
||||
if (fb->_ColorReadBufferIndex == -1) {
|
||||
if (fb->_ColorReadBufferIndex == -1 ||
|
||||
fb->DeletePending ||
|
||||
fb->Width == 0 ||
|
||||
fb->Height == 0) {
|
||||
fb->_ColorReadBuffer = NULL; /* legal! */
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -43,7 +43,11 @@ extern void
|
||||
_mesa_free_framebuffer_data(struct gl_framebuffer *buffer);
|
||||
|
||||
extern void
|
||||
_mesa_dereference_framebuffer(struct gl_framebuffer **fb);
|
||||
_mesa_reference_framebuffer(struct gl_framebuffer **ptr,
|
||||
struct gl_framebuffer *fb);
|
||||
|
||||
extern void
|
||||
_mesa_unreference_framebuffer(struct gl_framebuffer **fb);
|
||||
|
||||
extern void
|
||||
_mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb,
|
||||
|
||||
@@ -323,7 +323,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
|
||||
case GL_EDGE_FLAG:
|
||||
{
|
||||
FLUSH_CURRENT(ctx, 0);
|
||||
params[0] = ctx->Current.EdgeFlag;
|
||||
params[0] = (ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0);
|
||||
}
|
||||
break;
|
||||
case GL_FEEDBACK_BUFFER_SIZE:
|
||||
@@ -677,34 +677,34 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
|
||||
params[0] = ENUM_TO_BOOLEAN(ctx->Hint.PerspectiveCorrection);
|
||||
break;
|
||||
case GL_PIXEL_MAP_A_TO_A_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapAtoAsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.AtoA.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_B_TO_B_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapBtoBsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.BtoB.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_G_TO_G_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapGtoGsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.GtoG.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_A_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoAsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoA.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_B_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoBsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoB.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_G_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoGsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoG.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_I_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoIsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoI.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_R_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoRsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoR.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_R_TO_R_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapRtoRsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.RtoR.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_S_TO_S_SIZE:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapStoSsize);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.StoS.Size);
|
||||
break;
|
||||
case GL_POINT_SIZE:
|
||||
params[0] = FLOAT_TO_BOOLEAN(ctx->Point.Size);
|
||||
@@ -1283,15 +1283,15 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
|
||||
break;
|
||||
case GL_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_color_table, "GetBooleanv");
|
||||
params[0] = ctx->Pixel.ColorTableEnabled;
|
||||
params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION];
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_color_table, "GetBooleanv");
|
||||
params[0] = ctx->Pixel.PostConvolutionColorTableEnabled;
|
||||
params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION];
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_color_table, "GetBooleanv");
|
||||
params[0] = ctx->Pixel.PostColorMatrixColorTableEnabled;
|
||||
params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX];
|
||||
break;
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_texture_color_table, "GetBooleanv");
|
||||
@@ -1878,7 +1878,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
|
||||
break;
|
||||
case GL_MAX_VARYING_FLOATS_ARB:
|
||||
CHECK_EXT1(ARB_vertex_shader, "GetBooleanv");
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Const.MaxVaryingFloats);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Const.MaxVarying * 4);
|
||||
break;
|
||||
case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB:
|
||||
CHECK_EXT1(ARB_vertex_shader, "GetBooleanv");
|
||||
@@ -1888,6 +1888,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
|
||||
CHECK_EXT1(ARB_vertex_shader, "GetBooleanv");
|
||||
params[0] = INT_TO_BOOLEAN(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
|
||||
break;
|
||||
case GL_CURRENT_PROGRAM:
|
||||
CHECK_EXT1(ARB_shader_objects, "GetBooleanv");
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0);
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname);
|
||||
}
|
||||
@@ -2150,7 +2154,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
|
||||
case GL_EDGE_FLAG:
|
||||
{
|
||||
FLUSH_CURRENT(ctx, 0);
|
||||
params[0] = BOOLEAN_TO_FLOAT(ctx->Current.EdgeFlag);
|
||||
params[0] = BOOLEAN_TO_FLOAT((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0));
|
||||
}
|
||||
break;
|
||||
case GL_FEEDBACK_BUFFER_SIZE:
|
||||
@@ -2504,34 +2508,34 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
|
||||
params[0] = ENUM_TO_FLOAT(ctx->Hint.PerspectiveCorrection);
|
||||
break;
|
||||
case GL_PIXEL_MAP_A_TO_A_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapAtoAsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.AtoA.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_B_TO_B_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapBtoBsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.BtoB.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_G_TO_G_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapGtoGsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.GtoG.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_A_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapItoAsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.ItoA.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_B_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapItoBsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.ItoB.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_G_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapItoGsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.ItoG.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_I_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapItoIsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.ItoI.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_R_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapItoRsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.ItoR.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_R_TO_R_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapRtoRsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.RtoR.Size);
|
||||
break;
|
||||
case GL_PIXEL_MAP_S_TO_S_SIZE:
|
||||
params[0] = (GLfloat)(ctx->Pixel.MapStoSsize);
|
||||
params[0] = (GLfloat)(ctx->PixelMaps.StoS.Size);
|
||||
break;
|
||||
case GL_POINT_SIZE:
|
||||
params[0] = ctx->Point.Size;
|
||||
@@ -3110,15 +3114,15 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
|
||||
break;
|
||||
case GL_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_color_table, "GetFloatv");
|
||||
params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled);
|
||||
params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]);
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_color_table, "GetFloatv");
|
||||
params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PostConvolutionColorTableEnabled);
|
||||
params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]);
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_color_table, "GetFloatv");
|
||||
params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PostColorMatrixColorTableEnabled);
|
||||
params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]);
|
||||
break;
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_texture_color_table, "GetFloatv");
|
||||
@@ -3705,7 +3709,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
|
||||
break;
|
||||
case GL_MAX_VARYING_FLOATS_ARB:
|
||||
CHECK_EXT1(ARB_vertex_shader, "GetFloatv");
|
||||
params[0] = (GLfloat)(ctx->Const.MaxVaryingFloats);
|
||||
params[0] = (GLfloat)(ctx->Const.MaxVarying * 4);
|
||||
break;
|
||||
case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB:
|
||||
CHECK_EXT1(ARB_vertex_shader, "GetFloatv");
|
||||
@@ -3715,6 +3719,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
|
||||
CHECK_EXT1(ARB_vertex_shader, "GetFloatv");
|
||||
params[0] = (GLfloat)(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
|
||||
break;
|
||||
case GL_CURRENT_PROGRAM:
|
||||
CHECK_EXT1(ARB_shader_objects, "GetFloatv");
|
||||
params[0] = (GLfloat)(ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0);
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname);
|
||||
}
|
||||
@@ -3977,7 +3985,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
|
||||
case GL_EDGE_FLAG:
|
||||
{
|
||||
FLUSH_CURRENT(ctx, 0);
|
||||
params[0] = BOOLEAN_TO_INT(ctx->Current.EdgeFlag);
|
||||
params[0] = BOOLEAN_TO_INT((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0));
|
||||
}
|
||||
break;
|
||||
case GL_FEEDBACK_BUFFER_SIZE:
|
||||
@@ -4331,34 +4339,34 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
|
||||
params[0] = ENUM_TO_INT(ctx->Hint.PerspectiveCorrection);
|
||||
break;
|
||||
case GL_PIXEL_MAP_A_TO_A_SIZE:
|
||||
params[0] = ctx->Pixel.MapAtoAsize;
|
||||
params[0] = ctx->PixelMaps.AtoA.Size;
|
||||
break;
|
||||
case GL_PIXEL_MAP_B_TO_B_SIZE:
|
||||
params[0] = ctx->Pixel.MapBtoBsize;
|
||||
params[0] = ctx->PixelMaps.BtoB.Size;
|
||||
break;
|
||||
case GL_PIXEL_MAP_G_TO_G_SIZE:
|
||||
params[0] = ctx->Pixel.MapGtoGsize;
|
||||
params[0] = ctx->PixelMaps.GtoG.Size;
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_A_SIZE:
|
||||
params[0] = ctx->Pixel.MapItoAsize;
|
||||
params[0] = ctx->PixelMaps.ItoA.Size;
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_B_SIZE:
|
||||
params[0] = ctx->Pixel.MapItoBsize;
|
||||
params[0] = ctx->PixelMaps.ItoB.Size;
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_G_SIZE:
|
||||
params[0] = ctx->Pixel.MapItoGsize;
|
||||
params[0] = ctx->PixelMaps.ItoG.Size;
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_I_SIZE:
|
||||
params[0] = ctx->Pixel.MapItoIsize;
|
||||
params[0] = ctx->PixelMaps.ItoI.Size;
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_R_SIZE:
|
||||
params[0] = ctx->Pixel.MapItoRsize;
|
||||
params[0] = ctx->PixelMaps.ItoR.Size;
|
||||
break;
|
||||
case GL_PIXEL_MAP_R_TO_R_SIZE:
|
||||
params[0] = ctx->Pixel.MapRtoRsize;
|
||||
params[0] = ctx->PixelMaps.RtoR.Size;
|
||||
break;
|
||||
case GL_PIXEL_MAP_S_TO_S_SIZE:
|
||||
params[0] = ctx->Pixel.MapStoSsize;
|
||||
params[0] = ctx->PixelMaps.StoS.Size;
|
||||
break;
|
||||
case GL_POINT_SIZE:
|
||||
params[0] = IROUND(ctx->Point.Size);
|
||||
@@ -4937,15 +4945,15 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
|
||||
break;
|
||||
case GL_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_color_table, "GetIntegerv");
|
||||
params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled);
|
||||
params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]);
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_color_table, "GetIntegerv");
|
||||
params[0] = BOOLEAN_TO_INT(ctx->Pixel.PostConvolutionColorTableEnabled);
|
||||
params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]);
|
||||
break;
|
||||
case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_color_table, "GetIntegerv");
|
||||
params[0] = BOOLEAN_TO_INT(ctx->Pixel.PostColorMatrixColorTableEnabled);
|
||||
params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]);
|
||||
break;
|
||||
case GL_TEXTURE_COLOR_TABLE_SGI:
|
||||
CHECK_EXT1(SGI_texture_color_table, "GetIntegerv");
|
||||
@@ -5532,7 +5540,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
|
||||
break;
|
||||
case GL_MAX_VARYING_FLOATS_ARB:
|
||||
CHECK_EXT1(ARB_vertex_shader, "GetIntegerv");
|
||||
params[0] = ctx->Const.MaxVaryingFloats;
|
||||
params[0] = ctx->Const.MaxVarying * 4;
|
||||
break;
|
||||
case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB:
|
||||
CHECK_EXT1(ARB_vertex_shader, "GetIntegerv");
|
||||
@@ -5542,6 +5550,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
|
||||
CHECK_EXT1(ARB_vertex_shader, "GetIntegerv");
|
||||
params[0] = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
|
||||
break;
|
||||
case GL_CURRENT_PROGRAM:
|
||||
CHECK_EXT1(ARB_shader_objects, "GetIntegerv");
|
||||
params[0] = ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0;
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname);
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ _mesa_GetString( GLenum name )
|
||||
static const char *version_1_3 = "1.3 Mesa " MESA_VERSION_STRING;
|
||||
static const char *version_1_4 = "1.4 Mesa " MESA_VERSION_STRING;
|
||||
static const char *version_1_5 = "1.5 Mesa " MESA_VERSION_STRING;
|
||||
static const char *version_2_0 = "1.5 Mesa " MESA_VERSION_STRING;
|
||||
static const char *version_2_1 = "1.5 Mesa " MESA_VERSION_STRING;
|
||||
static const char *version_2_0 = "2.0 Mesa " MESA_VERSION_STRING;
|
||||
static const char *version_2_1 = "2.1 Mesa " MESA_VERSION_STRING;
|
||||
|
||||
#if FEATURE_ARB_shading_language_100
|
||||
static const char *sl_version_110 = "1.10 Mesa " MESA_VERSION_STRING;
|
||||
@@ -114,7 +114,8 @@ _mesa_GetString( GLenum name )
|
||||
ctx->Extensions.ARB_shader_objects &&
|
||||
ctx->Extensions.ARB_vertex_shader &&
|
||||
ctx->Extensions.ARB_fragment_shader &&
|
||||
ctx->Extensions.ARB_texture_non_power_of_two) {
|
||||
ctx->Extensions.ARB_texture_non_power_of_two &&
|
||||
ctx->Extensions.EXT_blend_equation_separate) {
|
||||
if (ctx->Extensions.ARB_shading_language_120 &&
|
||||
ctx->Extensions.EXT_pixel_buffer_object &&
|
||||
ctx->Extensions.EXT_texture_sRGB) {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* This is the top-most include file of the Mesa sources.
|
||||
* It includes gl.h and all system headers which are needed.
|
||||
* Other Mesa source files should \e not directly include any system
|
||||
* headers. This allows Mesa to be integrated into XFree86 and
|
||||
* allows system-dependent hacks/workarounds to be collected in one place.
|
||||
* headers. This allows system-dependent hacks/workarounds to be
|
||||
* collected in one place.
|
||||
*
|
||||
* \note Actually, a lot of system-dependent stuff is now in imports.[ch].
|
||||
*
|
||||
@@ -46,18 +46,15 @@
|
||||
#ifndef GLHEADER_H
|
||||
#define GLHEADER_H
|
||||
|
||||
/* This allows Mesa to be integrated into XFree86 */
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include "dix-config.h"
|
||||
#endif
|
||||
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE) && !defined(NO_LIBCWRAPPER)
|
||||
#include "xf86_ansic.h"
|
||||
#else
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
/* If we can use Compaq's Fast Math Library on Alpha */
|
||||
#if defined(__alpha__) && defined(CCPML)
|
||||
#include <cpml.h>
|
||||
#include <cpml.h> /* use Compaq's Fast Math Library on Alpha */
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
@@ -68,7 +65,6 @@
|
||||
#if defined(__linux__) && defined(__i386__)
|
||||
#include <fpu_control.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <float.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
+211
-102
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -59,6 +59,34 @@
|
||||
#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
|
||||
|
||||
|
||||
/**
|
||||
* \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise.
|
||||
*/
|
||||
static GLboolean
|
||||
_mesa_type_is_packed(GLenum type)
|
||||
{
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_BYTE_3_3_2:
|
||||
case GL_UNSIGNED_BYTE_2_3_3_REV:
|
||||
case GL_UNSIGNED_SHORT_5_6_5:
|
||||
case GL_UNSIGNED_SHORT_5_6_5_REV:
|
||||
case GL_UNSIGNED_SHORT_4_4_4_4:
|
||||
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
|
||||
case GL_UNSIGNED_SHORT_5_5_5_1:
|
||||
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
|
||||
case GL_UNSIGNED_INT_8_8_8_8:
|
||||
case GL_UNSIGNED_INT_8_8_8_8_REV:
|
||||
case GL_UNSIGNED_INT_10_10_10_2:
|
||||
case GL_UNSIGNED_INT_2_10_10_10_REV:
|
||||
case GL_UNSIGNED_SHORT_8_8_MESA:
|
||||
case GL_UNSIGNED_SHORT_8_8_REV_MESA:
|
||||
case GL_UNSIGNED_INT_24_8_EXT:
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flip the 8 bits in each byte of the given array.
|
||||
*
|
||||
@@ -651,39 +679,34 @@ _mesa_image_address3d( const struct gl_pixelstore_attrib *packing,
|
||||
|
||||
|
||||
/**
|
||||
* Compute the stride between image rows.
|
||||
* Compute the stride (in bytes) between image rows.
|
||||
*
|
||||
* \param packing the pixelstore attributes
|
||||
* \param width image width.
|
||||
* \param format pixel format.
|
||||
* \param type pixel data type.
|
||||
*
|
||||
* \return the stride in bytes for the given parameters.
|
||||
* \return the stride in bytes for the given parameters, or -1 if error
|
||||
*/
|
||||
GLint
|
||||
_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
|
||||
GLint width, GLenum format, GLenum type )
|
||||
{
|
||||
GLint bytesPerRow, remainder;
|
||||
|
||||
ASSERT(packing);
|
||||
|
||||
if (type == GL_BITMAP) {
|
||||
/* BITMAP data */
|
||||
GLint bytes;
|
||||
if (packing->RowLength == 0) {
|
||||
bytes = (width + 7) / 8;
|
||||
bytesPerRow = (width + 7) / 8;
|
||||
}
|
||||
else {
|
||||
bytes = (packing->RowLength + 7) / 8;
|
||||
bytesPerRow = (packing->RowLength + 7) / 8;
|
||||
}
|
||||
if (packing->Invert) {
|
||||
/* negate the bytes per row (negative row stride) */
|
||||
bytes = -bytes;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
else {
|
||||
/* Non-BITMAP data */
|
||||
const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
|
||||
GLint bytesPerRow, remainder;
|
||||
if (bytesPerPixel <= 0)
|
||||
return -1; /* error */
|
||||
if (packing->RowLength == 0) {
|
||||
@@ -692,13 +715,19 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
|
||||
else {
|
||||
bytesPerRow = bytesPerPixel * packing->RowLength;
|
||||
}
|
||||
remainder = bytesPerRow % packing->Alignment;
|
||||
if (remainder > 0)
|
||||
bytesPerRow += (packing->Alignment - remainder);
|
||||
if (packing->Invert)
|
||||
bytesPerRow = -bytesPerRow;
|
||||
return bytesPerRow;
|
||||
}
|
||||
|
||||
remainder = bytesPerRow % packing->Alignment;
|
||||
if (remainder > 0) {
|
||||
bytesPerRow += (packing->Alignment - remainder);
|
||||
}
|
||||
|
||||
if (packing->Invert) {
|
||||
/* negate the bytes per row (negative row stride) */
|
||||
bytesPerRow = -bytesPerRow;
|
||||
}
|
||||
|
||||
return bytesPerRow;
|
||||
}
|
||||
|
||||
|
||||
@@ -926,8 +955,8 @@ _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
|
||||
/* handling SkipPixels is a bit tricky (no pun intended!) */
|
||||
GLint i;
|
||||
if (packing->LsbFirst) {
|
||||
GLubyte srcMask = 1 << (packing->SkipPixels & 0x7);
|
||||
GLubyte dstMask = 128;
|
||||
GLubyte srcMask = 128;
|
||||
GLubyte dstMask = 1 << (packing->SkipPixels & 0x7);
|
||||
const GLubyte *s = src;
|
||||
GLubyte *d = dst;
|
||||
*d = 0;
|
||||
@@ -953,8 +982,8 @@ _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
|
||||
}
|
||||
}
|
||||
else {
|
||||
GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7);
|
||||
GLubyte dstMask = 128;
|
||||
GLubyte srcMask = 128;
|
||||
GLubyte dstMask = 128 >> (packing->SkipPixels & 0x7);
|
||||
const GLubyte *s = src;
|
||||
GLubyte *d = dst;
|
||||
*d = 0;
|
||||
@@ -1007,7 +1036,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
|
||||
}
|
||||
/* GL_COLOR_TABLE lookup */
|
||||
if (transferOps & IMAGE_COLOR_TABLE_BIT) {
|
||||
_mesa_lookup_rgba_float(&ctx->ColorTable, n, rgba);
|
||||
_mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_PRECONVOLUTION], n, rgba);
|
||||
}
|
||||
/* convolution */
|
||||
if (transferOps & IMAGE_CONVOLUTION_BIT) {
|
||||
@@ -1028,7 +1057,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
|
||||
}
|
||||
/* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
|
||||
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
|
||||
_mesa_lookup_rgba_float(&ctx->PostConvolutionColorTable, n, rgba);
|
||||
_mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_POSTCONVOLUTION], n, rgba);
|
||||
}
|
||||
/* color matrix transform */
|
||||
if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
|
||||
@@ -1036,7 +1065,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
|
||||
}
|
||||
/* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
|
||||
if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
|
||||
_mesa_lookup_rgba_float(&ctx->PostColorMatrixColorTable, n, rgba);
|
||||
_mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX], n, rgba);
|
||||
}
|
||||
/* update histogram count */
|
||||
if (transferOps & IMAGE_HISTOGRAM_BIT) {
|
||||
@@ -1100,11 +1129,11 @@ _mesa_apply_ci_transfer_ops(const GLcontext *ctx, GLbitfield transferOps,
|
||||
shift_and_offset_ci(ctx, n, indexes);
|
||||
}
|
||||
if (transferOps & IMAGE_MAP_COLOR_BIT) {
|
||||
const GLuint mask = ctx->Pixel.MapItoIsize - 1;
|
||||
const GLuint mask = ctx->PixelMaps.ItoI.Size - 1;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
const GLuint j = indexes[i] & mask;
|
||||
indexes[i] = IROUND(ctx->Pixel.MapItoI[j]);
|
||||
indexes[i] = IROUND(ctx->PixelMaps.ItoI.Map[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1140,10 +1169,10 @@ _mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n,
|
||||
}
|
||||
}
|
||||
if (ctx->Pixel.MapStencilFlag) {
|
||||
GLuint mask = ctx->Pixel.MapStoSsize - 1;
|
||||
GLuint mask = ctx->PixelMaps.StoS.Size - 1;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
stencil[i] = ctx->Pixel.MapStoS[ stencil[i] & mask ];
|
||||
stencil[i] = ctx->PixelMaps.StoS.Map[ stencil[i] & mask ];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1331,6 +1360,7 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
|
||||
dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
|
||||
}
|
||||
break;
|
||||
case GL_ABGR_EXT:
|
||||
for (i=0;i<n;i++) {
|
||||
dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
|
||||
@@ -1415,9 +1445,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
default:
|
||||
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
|
||||
}
|
||||
if (dstPacking->SwapBytes) {
|
||||
_mesa_swap2( (GLushort *) dst, n * comps);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_SHORT:
|
||||
@@ -1479,6 +1506,7 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
|
||||
dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
|
||||
}
|
||||
break;
|
||||
case GL_ABGR_EXT:
|
||||
for (i=0;i<n;i++) {
|
||||
dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
|
||||
@@ -1490,9 +1518,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
default:
|
||||
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
|
||||
}
|
||||
if (dstPacking->SwapBytes) {
|
||||
_mesa_swap2( (GLushort *) dst, n * comps );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
@@ -1566,9 +1591,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
default:
|
||||
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
|
||||
}
|
||||
if (dstPacking->SwapBytes) {
|
||||
_mesa_swap4( (GLuint *) dst, n * comps );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_INT:
|
||||
@@ -1642,9 +1664,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
default:
|
||||
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
|
||||
}
|
||||
if (dstPacking->SwapBytes) {
|
||||
_mesa_swap4( (GLuint *) dst, n * comps );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_FLOAT:
|
||||
@@ -1718,9 +1737,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
default:
|
||||
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
|
||||
}
|
||||
if (dstPacking->SwapBytes) {
|
||||
_mesa_swap4( (GLuint *) dst, n * comps );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_HALF_FLOAT_ARB:
|
||||
@@ -1794,9 +1810,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
default:
|
||||
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
|
||||
}
|
||||
if (dstPacking->SwapBytes) {
|
||||
_mesa_swap2( (GLushort *) dst, n * comps );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_UNSIGNED_BYTE_3_3_2:
|
||||
@@ -1815,7 +1828,7 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
for (i=0;i<n;i++) {
|
||||
dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) )
|
||||
| (((GLint) (rgba[i][GCOMP] * 7.0F)) << 3)
|
||||
| (((GLint) (rgba[i][BCOMP] * 3.0F)) << 5);
|
||||
| (((GLint) (rgba[i][BCOMP] * 3.0F)) << 6);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1861,9 +1874,9 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
else if (dstFormat == GL_ABGR_EXT) {
|
||||
GLushort *dst = (GLushort *) dstAddr;
|
||||
for (i=0;i<n;i++) {
|
||||
dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) << 4)
|
||||
dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12)
|
||||
| (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8)
|
||||
| (((GLint) (rgba[i][GCOMP] * 15.0F)) << 12)
|
||||
| (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
|
||||
| (((GLint) (rgba[i][RCOMP] * 15.0F)) );
|
||||
}
|
||||
}
|
||||
@@ -2073,6 +2086,21 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(ctx, "bad type in _mesa_pack_rgba_span_float");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dstPacking->SwapBytes) {
|
||||
GLint swapSize = _mesa_sizeof_packed_type(dstType);
|
||||
if (swapSize == 2) {
|
||||
if (dstPacking->SwapBytes) {
|
||||
_mesa_swap2((GLushort *) dstAddr, n * comps);
|
||||
}
|
||||
}
|
||||
else if (swapSize == 4) {
|
||||
if (dstPacking->SwapBytes) {
|
||||
_mesa_swap4((GLuint *) dstAddr, n * comps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3651,10 +3679,10 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
|
||||
|
||||
if (ctx->Pixel.MapStencilFlag) {
|
||||
/* Apply stencil lookup table */
|
||||
GLuint mask = ctx->Pixel.MapStoSsize - 1;
|
||||
GLuint mask = ctx->PixelMaps.StoS.Size - 1;
|
||||
GLuint i;
|
||||
for (i=0;i<n;i++) {
|
||||
indexes[i] = ctx->Pixel.MapStoS[ indexes[i] & mask ];
|
||||
indexes[i] = ctx->PixelMaps.StoS.Map[ indexes[i] & mask ];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3840,6 +3868,22 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
|
||||
}
|
||||
}
|
||||
|
||||
#define DEPTH_VALUES(GLTYPE, GLTYPE2FLOAT) \
|
||||
do { \
|
||||
GLuint i; \
|
||||
const GLTYPE *src = (const GLTYPE *)source; \
|
||||
for (i = 0; i < n; i++) { \
|
||||
GLTYPE value = src[i]; \
|
||||
if (srcPacking->SwapBytes) { \
|
||||
if (sizeof(GLTYPE) == 2) { \
|
||||
SWAP2BYTE(value); \
|
||||
} else if (sizeof(GLTYPE) == 4) { \
|
||||
SWAP4BYTE(value); \
|
||||
} \
|
||||
} \
|
||||
depthValues[i] = CLAMP(GLTYPE2FLOAT(value), 0.0F, 1.0F); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
|
||||
@@ -3849,6 +3893,36 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
|
||||
{
|
||||
GLfloat depthTemp[MAX_WIDTH], *depthValues;
|
||||
|
||||
/* Look for special cases first.
|
||||
* Not only are these faster, they're less prone to numeric conversion
|
||||
* problems. Otherwise, converting from an int type to a float then
|
||||
* back to an int type can introduce errors that will show up as
|
||||
* artifacts in things like depth peeling which uses glCopyTexImage.
|
||||
*/
|
||||
if (ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) {
|
||||
if (srcType == GL_UNSIGNED_INT && dstType == GL_UNSIGNED_SHORT) {
|
||||
const GLuint *src = (const GLuint *) source;
|
||||
GLushort *dst = (GLushort *) dest;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i] = src[i] >> 16;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (srcType == GL_UNSIGNED_SHORT && dstType == GL_UNSIGNED_INT) {
|
||||
const GLushort *src = (const GLushort *) source;
|
||||
GLuint *dst = (GLuint *) dest;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i] = src[i] | (src[i] << 16);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* XXX may want to add additional cases here someday */
|
||||
}
|
||||
|
||||
/* general case path */
|
||||
|
||||
if (dstType == GL_FLOAT) {
|
||||
depthValues = (GLfloat *) dest;
|
||||
}
|
||||
@@ -3859,60 +3933,25 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
|
||||
/* XXX we need to obey srcPacking->SwapBytes here!!! */
|
||||
(void) srcPacking;
|
||||
|
||||
/* convert incoming values to GLfloat */
|
||||
switch (srcType) {
|
||||
case GL_BYTE:
|
||||
{
|
||||
GLuint i;
|
||||
const GLubyte *src = (const GLubyte *) source;
|
||||
for (i = 0; i < n; i++) {
|
||||
depthValues[i] = BYTE_TO_FLOAT(src[i]);
|
||||
}
|
||||
}
|
||||
DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT);
|
||||
break;
|
||||
case GL_UNSIGNED_BYTE:
|
||||
{
|
||||
GLuint i;
|
||||
const GLubyte *src = (const GLubyte *) source;
|
||||
for (i = 0; i < n; i++) {
|
||||
depthValues[i] = UBYTE_TO_FLOAT(src[i]);
|
||||
}
|
||||
}
|
||||
DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT);
|
||||
break;
|
||||
case GL_SHORT:
|
||||
{
|
||||
GLuint i;
|
||||
const GLshort *src = (const GLshort *) source;
|
||||
for (i = 0; i < n; i++) {
|
||||
depthValues[i] = SHORT_TO_FLOAT(src[i]);
|
||||
}
|
||||
}
|
||||
DEPTH_VALUES(GLshort, SHORT_TO_FLOAT);
|
||||
break;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
{
|
||||
GLuint i;
|
||||
const GLushort *src = (const GLushort *) source;
|
||||
for (i = 0; i < n; i++) {
|
||||
depthValues[i] = USHORT_TO_FLOAT(src[i]);
|
||||
}
|
||||
}
|
||||
DEPTH_VALUES(GLushort, USHORT_TO_FLOAT);
|
||||
break;
|
||||
case GL_INT:
|
||||
{
|
||||
GLuint i;
|
||||
const GLint *src = (const GLint *) source;
|
||||
for (i = 0; i < n; i++) {
|
||||
depthValues[i] = INT_TO_FLOAT(src[i]);
|
||||
}
|
||||
}
|
||||
DEPTH_VALUES(GLint, INT_TO_FLOAT);
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
{
|
||||
GLuint i;
|
||||
const GLuint *src = (const GLuint *) source;
|
||||
for (i = 0; i < n; i++) {
|
||||
depthValues[i] = UINT_TO_FLOAT(src[i]);
|
||||
}
|
||||
}
|
||||
DEPTH_VALUES(GLuint, UINT_TO_FLOAT);
|
||||
break;
|
||||
case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */
|
||||
if (dstType == GL_UNSIGNED_INT &&
|
||||
@@ -3923,7 +3962,11 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
|
||||
GLuint *zValues = (GLuint *) dest;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
zValues[i] = src[i] & 0xffffff00;
|
||||
GLuint value = src[i];
|
||||
if (srcPacking->SwapBytes) {
|
||||
SWAP4BYTE(value);
|
||||
}
|
||||
zValues[i] = value & 0xffffff00;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -3932,19 +3975,27 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
|
||||
const GLfloat scale = 1.0f / 0xffffff;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
depthValues[i] = (src[i] >> 8) * scale;
|
||||
GLuint value = src[i];
|
||||
if (srcPacking->SwapBytes) {
|
||||
SWAP4BYTE(value);
|
||||
}
|
||||
depthValues[i] = (value >> 8) * scale;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_FLOAT:
|
||||
_mesa_memcpy(depthValues, source, n * sizeof(GLfloat));
|
||||
DEPTH_VALUES(GLfloat, 1*);
|
||||
break;
|
||||
case GL_HALF_FLOAT_ARB:
|
||||
{
|
||||
GLuint i;
|
||||
const GLhalfARB *src = (const GLhalfARB *) source;
|
||||
for (i = 0; i < n; i++) {
|
||||
depthValues[i] = _mesa_half_to_float(src[i]);
|
||||
GLhalfARB value = src[i];
|
||||
if (srcPacking->SwapBytes) {
|
||||
SWAP2BYTE(value);
|
||||
}
|
||||
depthValues[i] = _mesa_half_to_float(value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -4175,14 +4226,18 @@ _mesa_unpack_image( GLuint dimensions,
|
||||
|
||||
if (type == GL_BITMAP) {
|
||||
bytesPerRow = (width + 7) >> 3;
|
||||
flipBytes = !unpack->LsbFirst;
|
||||
flipBytes = unpack->LsbFirst;
|
||||
swap2 = swap4 = GL_FALSE;
|
||||
compsPerRow = 0;
|
||||
}
|
||||
else {
|
||||
const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
|
||||
const GLint components = _mesa_components_in_format(format);
|
||||
GLint components = _mesa_components_in_format(format);
|
||||
GLint bytesPerComp;
|
||||
|
||||
if (_mesa_type_is_packed(type))
|
||||
components = 1;
|
||||
|
||||
if (bytesPerPixel <= 0 || components <= 0)
|
||||
return NULL; /* bad format or type. generate error later */
|
||||
bytesPerRow = bytesPerPixel * width;
|
||||
@@ -4207,6 +4262,60 @@ _mesa_unpack_image( GLuint dimensions,
|
||||
for (row = 0; row < height; row++) {
|
||||
const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels,
|
||||
width, height, format, type, img, row, 0);
|
||||
|
||||
if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) {
|
||||
GLint i;
|
||||
flipBytes = GL_FALSE;
|
||||
if (unpack->LsbFirst) {
|
||||
GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7);
|
||||
GLubyte dstMask = 128;
|
||||
const GLubyte *s = src;
|
||||
GLubyte *d = dst;
|
||||
*d = 0;
|
||||
for (i = 0; i < width; i++) {
|
||||
if (*s & srcMask) {
|
||||
*d |= dstMask;
|
||||
}
|
||||
if (srcMask == 128) {
|
||||
srcMask = 1;
|
||||
s++;
|
||||
} else {
|
||||
srcMask = srcMask << 1;
|
||||
}
|
||||
if (dstMask == 1) {
|
||||
dstMask = 128;
|
||||
d++;
|
||||
*d = 0;
|
||||
} else {
|
||||
dstMask = dstMask >> 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7);
|
||||
GLubyte dstMask = 128;
|
||||
const GLubyte *s = src;
|
||||
GLubyte *d = dst;
|
||||
*d = 0;
|
||||
for (i = 0; i < width; i++) {
|
||||
if (*s & srcMask) {
|
||||
*d |= dstMask;
|
||||
}
|
||||
if (srcMask == 1) {
|
||||
srcMask = 128;
|
||||
s++;
|
||||
} else {
|
||||
srcMask = srcMask >> 1;
|
||||
}
|
||||
if (dstMask == 1) {
|
||||
dstMask = 128;
|
||||
d++;
|
||||
*d = 0;
|
||||
} else {
|
||||
dstMask = dstMask >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
_mesa_memcpy(dst, src, bytesPerRow);
|
||||
/* byte flipping/swapping */
|
||||
if (flipBytes) {
|
||||
|
||||
@@ -12,21 +12,10 @@
|
||||
*
|
||||
* Eventually, I want to move roll the glheader.h file into this.
|
||||
*
|
||||
* The OpenGL SI's __GLimports structure allows per-context specification of
|
||||
* replacements for the standard C lib functions. In practice that's probably
|
||||
* never needed; compile-time replacements are far more likely.
|
||||
*
|
||||
* The _mesa_*() functions defined here don't in general take a context
|
||||
* parameter. I guess we can change that someday, if need be.
|
||||
* So for now, the __GLimports stuff really isn't used.
|
||||
*
|
||||
* \todo Functions still needed:
|
||||
* - scanf
|
||||
* - qsort
|
||||
* - rand and RAND_MAX
|
||||
*
|
||||
* \note When compiled into a XFree86 module these functions wrap around
|
||||
* XFree86 own wrappers.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -71,50 +60,29 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* If we don't actually want to use the libcwrapper junk (even though we're
|
||||
* building an Xorg server module), then just undef IN_MODULE to signal that to
|
||||
* the following code. It's left around for now to allow compiling of newish
|
||||
* Mesa with older servers, but this whole mess should go away at some point.
|
||||
*/
|
||||
#ifdef NO_LIBCWRAPPER
|
||||
#undef IN_MODULE
|
||||
#endif
|
||||
|
||||
/**********************************************************************/
|
||||
/** \name Memory */
|
||||
/*@{*/
|
||||
|
||||
/** Wrapper around either malloc() or xf86malloc() */
|
||||
/** Wrapper around malloc() */
|
||||
void *
|
||||
_mesa_malloc(size_t bytes)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86malloc(bytes);
|
||||
#else
|
||||
return malloc(bytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either calloc() or xf86calloc() */
|
||||
/** Wrapper around calloc() */
|
||||
void *
|
||||
_mesa_calloc(size_t bytes)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86calloc(1, bytes);
|
||||
#else
|
||||
return calloc(1, bytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either free() or xf86free() */
|
||||
/** Wrapper around free() */
|
||||
void
|
||||
_mesa_free(void *ptr)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
xf86free(ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +99,7 @@ _mesa_free(void *ptr)
|
||||
void *
|
||||
_mesa_align_malloc(size_t bytes, unsigned long alignment)
|
||||
{
|
||||
#if defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE))
|
||||
#if defined(HAVE_POSIX_MEMALIGN)
|
||||
void *mem;
|
||||
|
||||
(void) posix_memalign(& mem, alignment, bytes);
|
||||
@@ -157,7 +125,7 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
|
||||
#endif
|
||||
|
||||
return (void *) buf;
|
||||
#endif /* defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE)) */
|
||||
#endif /* defined(HAVE_POSIX_MEMALIGN) */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +135,7 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
|
||||
void *
|
||||
_mesa_align_calloc(size_t bytes, unsigned long alignment)
|
||||
{
|
||||
#if defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE))
|
||||
#if defined(HAVE_POSIX_MEMALIGN)
|
||||
void *mem;
|
||||
|
||||
mem = _mesa_align_malloc(bytes, alignment);
|
||||
@@ -197,7 +165,7 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
|
||||
#endif
|
||||
|
||||
return (void *)buf;
|
||||
#endif /* defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE)) */
|
||||
#endif /* defined(HAVE_POSIX_MEMALIGN) */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,13 +178,13 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
|
||||
void
|
||||
_mesa_align_free(void *ptr)
|
||||
{
|
||||
#if defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE))
|
||||
#if defined(HAVE_POSIX_MEMALIGN)
|
||||
free(ptr);
|
||||
#else
|
||||
void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
|
||||
void *realAddr = *cubbyHole;
|
||||
_mesa_free(realAddr);
|
||||
#endif /* defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE)) */
|
||||
#endif /* defined(HAVE_POSIX_MEMALIGN) */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,22 +223,18 @@ _mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
|
||||
void *
|
||||
_mesa_memcpy(void *dest, const void *src, size_t n)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86memcpy(dest, src, n);
|
||||
#elif defined(SUNOS4)
|
||||
#if defined(SUNOS4)
|
||||
return memcpy((char *) dest, (char *) src, (int) n);
|
||||
#else
|
||||
return memcpy(dest, src, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either memset() or xf86memset() */
|
||||
/** Wrapper around memset() */
|
||||
void
|
||||
_mesa_memset( void *dst, int val, size_t n )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
xf86memset( dst, val, n );
|
||||
#elif defined(SUNOS4)
|
||||
#if defined(SUNOS4)
|
||||
memset( (char *) dst, (int) val, (int) n );
|
||||
#else
|
||||
memset(dst, val, n);
|
||||
@@ -290,26 +254,22 @@ _mesa_memset16( unsigned short *dst, unsigned short val, size_t n )
|
||||
*dst++ = val;
|
||||
}
|
||||
|
||||
/** Wrapper around either memcpy() or xf86memcpy() or bzero() */
|
||||
/** Wrapper around either memcpy() or bzero() */
|
||||
void
|
||||
_mesa_bzero( void *dst, size_t n )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
xf86memset( dst, 0, n );
|
||||
#elif defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__)
|
||||
bzero( dst, n );
|
||||
#else
|
||||
memset( dst, 0, n );
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either memcmp() or xf86memcmp() */
|
||||
/** Wrapper around memcmp() */
|
||||
int
|
||||
_mesa_memcmp( const void *s1, const void *s2, size_t n )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86memcmp( s1, s2, n );
|
||||
#elif defined(SUNOS4)
|
||||
#if defined(SUNOS4)
|
||||
return memcmp( (char *) s1, (char *) s2, (int) n );
|
||||
#else
|
||||
return memcmp(s1, s2, n);
|
||||
@@ -323,70 +283,46 @@ _mesa_memcmp( const void *s1, const void *s2, size_t n )
|
||||
/** \name Math */
|
||||
/*@{*/
|
||||
|
||||
/** Wrapper around either sin() or xf86sin() */
|
||||
/** Wrapper around sin() */
|
||||
double
|
||||
_mesa_sin(double a)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86sin(a);
|
||||
#else
|
||||
return sin(a);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Single precision wrapper around either sin() or xf86sin() */
|
||||
/** Single precision wrapper around sin() */
|
||||
float
|
||||
_mesa_sinf(float a)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return (float) xf86sin((double) a);
|
||||
#else
|
||||
return (float) sin((double) a);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either cos() or xf86cos() */
|
||||
/** Wrapper around cos() */
|
||||
double
|
||||
_mesa_cos(double a)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86cos(a);
|
||||
#else
|
||||
return cos(a);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Single precision wrapper around either asin() or xf86asin() */
|
||||
/** Single precision wrapper around asin() */
|
||||
float
|
||||
_mesa_asinf(float x)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return (float) xf86asin((double) x);
|
||||
#else
|
||||
return (float) asin((double) x);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Single precision wrapper around either atan() or xf86atan() */
|
||||
/** Single precision wrapper around atan() */
|
||||
float
|
||||
_mesa_atanf(float x)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return (float) xf86atan((double) x);
|
||||
#else
|
||||
return (float) atan((double) x);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either sqrt() or xf86sqrt() */
|
||||
/** Wrapper around sqrt() */
|
||||
double
|
||||
_mesa_sqrtd(double x)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86sqrt(x);
|
||||
#else
|
||||
return sqrt(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -404,7 +340,8 @@ _mesa_sqrtd(double x)
|
||||
*/
|
||||
static short sqrttab[0x100]; /* declare table of square roots */
|
||||
|
||||
static void init_sqrt_table(void)
|
||||
void
|
||||
_mesa_init_sqrt_table(void)
|
||||
{
|
||||
#if defined(USE_IEEE) && !defined(DEBUG)
|
||||
unsigned short i;
|
||||
@@ -584,25 +521,17 @@ _mesa_inv_sqrtf(float n)
|
||||
|
||||
return x3 * r3;
|
||||
#endif
|
||||
#elif defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return 1.0F / xf86sqrt(n);
|
||||
#else
|
||||
return (float) (1.0 / sqrt(n));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper around either pow() or xf86pow().
|
||||
*/
|
||||
/** Wrapper around pow() */
|
||||
double
|
||||
_mesa_pow(double x, double y)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86pow(x, y);
|
||||
#else
|
||||
return pow(x, y);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -633,14 +562,41 @@ _mesa_ffs(int i)
|
||||
}
|
||||
}
|
||||
return bit;
|
||||
#elif defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86ffs(i);
|
||||
#else
|
||||
return ffs(i);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find position of first bit set in given value.
|
||||
* XXX Warning: this function can only be used on 64-bit systems!
|
||||
* \return position of least-significant bit set, starting at 1, return zero
|
||||
* if no bits set.
|
||||
*/
|
||||
int
|
||||
_mesa_ffsll(long long val)
|
||||
{
|
||||
#ifdef ffsll
|
||||
return ffsll(val);
|
||||
#else
|
||||
int bit;
|
||||
|
||||
assert(sizeof(val) == 8);
|
||||
|
||||
bit = _mesa_ffs(val);
|
||||
if (bit != 0)
|
||||
return bit;
|
||||
|
||||
bit = _mesa_ffs(val >> 32);
|
||||
if (bit != 0)
|
||||
return 32 + bit;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return number of bits set in given GLuint.
|
||||
*/
|
||||
@@ -807,11 +763,7 @@ void *
|
||||
_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *) )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86bsearch(key, base, nmemb, size, compar);
|
||||
#else
|
||||
return bsearch(key, base, nmemb, size, compar);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
@@ -827,9 +779,7 @@ _mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
|
||||
char *
|
||||
_mesa_getenv( const char *var )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86getenv(var);
|
||||
#elif defined(_XBOX)
|
||||
#if defined(_XBOX)
|
||||
return NULL;
|
||||
#else
|
||||
return getenv(var);
|
||||
@@ -843,114 +793,86 @@ _mesa_getenv( const char *var )
|
||||
/** \name String */
|
||||
/*@{*/
|
||||
|
||||
/** Wrapper around either strstr() or xf86strstr() */
|
||||
/** Wrapper around strstr() */
|
||||
char *
|
||||
_mesa_strstr( const char *haystack, const char *needle )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86strstr(haystack, needle);
|
||||
#else
|
||||
return strstr(haystack, needle);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either strncat() or xf86strncat() */
|
||||
/** Wrapper around strncat() */
|
||||
char *
|
||||
_mesa_strncat( char *dest, const char *src, size_t n )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86strncat(dest, src, n);
|
||||
#else
|
||||
return strncat(dest, src, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either strcpy() or xf86strcpy() */
|
||||
/** Wrapper around strcpy() */
|
||||
char *
|
||||
_mesa_strcpy( char *dest, const char *src )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86strcpy(dest, src);
|
||||
#else
|
||||
return strcpy(dest, src);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either strncpy() or xf86strncpy() */
|
||||
/** Wrapper around strncpy() */
|
||||
char *
|
||||
_mesa_strncpy( char *dest, const char *src, size_t n )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86strncpy(dest, src, n);
|
||||
#else
|
||||
return strncpy(dest, src, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either strlen() or xf86strlen() */
|
||||
/** Wrapper around strlen() */
|
||||
size_t
|
||||
_mesa_strlen( const char *s )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86strlen(s);
|
||||
#else
|
||||
return strlen(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either strcmp() or xf86strcmp() */
|
||||
/** Wrapper around strcmp() */
|
||||
int
|
||||
_mesa_strcmp( const char *s1, const char *s2 )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86strcmp(s1, s2);
|
||||
#else
|
||||
return strcmp(s1, s2);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either strncmp() or xf86strncmp() */
|
||||
/** Wrapper around strncmp() */
|
||||
int
|
||||
_mesa_strncmp( const char *s1, const char *s2, size_t n )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86strncmp(s1, s2, n);
|
||||
#else
|
||||
return strncmp(s1, s2, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Implemented using _mesa_malloc() and _mesa_strcpy */
|
||||
/**
|
||||
* Implemented using _mesa_malloc() and _mesa_strcpy.
|
||||
* Note that NULL is handled accordingly.
|
||||
*/
|
||||
char *
|
||||
_mesa_strdup( const char *s )
|
||||
{
|
||||
if (s) {
|
||||
size_t l = _mesa_strlen(s);
|
||||
char *s2 = (char *) _mesa_malloc(l + 1);
|
||||
if (s2)
|
||||
_mesa_strcpy(s2, s);
|
||||
return s2;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** Wrapper around either atoi() or xf86atoi() */
|
||||
/** Wrapper around atoi() */
|
||||
int
|
||||
_mesa_atoi(const char *s)
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86atoi(s);
|
||||
#else
|
||||
return atoi(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either strtod() or xf86strtod() */
|
||||
/** Wrapper around strtod() */
|
||||
double
|
||||
_mesa_strtod( const char *s, char **end )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86strtod(s, end);
|
||||
#else
|
||||
return strtod(s, end);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
@@ -960,24 +882,19 @@ _mesa_strtod( const char *s, char **end )
|
||||
/** \name I/O */
|
||||
/*@{*/
|
||||
|
||||
/** Wrapper around either vsprintf() or xf86vsprintf() */
|
||||
/** Wrapper around vsprintf() */
|
||||
int
|
||||
_mesa_sprintf( char *str, const char *fmt, ... )
|
||||
{
|
||||
int r;
|
||||
va_list args;
|
||||
va_start( args, fmt );
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
r = xf86vsprintf( str, fmt, args );
|
||||
#else
|
||||
r = vsprintf( str, fmt, args );
|
||||
#endif
|
||||
va_end( args );
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Wrapper around either printf() or xf86printf(), using vsprintf() for
|
||||
* the formatting. */
|
||||
/** Wrapper around printf(), using vsprintf() for the formatting. */
|
||||
void
|
||||
_mesa_printf( const char *fmtString, ... )
|
||||
{
|
||||
@@ -986,22 +903,14 @@ _mesa_printf( const char *fmtString, ... )
|
||||
va_start( args, fmtString );
|
||||
vsnprintf(s, MAXSTRING, fmtString, args);
|
||||
va_end( args );
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
xf86printf("%s", s);
|
||||
#else
|
||||
fprintf(stderr,"%s", s);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around either vsprintf() or xf86vsprintf() */
|
||||
/** Wrapper around vsprintf() */
|
||||
int
|
||||
_mesa_vsprintf( char *str, const char *fmt, va_list args )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86vsprintf( str, fmt, args );
|
||||
#else
|
||||
return vsprintf( str, fmt, args );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
@@ -1019,7 +928,7 @@ _mesa_vsprintf( char *str, const char *fmt, va_list args )
|
||||
*
|
||||
* If debugging is enabled (either at compile-time via the DEBUG macro, or
|
||||
* run-time via the MESA_DEBUG environment variable), prints the warning to
|
||||
* stderr, either via fprintf() or xf86printf().
|
||||
* stderr via fprintf().
|
||||
*/
|
||||
void
|
||||
_mesa_warning( GLcontext *ctx, const char *fmtString, ... )
|
||||
@@ -1037,11 +946,7 @@ _mesa_warning( GLcontext *ctx, const char *fmtString, ... )
|
||||
debug = _mesa_getenv("MESA_DEBUG") ? GL_TRUE : GL_FALSE;
|
||||
#endif
|
||||
if (debug) {
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
xf86fprintf(stderr, "Mesa warning: %s\n", str);
|
||||
#else
|
||||
fprintf(stderr, "Mesa warning: %s\n", str);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1052,7 +957,7 @@ _mesa_warning( GLcontext *ctx, const char *fmtString, ... )
|
||||
* \param ctx GL context.
|
||||
* \param s problem description string.
|
||||
*
|
||||
* Prints the message to stderr, either via fprintf() or xf86fprintf().
|
||||
* Prints the message to stderr via fprintf().
|
||||
*/
|
||||
void
|
||||
_mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
|
||||
@@ -1065,13 +970,8 @@ _mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
|
||||
vsnprintf( str, MAXSTRING, fmtString, args );
|
||||
va_end( args );
|
||||
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
xf86fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str);
|
||||
xf86fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");
|
||||
#else
|
||||
fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str);
|
||||
fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1161,7 +1061,7 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
|
||||
* \param ctx GL context.
|
||||
* \param fmtString printf() alike format string.
|
||||
*
|
||||
* Prints the message to stderr, either via fprintf() or xf86printf().
|
||||
* Prints the message to stderr via fprintf().
|
||||
*/
|
||||
void
|
||||
_mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
|
||||
@@ -1172,11 +1072,7 @@ _mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
|
||||
va_start(args, fmtString);
|
||||
vsnprintf(s, MAXSTRING, fmtString, args);
|
||||
va_end(args);
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
xf86fprintf(stderr, "Mesa: %s", s);
|
||||
#else
|
||||
fprintf(stderr, "Mesa: %s", s);
|
||||
#endif
|
||||
#endif /* DEBUG */
|
||||
(void) ctx;
|
||||
(void) fmtString;
|
||||
@@ -1185,185 +1081,11 @@ _mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/** \name Exit */
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* Wrapper for exit().
|
||||
*/
|
||||
void
|
||||
_mesa_exit( int status )
|
||||
{
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
xf86exit(status);
|
||||
#else
|
||||
exit(status);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/** \name Default Imports Wrapper */
|
||||
/*@{*/
|
||||
|
||||
/** Wrapper around _mesa_malloc() */
|
||||
static void *
|
||||
default_malloc(__GLcontext *gc, size_t size)
|
||||
{
|
||||
(void) gc;
|
||||
return _mesa_malloc(size);
|
||||
}
|
||||
|
||||
/** Wrapper around _mesa_malloc() */
|
||||
static void *
|
||||
default_calloc(__GLcontext *gc, size_t numElem, size_t elemSize)
|
||||
{
|
||||
(void) gc;
|
||||
return _mesa_calloc(numElem * elemSize);
|
||||
}
|
||||
|
||||
/** Wrapper around either realloc() or xf86realloc() */
|
||||
static void *
|
||||
default_realloc(__GLcontext *gc, void *oldAddr, size_t newSize)
|
||||
{
|
||||
(void) gc;
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE)
|
||||
return xf86realloc(oldAddr, newSize);
|
||||
#else
|
||||
return realloc(oldAddr, newSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Wrapper around _mesa_free() */
|
||||
static void
|
||||
default_free(__GLcontext *gc, void *addr)
|
||||
{
|
||||
(void) gc;
|
||||
_mesa_free(addr);
|
||||
}
|
||||
|
||||
/** Wrapper around _mesa_getenv() */
|
||||
static char * CAPI
|
||||
default_getenv( __GLcontext *gc, const char *var )
|
||||
{
|
||||
(void) gc;
|
||||
return _mesa_getenv(var);
|
||||
}
|
||||
|
||||
/** Wrapper around _mesa_warning() */
|
||||
static void
|
||||
default_warning(__GLcontext *gc, char *str)
|
||||
{
|
||||
_mesa_warning(gc, str);
|
||||
}
|
||||
|
||||
/** Wrapper around _mesa_problem() */
|
||||
static void
|
||||
default_fatal(__GLcontext *gc, char *str)
|
||||
{
|
||||
_mesa_problem(gc, str);
|
||||
abort();
|
||||
}
|
||||
|
||||
/** Wrapper around atoi() */
|
||||
static int CAPI
|
||||
default_atoi(__GLcontext *gc, const char *str)
|
||||
{
|
||||
(void) gc;
|
||||
return atoi(str);
|
||||
}
|
||||
|
||||
/** Wrapper around vsprintf() */
|
||||
static int CAPI
|
||||
default_sprintf(__GLcontext *gc, char *str, const char *fmt, ...)
|
||||
{
|
||||
int r;
|
||||
va_list args;
|
||||
(void) gc;
|
||||
va_start( args, fmt );
|
||||
r = vsprintf( str, fmt, args );
|
||||
va_end( args );
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Wrapper around fopen() */
|
||||
static void * CAPI
|
||||
default_fopen(__GLcontext *gc, const char *path, const char *mode)
|
||||
{
|
||||
(void) gc;
|
||||
return fopen(path, mode);
|
||||
}
|
||||
|
||||
/** Wrapper around fclose() */
|
||||
static int CAPI
|
||||
default_fclose(__GLcontext *gc, void *stream)
|
||||
{
|
||||
(void) gc;
|
||||
return fclose((FILE *) stream);
|
||||
}
|
||||
|
||||
/** Wrapper around vfprintf() */
|
||||
static int CAPI
|
||||
default_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
|
||||
{
|
||||
int r;
|
||||
va_list args;
|
||||
(void) gc;
|
||||
va_start( args, fmt );
|
||||
r = vfprintf( (FILE *) stream, fmt, args );
|
||||
va_end( args );
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* \todo this really is driver-specific and can't be here
|
||||
*/
|
||||
static __GLdrawablePrivate *
|
||||
default_GetDrawablePrivate(__GLcontext *gc)
|
||||
{
|
||||
(void) gc;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a __GLimports object to point to the functions in this
|
||||
* file.
|
||||
*
|
||||
* This is to be called from device drivers.
|
||||
*
|
||||
* Also, do some one-time initializations.
|
||||
*
|
||||
* \param imports the object to initialize.
|
||||
* \param driverCtx pointer to device driver-specific data.
|
||||
*/
|
||||
void
|
||||
_mesa_init_default_imports(__GLimports *imports, void *driverCtx)
|
||||
{
|
||||
/* XXX maybe move this one-time init stuff into context.c */
|
||||
static GLboolean initialized = GL_FALSE;
|
||||
if (!initialized) {
|
||||
init_sqrt_table();
|
||||
initialized = GL_TRUE;
|
||||
}
|
||||
|
||||
imports->malloc = default_malloc;
|
||||
imports->calloc = default_calloc;
|
||||
imports->realloc = default_realloc;
|
||||
imports->free = default_free;
|
||||
imports->warning = default_warning;
|
||||
imports->fatal = default_fatal;
|
||||
imports->getenv = default_getenv; /* not used for now */
|
||||
imports->atoi = default_atoi;
|
||||
imports->sprintf = default_sprintf;
|
||||
imports->fopen = default_fopen;
|
||||
imports->fclose = default_fclose;
|
||||
imports->fprintf = default_fprintf;
|
||||
imports->getDrawablePrivate = default_GetDrawablePrivate;
|
||||
imports->other = driverCtx;
|
||||
}
|
||||
|
||||
@@ -138,13 +138,16 @@ typedef union { GLfloat f; GLint i; } fi_type;
|
||||
#define M_E (2.7182818284590452354)
|
||||
#endif
|
||||
|
||||
#ifndef FLT_MAX_EXP
|
||||
#define FLT_MAX_EXP 128
|
||||
#ifndef ONE_DIV_LN2
|
||||
#define ONE_DIV_LN2 (1.442695040888963456)
|
||||
#endif
|
||||
|
||||
/* XXX this is a bit of a hack needed for compilation within XFree86 */
|
||||
#ifndef FLT_MIN
|
||||
#define FLT_MIN (1.0e-37)
|
||||
#ifndef ONE_DIV_SQRT_LN2
|
||||
#define ONE_DIV_SQRT_LN2 (1.201122408786449815)
|
||||
#endif
|
||||
|
||||
#ifndef FLT_MAX_EXP
|
||||
#define FLT_MAX_EXP 128
|
||||
#endif
|
||||
|
||||
/* Degrees to radians conversion: */
|
||||
@@ -173,8 +176,6 @@ typedef union { GLfloat f; GLint i; } fi_type;
|
||||
***/
|
||||
#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */
|
||||
# define SQRTF(X) _mesa_sqrtf(X)
|
||||
#elif defined(XFree86LOADER) && defined(IN_MODULE) && !defined(NO_LIBCWRAPPER)
|
||||
# define SQRTF(X) (float) xf86sqrt((float) (X))
|
||||
#else
|
||||
# define SQRTF(X) (float) sqrt((float) (X))
|
||||
#endif
|
||||
@@ -221,8 +222,6 @@ static INLINE GLfloat LOG2(GLfloat val)
|
||||
num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
|
||||
return num.f + log_2;
|
||||
}
|
||||
#elif defined(XFree86LOADER) && defined(IN_MODULE) && !defined(NO_LIBCWRAPPER)
|
||||
#define LOG2(x) ((GLfloat) (xf86log(x) * 1.442695))
|
||||
#else
|
||||
/*
|
||||
* NOTE: log_base_2(x) = log(x) / log(2)
|
||||
@@ -293,15 +292,7 @@ static INLINE int GET_FLOAT_BITS( float x )
|
||||
*** LDEXPF: multiply value by an integral power of two
|
||||
*** FREXPF: extract mantissa and exponent from value
|
||||
***/
|
||||
#if defined(XFree86LOADER) && defined(IN_MODULE) && !defined(NO_LIBCWRAPPER)
|
||||
#define CEILF(x) ((GLfloat) xf86ceil(x))
|
||||
#define FLOORF(x) ((GLfloat) xf86floor(x))
|
||||
#define FABSF(x) ((GLfloat) xf86fabs(x))
|
||||
#define LOGF(x) ((GLfloat) xf86log(x))
|
||||
#define EXPF(x) ((GLfloat) xf86exp(x))
|
||||
#define LDEXPF(x,y) ((GLfloat) xf86ldexp(x,y))
|
||||
#define FREXPF(x,y) ((GLfloat) xf86frexp(x,y))
|
||||
#elif defined(__gnu_linux__)
|
||||
#if defined(__gnu_linux__)
|
||||
/* C99 functions */
|
||||
#define CEILF(x) ceilf(x)
|
||||
#define FLOORF(x) floorf(x)
|
||||
@@ -699,12 +690,18 @@ _mesa_sqrtf(float x);
|
||||
extern float
|
||||
_mesa_inv_sqrtf(float x);
|
||||
|
||||
extern void
|
||||
_mesa_init_sqrt_table(void);
|
||||
|
||||
extern double
|
||||
_mesa_pow(double x, double y);
|
||||
|
||||
extern int
|
||||
_mesa_ffs(int i);
|
||||
|
||||
extern int
|
||||
_mesa_ffsll(long long i);
|
||||
|
||||
extern unsigned int
|
||||
_mesa_bitcount(unsigned int n);
|
||||
|
||||
@@ -778,10 +775,6 @@ extern void
|
||||
_mesa_exit( int status );
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_init_default_imports( __GLimports *imports, void *driverCtx );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
*
|
||||
@@ -53,9 +53,8 @@ _mesa_ShadeModel( GLenum mode )
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_LIGHT);
|
||||
ctx->Light.ShadeModel = mode;
|
||||
ctx->_TriangleCaps ^= DD_FLATSHADE;
|
||||
if (ctx->Driver.ShadeModel)
|
||||
(*ctx->Driver.ShadeModel)( ctx, mode );
|
||||
ctx->Driver.ShadeModel( ctx, mode );
|
||||
}
|
||||
|
||||
|
||||
@@ -442,11 +441,6 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_LIGHT);
|
||||
ctx->Light.Model.TwoSide = newbool;
|
||||
|
||||
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
|
||||
ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
|
||||
else
|
||||
ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
|
||||
break;
|
||||
case GL_LIGHT_MODEL_COLOR_CONTROL:
|
||||
if (params[0] == (GLfloat) GL_SINGLE_COLOR)
|
||||
@@ -728,7 +722,7 @@ _mesa_ColorMaterial( GLenum face, GLenum mode )
|
||||
}
|
||||
|
||||
if (ctx->Driver.ColorMaterial)
|
||||
(*ctx->Driver.ColorMaterial)( ctx, face, mode );
|
||||
ctx->Driver.ColorMaterial( ctx, face, mode );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -92,7 +92,8 @@ do { \
|
||||
struct gl_shine_tab *_tab = table; \
|
||||
float f = (dp * (SHINE_TABLE_SIZE-1)); \
|
||||
int k = (int) f; \
|
||||
if (k > SHINE_TABLE_SIZE-2) \
|
||||
if (k < 0 /* gcc may cast an overflow float value to negative int value*/ \
|
||||
|| k > SHINE_TABLE_SIZE-2) \
|
||||
result = (GLfloat) _mesa_pow( dp, _tab->shininess ); \
|
||||
else \
|
||||
result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
/**
|
||||
* \file lines.c
|
||||
* Line operations.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 5.1
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -43,12 +38,6 @@
|
||||
* \param width line width in pixels.
|
||||
*
|
||||
* \sa glLineWidth().
|
||||
*
|
||||
* Verifies the parameter and updates gl_line_attrib::Width. On a change,
|
||||
* flushes the vertices, updates the clamped line width and marks the
|
||||
* DD_LINE_WIDTH flag in __GLcontextRec::_TriangleCaps for the drivers if the
|
||||
* width is different from one. Notifies the driver via the
|
||||
* dd_function_table::LineWidth callback.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
_mesa_LineWidth( GLfloat width )
|
||||
@@ -70,14 +59,8 @@ _mesa_LineWidth( GLfloat width )
|
||||
ctx->Const.MinLineWidth,
|
||||
ctx->Const.MaxLineWidth);
|
||||
|
||||
|
||||
if (width != 1.0)
|
||||
ctx->_TriangleCaps |= DD_LINE_WIDTH;
|
||||
else
|
||||
ctx->_TriangleCaps &= ~DD_LINE_WIDTH;
|
||||
|
||||
if (ctx->Driver.LineWidth)
|
||||
(*ctx->Driver.LineWidth)(ctx, width);
|
||||
ctx->Driver.LineWidth(ctx, width);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.3
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -230,7 +230,7 @@ void GLAPIENTRY
|
||||
_mesa_PushMatrix( void )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
struct matrix_stack *stack = ctx->CurrentStack;
|
||||
struct gl_matrix_stack *stack = ctx->CurrentStack;
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
if (MESA_VERBOSE&VERBOSE_API)
|
||||
@@ -270,7 +270,7 @@ void GLAPIENTRY
|
||||
_mesa_PopMatrix( void )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
struct matrix_stack *stack = ctx->CurrentStack;
|
||||
struct gl_matrix_stack *stack = ctx->CurrentStack;
|
||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
||||
|
||||
if (MESA_VERBOSE&VERBOSE_API)
|
||||
@@ -427,7 +427,7 @@ _mesa_Scalef( GLfloat x, GLfloat y, GLfloat z )
|
||||
|
||||
|
||||
/**
|
||||
* Multiply the current matrix with a general scaling matrix.
|
||||
* Multiply the current matrix with a translation matrix.
|
||||
*
|
||||
* \param x translation vector x coordinate.
|
||||
* \param y translation vector y coordinate.
|
||||
@@ -766,7 +766,7 @@ void _mesa_update_modelview_project( GLcontext *ctx, GLuint new_state )
|
||||
* initialize it.
|
||||
*/
|
||||
static void
|
||||
init_matrix_stack( struct matrix_stack *stack,
|
||||
init_matrix_stack( struct gl_matrix_stack *stack,
|
||||
GLuint maxDepth, GLuint dirtyFlag )
|
||||
{
|
||||
GLuint i;
|
||||
@@ -792,7 +792,7 @@ init_matrix_stack( struct matrix_stack *stack,
|
||||
* frees the array.
|
||||
*/
|
||||
static void
|
||||
free_matrix_stack( struct matrix_stack *stack )
|
||||
free_matrix_stack( struct gl_matrix_stack *stack )
|
||||
{
|
||||
GLuint i;
|
||||
for (i = 0; i < stack->MaxDepth; i++) {
|
||||
|
||||
@@ -928,6 +928,9 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
|
||||
return;
|
||||
}
|
||||
|
||||
if (dstImage->ImageOffsets)
|
||||
_mesa_free(dstImage->ImageOffsets);
|
||||
|
||||
/* Free old image data */
|
||||
if (dstImage->Data)
|
||||
ctx->Driver.FreeTexImageData(ctx, dstImage);
|
||||
|
||||
+248
-162
@@ -7,9 +7,9 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include <GL/internal/glcore.h> /* GLimports/GLexports/GLcontextModes */
|
||||
#include <GL/internal/glcore.h> /* __GLcontextModes (GLvisual) */
|
||||
#include "config.h" /* Hardwired parameters */
|
||||
#include "glapitable.h"
|
||||
#include "glthread.h"
|
||||
@@ -44,6 +44,12 @@
|
||||
#include "bitset.h"
|
||||
|
||||
|
||||
/**
|
||||
* Special, internal token
|
||||
*/
|
||||
#define GL_SHADER_PROGRAM_MESA 0x9999
|
||||
|
||||
|
||||
/**
|
||||
* Color channel data type.
|
||||
*/
|
||||
@@ -143,7 +149,7 @@ enum
|
||||
VERT_ATTRIB_COLOR1 = 4,
|
||||
VERT_ATTRIB_FOG = 5,
|
||||
VERT_ATTRIB_COLOR_INDEX = 6,
|
||||
VERT_ATTRIB_SEVEN = 7,
|
||||
VERT_ATTRIB_EDGEFLAG = 7,
|
||||
VERT_ATTRIB_TEX0 = 8,
|
||||
VERT_ATTRIB_TEX1 = 9,
|
||||
VERT_ATTRIB_TEX2 = 10,
|
||||
@@ -183,7 +189,7 @@ enum
|
||||
#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
|
||||
#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
|
||||
#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX)
|
||||
#define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
|
||||
#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG)
|
||||
#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
|
||||
#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
|
||||
#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
|
||||
@@ -213,22 +219,6 @@ enum
|
||||
#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* GLSL allows shader writers to allocate vertex result attributes (varyings) in
|
||||
* single float component granularity. This is in contrast to vertex / fragment
|
||||
* programs, where result attributes (actually texcoords) were allocated
|
||||
* in 4-component vectors of floats granularity.
|
||||
* For performance reasons, it would be optimal to stick with this scheme on a scalar
|
||||
* processor. Varyings will likely be allocated as 3-component vectors, so statistically
|
||||
* we win 2 floats.
|
||||
* The constant VARYINGS_PER_VECTOR tells us how much of float components we pack into
|
||||
* one result vector. For scalar processor it would be 1, for vector processor - 4.
|
||||
*
|
||||
* NOTE: Currently we pack varyings into vertex attributes.
|
||||
*/
|
||||
#define VARYINGS_PER_VECTOR 2
|
||||
#define VARYING_EMIT_STYLE EMIT_2F
|
||||
#define MAX_VARYING_VECTORS ((MAX_VARYING_FLOATS + VARYINGS_PER_VECTOR - 1) / VARYINGS_PER_VECTOR)
|
||||
|
||||
/**
|
||||
* Indexes for vertex program result attributes
|
||||
@@ -250,7 +240,8 @@ enum
|
||||
#define VERT_RESULT_BFC0 13
|
||||
#define VERT_RESULT_BFC1 14
|
||||
#define VERT_RESULT_EDGE 15
|
||||
#define VERT_RESULT_MAX 16
|
||||
#define VERT_RESULT_VAR0 16 /**< shader varying */
|
||||
#define VERT_RESULT_MAX (VERT_RESULT_VAR0 + MAX_VARYING)
|
||||
/*@}*/
|
||||
|
||||
|
||||
@@ -271,7 +262,8 @@ enum
|
||||
FRAG_ATTRIB_TEX5 = 9,
|
||||
FRAG_ATTRIB_TEX6 = 10,
|
||||
FRAG_ATTRIB_TEX7 = 11,
|
||||
FRAG_ATTRIB_MAX = 12
|
||||
FRAG_ATTRIB_VAR0 = 12, /**< shader varying */
|
||||
FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING)
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -290,6 +282,10 @@ enum
|
||||
#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
|
||||
#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
|
||||
#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
|
||||
#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0)
|
||||
|
||||
#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U))
|
||||
#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V))
|
||||
|
||||
#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
|
||||
FRAG_BIT_TEX1| \
|
||||
@@ -305,12 +301,14 @@ enum
|
||||
/**
|
||||
* Fragment program results
|
||||
*/
|
||||
/*@{*/
|
||||
#define FRAG_RESULT_COLR 0
|
||||
#define FRAG_RESULT_COLH 1
|
||||
#define FRAG_RESULT_DEPR 2
|
||||
#define FRAG_RESULT_MAX 3
|
||||
/*@}*/
|
||||
enum
|
||||
{
|
||||
FRAG_RESULT_COLR = 0,
|
||||
FRAG_RESULT_COLH = 1,
|
||||
FRAG_RESULT_DEPR = 2,
|
||||
FRAG_RESULT_DATA0 = 3,
|
||||
FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@@ -383,6 +381,13 @@ enum {
|
||||
BUFFER_BIT_COLOR7)
|
||||
|
||||
|
||||
/** The pixel transfer path has three color tables: */
|
||||
/*@{*/
|
||||
#define COLORTABLE_PRECONVOLUTION 0
|
||||
#define COLORTABLE_POSTCONVOLUTION 1
|
||||
#define COLORTABLE_POSTCOLORMATRIX 2
|
||||
#define COLORTABLE_MAX 3
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
@@ -616,11 +621,11 @@ struct gl_current_attrib
|
||||
/**
|
||||
* \name Current vertex attributes.
|
||||
* \note Values are valid only after FLUSH_VERTICES has been called.
|
||||
* \note Index and Edgeflag current values are stored as floats in the
|
||||
* SIX and SEVEN attribute slots.
|
||||
*/
|
||||
/*@{*/
|
||||
GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */
|
||||
GLfloat Index; /**< Current color index */
|
||||
GLboolean EdgeFlag; /**< Current edge flag */
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
@@ -663,9 +668,7 @@ struct gl_enable_attrib
|
||||
GLboolean Blend;
|
||||
GLbitfield ClipPlanes;
|
||||
GLboolean ColorMaterial;
|
||||
GLboolean ColorTable; /* SGI_color_table */
|
||||
GLboolean PostColorMatrixColorTable; /* SGI_color_table */
|
||||
GLboolean PostConvolutionColorTable; /* SGI_color_table */
|
||||
GLboolean ColorTable[COLORTABLE_MAX];
|
||||
GLboolean Convolution1D;
|
||||
GLboolean Convolution2D;
|
||||
GLboolean Separable2D;
|
||||
@@ -964,75 +967,92 @@ struct gl_multisample_attrib
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A pixelmap (see glPixelMap)
|
||||
*/
|
||||
struct gl_pixelmap
|
||||
{
|
||||
GLint Size;
|
||||
GLfloat Map[MAX_PIXEL_MAP_TABLE];
|
||||
GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Collection of all pixelmaps
|
||||
*/
|
||||
struct gl_pixelmaps
|
||||
{
|
||||
struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */
|
||||
struct gl_pixelmap GtoG;
|
||||
struct gl_pixelmap BtoB;
|
||||
struct gl_pixelmap AtoA;
|
||||
struct gl_pixelmap ItoR;
|
||||
struct gl_pixelmap ItoG;
|
||||
struct gl_pixelmap ItoB;
|
||||
struct gl_pixelmap ItoA;
|
||||
struct gl_pixelmap ItoI;
|
||||
struct gl_pixelmap StoS;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Pixel attribute group (GL_PIXEL_MODE_BIT).
|
||||
*/
|
||||
struct gl_pixel_attrib
|
||||
{
|
||||
GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */
|
||||
|
||||
/*--- Begin Pixel Transfer State ---*/
|
||||
/* Fields are in the order in which they're applied... */
|
||||
|
||||
/* Scale & Bias (index shift, offset) */
|
||||
GLfloat RedBias, RedScale;
|
||||
GLfloat GreenBias, GreenScale;
|
||||
GLfloat BlueBias, BlueScale;
|
||||
GLfloat AlphaBias, AlphaScale;
|
||||
GLfloat DepthBias, DepthScale;
|
||||
GLint IndexShift, IndexOffset;
|
||||
|
||||
/* Pixel Maps */
|
||||
/* Note: actual pixel maps are not part of this attrib group */
|
||||
GLboolean MapColorFlag;
|
||||
GLboolean MapStencilFlag;
|
||||
GLfloat ZoomX, ZoomY;
|
||||
/* XXX move these out of gl_pixel_attrib */
|
||||
GLint MapStoSsize; /**< Size of each pixel map */
|
||||
GLint MapItoIsize;
|
||||
GLint MapItoRsize;
|
||||
GLint MapItoGsize;
|
||||
GLint MapItoBsize;
|
||||
GLint MapItoAsize;
|
||||
GLint MapRtoRsize;
|
||||
GLint MapGtoGsize;
|
||||
GLint MapBtoBsize;
|
||||
GLint MapAtoAsize;
|
||||
GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /**< Pixel map tables */
|
||||
GLfloat MapItoI[MAX_PIXEL_MAP_TABLE];
|
||||
GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
|
||||
GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
|
||||
GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
|
||||
GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
|
||||
GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */
|
||||
GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE];
|
||||
GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE];
|
||||
GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE];
|
||||
GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
|
||||
GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
|
||||
GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
|
||||
GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
|
||||
/** GL_EXT_histogram */
|
||||
GLboolean HistogramEnabled;
|
||||
GLboolean MinMaxEnabled;
|
||||
/** GL_SGI_color_matrix */
|
||||
GLfloat PostColorMatrixScale[4]; /**< RGBA */
|
||||
GLfloat PostColorMatrixBias[4]; /**< RGBA */
|
||||
/** GL_SGI_color_table */
|
||||
GLfloat ColorTableScale[4];
|
||||
GLfloat ColorTableBias[4];
|
||||
GLboolean ColorTableEnabled;
|
||||
GLfloat PCCTscale[4];
|
||||
GLfloat PCCTbias[4];
|
||||
GLboolean PostConvolutionColorTableEnabled;
|
||||
GLfloat PCMCTscale[4];
|
||||
GLfloat PCMCTbias[4];
|
||||
GLboolean PostColorMatrixColorTableEnabled;
|
||||
/** GL_SGI_texture_color_table */
|
||||
GLfloat TextureColorTableScale[4];
|
||||
GLfloat TextureColorTableBias[4];
|
||||
/** Convolution */
|
||||
|
||||
/* There are multiple color table stages: */
|
||||
GLboolean ColorTableEnabled[COLORTABLE_MAX];
|
||||
GLfloat ColorTableScale[COLORTABLE_MAX][4]; /**< RGBA */
|
||||
GLfloat ColorTableBias[COLORTABLE_MAX][4]; /**< RGBA */
|
||||
|
||||
/* Convolution (GL_EXT_convolution) */
|
||||
GLboolean Convolution1DEnabled;
|
||||
GLboolean Convolution2DEnabled;
|
||||
GLboolean Separable2DEnabled;
|
||||
GLfloat ConvolutionBorderColor[3][4];
|
||||
GLenum ConvolutionBorderMode[3];
|
||||
GLfloat ConvolutionFilterScale[3][4];
|
||||
GLfloat ConvolutionFilterBias[3][4];
|
||||
GLfloat ConvolutionFilterScale[3][4]; /**< RGBA */
|
||||
GLfloat ConvolutionFilterBias[3][4]; /**< RGBA */
|
||||
GLfloat PostConvolutionScale[4]; /**< RGBA */
|
||||
GLfloat PostConvolutionBias[4]; /**< RGBA */
|
||||
|
||||
/* Color matrix (GL_SGI_color_matrix) */
|
||||
/* Note: the color matrix is not part of this attrib group */
|
||||
GLfloat PostColorMatrixScale[4]; /**< RGBA */
|
||||
GLfloat PostColorMatrixBias[4]; /**< RGBA */
|
||||
|
||||
/* Histogram & minmax (GL_EXT_histogram) */
|
||||
/* Note: histogram and minmax data are not part of this attrib group */
|
||||
GLboolean HistogramEnabled;
|
||||
GLboolean MinMaxEnabled;
|
||||
|
||||
/*--- End Pixel Transfer State ---*/
|
||||
|
||||
/* Pixel Zoom */
|
||||
GLfloat ZoomX, ZoomY;
|
||||
|
||||
/** GL_SGI_texture_color_table */
|
||||
GLfloat TextureColorTableScale[4];
|
||||
GLfloat TextureColorTableBias[4];
|
||||
};
|
||||
|
||||
|
||||
@@ -1640,8 +1660,6 @@ struct gl_pixelstore_attrib
|
||||
};
|
||||
|
||||
|
||||
#define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
|
||||
|
||||
|
||||
/**
|
||||
* Client vertex array attributes
|
||||
@@ -1653,14 +1671,12 @@ struct gl_client_array
|
||||
GLsizei Stride; /**< user-specified stride */
|
||||
GLsizei StrideB; /**< actual stride in bytes */
|
||||
const GLubyte *Ptr; /**< Points to array data */
|
||||
GLbitfield Enabled; /**< one of the _NEW_ARRAY_ bits */
|
||||
GLboolean Enabled; /**< Enabled flag is a boolean */
|
||||
GLboolean Normalized; /**< GL_ARB_vertex_program */
|
||||
|
||||
/**< GL_ARB_vertex_buffer_object */
|
||||
struct gl_buffer_object *BufferObj;
|
||||
GLuint _MaxElement;
|
||||
|
||||
GLbitfield Flags;
|
||||
};
|
||||
|
||||
|
||||
@@ -1681,8 +1697,8 @@ struct gl_array_object
|
||||
struct gl_client_array SecondaryColor;
|
||||
struct gl_client_array FogCoord;
|
||||
struct gl_client_array Index;
|
||||
struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
|
||||
struct gl_client_array EdgeFlag;
|
||||
struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
|
||||
/*@}*/
|
||||
|
||||
/** Generic arrays for vertex programs/shaders */
|
||||
@@ -1811,22 +1827,31 @@ struct gl_evaluators
|
||||
|
||||
/**
|
||||
* Names of the various vertex/fragment program register files, etc.
|
||||
*
|
||||
* NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
|
||||
* All values should fit in a 4-bit field.
|
||||
*
|
||||
* NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM,
|
||||
* PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to
|
||||
* be "uniform" variables since they can only be set outside glBegin/End.
|
||||
* They're also all stored in the same Parameters array.
|
||||
*/
|
||||
enum register_file
|
||||
{
|
||||
PROGRAM_TEMPORARY = 0,
|
||||
PROGRAM_LOCAL_PARAM = 1,
|
||||
PROGRAM_ENV_PARAM = 2,
|
||||
PROGRAM_STATE_VAR = 3,
|
||||
PROGRAM_INPUT = 4,
|
||||
PROGRAM_OUTPUT = 5,
|
||||
PROGRAM_NAMED_PARAM = 6,
|
||||
PROGRAM_CONSTANT = 7,
|
||||
PROGRAM_WRITE_ONLY = 8,
|
||||
PROGRAM_ADDRESS = 9,
|
||||
PROGRAM_UNDEFINED = 10, /* invalid value */
|
||||
PROGRAM_TEMPORARY = 0, /**< machine->Temporary[] */
|
||||
PROGRAM_LOCAL_PARAM = 1, /**< gl_program->LocalParams[] */
|
||||
PROGRAM_ENV_PARAM = 2, /**< gl_program->Parameters[] */
|
||||
PROGRAM_STATE_VAR = 3, /**< gl_program->Parameters[] */
|
||||
PROGRAM_INPUT = 4, /**< machine->Inputs[] */
|
||||
PROGRAM_OUTPUT = 5, /**< machine->Outputs[] */
|
||||
PROGRAM_NAMED_PARAM = 6, /**< gl_program->Parameters[] */
|
||||
PROGRAM_CONSTANT = 7, /**< gl_program->Parameters[] */
|
||||
PROGRAM_UNIFORM = 8, /**< gl_program->Parameters[] */
|
||||
PROGRAM_VARYING = 9, /**< machine->Inputs[]/Outputs[] */
|
||||
PROGRAM_WRITE_ONLY = 10, /**< A dummy, write-only register */
|
||||
PROGRAM_ADDRESS = 11, /**< machine->AddressReg */
|
||||
PROGRAM_SAMPLER = 12, /**< for shader samplers, compile-time only */
|
||||
PROGRAM_UNDEFINED = 13, /**< Invalid value */
|
||||
PROGRAM_FILE_MAX
|
||||
};
|
||||
|
||||
@@ -1844,20 +1869,26 @@ struct gl_program
|
||||
GLuint Id;
|
||||
GLubyte *String; /**< Null-terminated program text */
|
||||
GLint RefCount;
|
||||
GLenum Target;
|
||||
GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */
|
||||
GLenum Format; /**< String encoding format */
|
||||
GLboolean Resident;
|
||||
|
||||
struct prog_instruction *Instructions;
|
||||
|
||||
GLbitfield InputsRead; /* Bitmask of which input regs are read */
|
||||
GLbitfield OutputsWritten; /* Bitmask of which output regs are written to */
|
||||
GLbitfield InputsRead; /**< Bitmask of which input regs are read */
|
||||
GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */
|
||||
GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
|
||||
|
||||
/** Named parameters, constants, etc. from program text */
|
||||
struct gl_program_parameter_list *Parameters;
|
||||
/** Numbered local parameters */
|
||||
GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
|
||||
|
||||
/** Vertex/fragment shader varying vars */
|
||||
struct gl_program_parameter_list *Varying;
|
||||
/** Vertex program user-defined attributes */
|
||||
struct gl_program_parameter_list *Attributes;
|
||||
|
||||
/** Logical counts */
|
||||
/*@{*/
|
||||
GLuint NumInstructions;
|
||||
@@ -1865,6 +1896,9 @@ struct gl_program
|
||||
GLuint NumParameters;
|
||||
GLuint NumAttributes;
|
||||
GLuint NumAddressRegs;
|
||||
GLuint NumAluInstructions;
|
||||
GLuint NumTexInstructions;
|
||||
GLuint NumTexIndirections;
|
||||
/*@}*/
|
||||
/** Native, actual h/w counts */
|
||||
/*@{*/
|
||||
@@ -1873,6 +1907,9 @@ struct gl_program
|
||||
GLuint NumNativeParameters;
|
||||
GLuint NumNativeAttributes;
|
||||
GLuint NumNativeAddressRegs;
|
||||
GLuint NumNativeAluInstructions;
|
||||
GLuint NumNativeTexInstructions;
|
||||
GLuint NumNativeTexIndirections;
|
||||
/*@}*/
|
||||
};
|
||||
|
||||
@@ -1891,13 +1928,6 @@ struct gl_vertex_program
|
||||
struct gl_fragment_program
|
||||
{
|
||||
struct gl_program Base; /**< base class */
|
||||
GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
|
||||
GLuint NumAluInstructions; /**< GL_ARB_fragment_program */
|
||||
GLuint NumTexInstructions;
|
||||
GLuint NumTexIndirections;
|
||||
GLuint NumNativeAluInstructions; /**< GL_ARB_fragment_program */
|
||||
GLuint NumNativeTexInstructions;
|
||||
GLuint NumNativeTexIndirections;
|
||||
GLenum FogOption;
|
||||
GLboolean UsesKill;
|
||||
};
|
||||
@@ -1922,16 +1952,24 @@ struct gl_vertex_program_state
|
||||
GLboolean _Enabled; /**< Enabled and valid program? */
|
||||
GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
|
||||
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
|
||||
struct gl_vertex_program *Current; /**< ptr to currently bound program */
|
||||
const struct gl_vertex_program *_Current; /**< ptr to currently bound
|
||||
program, including internal
|
||||
(t_vp_build.c) programs */
|
||||
struct gl_vertex_program *Current; /**< user-bound vertex program */
|
||||
|
||||
GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /**< Env params */
|
||||
/** Currently enabled and valid program (including internal programs
|
||||
* and compiled shader programs).
|
||||
*/
|
||||
struct gl_vertex_program *_Current;
|
||||
|
||||
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
|
||||
|
||||
/* For GL_NV_vertex_program only: */
|
||||
GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
|
||||
GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
|
||||
GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4];
|
||||
GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4];
|
||||
|
||||
/** Should fixed-function T&L be implemented with a vertex prog? */
|
||||
GLboolean _MaintainTnlProgram;
|
||||
|
||||
/** Program to emulate fixed-function T&L (see above) */
|
||||
struct gl_vertex_program *_TnlProgram;
|
||||
|
||||
#if FEATURE_MESA_program_debug
|
||||
GLprogramcallbackMESA Callback;
|
||||
@@ -1949,11 +1987,22 @@ struct gl_fragment_program_state
|
||||
{
|
||||
GLboolean Enabled; /**< User-set fragment program enable flag */
|
||||
GLboolean _Enabled; /**< Fragment program enabled and valid? */
|
||||
GLboolean _Active; /**< Is a user program or internal program active? */
|
||||
struct gl_fragment_program *Current; /**< User-bound program */
|
||||
const struct gl_fragment_program *_Current; /**< currently active program
|
||||
(including internal programs) */
|
||||
GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /**< Env params */
|
||||
GLboolean _Active;
|
||||
struct gl_fragment_program *Current; /**< User-bound fragment program */
|
||||
|
||||
/** Currently enabled and valid program (including internal programs
|
||||
* and compiled shader programs).
|
||||
*/
|
||||
struct gl_fragment_program *_Current;
|
||||
|
||||
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
|
||||
|
||||
/** Should fixed-function texturing be implemented with a fragment prog? */
|
||||
GLboolean _MaintainTexEnvProgram;
|
||||
GLboolean _UseTexEnvProgram;
|
||||
|
||||
/** Program to emulate fixed-function texture env/combine (see above) */
|
||||
struct gl_fragment_program *_TexEnvProgram;
|
||||
|
||||
#if FEATURE_MESA_program_debug
|
||||
GLprogramcallbackMESA Callback;
|
||||
@@ -2030,14 +2079,61 @@ struct gl_query_state
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Context state for vertex/fragment shaders.
|
||||
* A GLSL shader object.
|
||||
*/
|
||||
struct gl_shader_objects_state
|
||||
struct gl_shader
|
||||
{
|
||||
struct gl2_program_intf **CurrentProgram;
|
||||
GLboolean _VertexShaderPresent;
|
||||
GLboolean _FragmentShaderPresent;
|
||||
GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER (first field!) */
|
||||
GLuint Name; /**< AKA the handle */
|
||||
GLint RefCount; /**< Reference count */
|
||||
GLboolean DeletePending;
|
||||
|
||||
const GLchar *Source; /**< Source code string */
|
||||
GLboolean CompileStatus;
|
||||
GLuint NumPrograms; /**< size of Programs[] array */
|
||||
struct gl_program **Programs; /**< Post-compile assembly code */
|
||||
GLchar *InfoLog;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A GLSL program object. Basically a linked collection of "shaders".
|
||||
*/
|
||||
struct gl_shader_program
|
||||
{
|
||||
GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */
|
||||
GLuint Name; /**< aka handle or ID */
|
||||
GLint RefCount; /**< Reference count */
|
||||
GLboolean DeletePending;
|
||||
|
||||
GLuint NumShaders; /**< number of attached shaders */
|
||||
struct gl_shader **Shaders; /**< List of attached the shaders */
|
||||
|
||||
/* post-link info: */
|
||||
struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
|
||||
struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
|
||||
struct gl_program_parameter_list *Uniforms; /**< Plus constants, etc */
|
||||
struct gl_program_parameter_list *Varying;
|
||||
struct gl_program_parameter_list *Attributes; /**< Vertex attributes */
|
||||
GLboolean LinkStatus; /**< GL_LINK_STATUS */
|
||||
GLboolean Validated;
|
||||
GLchar *InfoLog;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Context state for GLSL vertex/fragment shaders.
|
||||
*/
|
||||
struct gl_shader_state
|
||||
{
|
||||
struct gl_shader_program *CurrentProgram; /**< The user-bound program */
|
||||
/** Driver-selectable options: */
|
||||
GLboolean EmitHighLevelInstructions; /**< IF/ELSE/ENDIF vs. BRA, etc. */
|
||||
GLboolean EmitCondCodes; /**< Use condition codes? */
|
||||
GLboolean EmitComments; /**< Annotated instructions */
|
||||
void *MemPool;
|
||||
};
|
||||
|
||||
|
||||
@@ -2098,7 +2194,8 @@ struct gl_shared_state
|
||||
#endif
|
||||
|
||||
#if FEATURE_ARB_shader_objects
|
||||
struct _mesa_HashTable *GL2Objects;
|
||||
/** Table of both gl_shader and gl_shader_program objects */
|
||||
struct _mesa_HashTable *ShaderObjects;
|
||||
#endif
|
||||
|
||||
#if FEATURE_EXT_framebuffer_object
|
||||
@@ -2126,6 +2223,8 @@ struct gl_shared_state
|
||||
*/
|
||||
struct gl_renderbuffer
|
||||
{
|
||||
#define RB_MAGIC 0xaabbccdd
|
||||
int Magic; /** XXX TEMPORARY DEBUG INFO */
|
||||
_glthread_Mutex Mutex; /**< for thread safety */
|
||||
GLuint ClassID; /**< Useful for drivers */
|
||||
GLuint Name;
|
||||
@@ -2143,7 +2242,7 @@ struct gl_renderbuffer
|
||||
GLubyte IndexBits;
|
||||
GLubyte DepthBits;
|
||||
GLubyte StencilBits;
|
||||
GLvoid *Data;
|
||||
GLvoid *Data; /**< This may not be used by some kinds of RBs */
|
||||
|
||||
/* Used to wrap one renderbuffer around another: */
|
||||
struct gl_renderbuffer *Wrapped;
|
||||
@@ -2247,6 +2346,7 @@ struct gl_framebuffer
|
||||
_glthread_Mutex Mutex; /**< for thread safety */
|
||||
GLuint Name; /* if zero, this is a window system framebuffer */
|
||||
GLint RefCount;
|
||||
GLboolean DeletePending;
|
||||
|
||||
GLvisual Visual; /**< The framebuffer's visual.
|
||||
Immutable if this is a window system buffer.
|
||||
@@ -2377,7 +2477,7 @@ struct gl_constants
|
||||
GLuint MaxRenderbufferSize;
|
||||
/* GL_ARB_vertex_shader */
|
||||
GLuint MaxVertexTextureImageUnits;
|
||||
GLuint MaxVaryingFloats;
|
||||
GLuint MaxVarying;
|
||||
};
|
||||
|
||||
|
||||
@@ -2478,6 +2578,7 @@ struct gl_extensions
|
||||
GLboolean ATI_texture_mirror_once;
|
||||
GLboolean ATI_texture_env_combine3;
|
||||
GLboolean ATI_fragment_shader;
|
||||
GLboolean ATI_separate_stencil;
|
||||
GLboolean IBM_rasterpos_clip;
|
||||
GLboolean IBM_multimode_draw_arrays;
|
||||
GLboolean MESA_pack_invert;
|
||||
@@ -2514,7 +2615,7 @@ struct gl_extensions
|
||||
/**
|
||||
* A stack of matrices (projection, modelview, color, texture, etc).
|
||||
*/
|
||||
struct matrix_stack
|
||||
struct gl_matrix_stack
|
||||
{
|
||||
GLmatrix *Top; /**< points into Stack */
|
||||
GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
|
||||
@@ -2611,7 +2712,7 @@ struct matrix_stack
|
||||
#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
|
||||
#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
|
||||
#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX
|
||||
#define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
|
||||
#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG
|
||||
#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
|
||||
#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
|
||||
#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
|
||||
@@ -2620,7 +2721,7 @@ struct matrix_stack
|
||||
#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
|
||||
#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
|
||||
#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
|
||||
#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
|
||||
#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */
|
||||
#define _NEW_ARRAY_ALL 0xffffffff
|
||||
|
||||
|
||||
@@ -2677,6 +2778,7 @@ struct matrix_stack
|
||||
#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
|
||||
_NEW_TEXTURE | \
|
||||
_NEW_POINT | \
|
||||
_NEW_PROGRAM | \
|
||||
_NEW_MODELVIEW)
|
||||
|
||||
#define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
|
||||
@@ -2744,7 +2846,7 @@ struct mesa_display_list
|
||||
/**
|
||||
* State used during display list compilation and execution.
|
||||
*/
|
||||
struct mesa_list_state
|
||||
struct gl_dlist_state
|
||||
{
|
||||
struct mesa_display_list *CallStack[MAX_LIST_NESTING];
|
||||
GLuint CallDepth; /**< Current recursion calling depth */
|
||||
@@ -2783,17 +2885,6 @@ struct mesa_list_state
|
||||
*/
|
||||
struct __GLcontextRec
|
||||
{
|
||||
/**
|
||||
* \name OS related interfaces.
|
||||
*
|
||||
* These \b must be the first members of this structure, because they are
|
||||
* exposed to the outside world (i.e. GLX extension).
|
||||
*/
|
||||
/*@{*/
|
||||
__GLimports imports;
|
||||
__GLexports exports;
|
||||
/*@}*/
|
||||
|
||||
/** State possibly shared with other contexts in the address space */
|
||||
struct gl_shared_state *Shared;
|
||||
|
||||
@@ -2816,26 +2907,25 @@ struct __GLcontextRec
|
||||
struct dd_function_table Driver;
|
||||
|
||||
void *DriverCtx; /**< Points to device driver context/state */
|
||||
void *DriverMgrCtx; /**< Points to device driver manager (optional)*/
|
||||
|
||||
/** Core/Driver constants */
|
||||
struct gl_constants Const;
|
||||
|
||||
/** \name The various 4x4 matrix stacks */
|
||||
/*@{*/
|
||||
struct matrix_stack ModelviewMatrixStack;
|
||||
struct matrix_stack ProjectionMatrixStack;
|
||||
struct matrix_stack ColorMatrixStack;
|
||||
struct matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
|
||||
struct matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
|
||||
struct matrix_stack *CurrentStack; /**< Points to one of the above stacks */
|
||||
struct gl_matrix_stack ModelviewMatrixStack;
|
||||
struct gl_matrix_stack ProjectionMatrixStack;
|
||||
struct gl_matrix_stack ColorMatrixStack;
|
||||
struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
|
||||
struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
|
||||
struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
|
||||
/*@}*/
|
||||
|
||||
/** Combined modelview and projection matrix */
|
||||
GLmatrix _ModelProjectMatrix;
|
||||
|
||||
/** \name Display lists */
|
||||
struct mesa_list_state ListState;
|
||||
struct gl_dlist_state ListState;
|
||||
|
||||
GLboolean ExecuteFlag; /**< Execute GL commands? */
|
||||
GLboolean CompileFlag; /**< Compile GL commands into display list? */
|
||||
@@ -2893,6 +2983,7 @@ struct __GLcontextRec
|
||||
|
||||
/** \name Other assorted state (not pushed/popped on attribute stack) */
|
||||
/*@{*/
|
||||
struct gl_pixelmaps PixelMaps;
|
||||
struct gl_histogram_attrib Histogram;
|
||||
struct gl_minmax_attrib MinMax;
|
||||
struct gl_convolution_attrib Convolution1D;
|
||||
@@ -2903,28 +2994,23 @@ struct __GLcontextRec
|
||||
struct gl_feedback Feedback; /**< Feedback */
|
||||
struct gl_selection Select; /**< Selection */
|
||||
|
||||
struct gl_color_table ColorTable; /**< Pre-convolution */
|
||||
struct gl_color_table ProxyColorTable; /**< Pre-convolution */
|
||||
struct gl_color_table ColorTable[COLORTABLE_MAX];
|
||||
struct gl_color_table ProxyColorTable[COLORTABLE_MAX];
|
||||
#if 0
|
||||
struct gl_color_table PostConvolutionColorTable;
|
||||
struct gl_color_table ProxyPostConvolutionColorTable;
|
||||
struct gl_color_table PostColorMatrixColorTable;
|
||||
struct gl_color_table ProxyPostColorMatrixColorTable;
|
||||
#endif
|
||||
|
||||
struct gl_program_state Program; /**< for vertex or fragment progs */
|
||||
struct gl_vertex_program_state VertexProgram; /**< GL_ARB/NV_vertex_program */
|
||||
struct gl_fragment_program_state FragmentProgram; /**< GL_ARB/NV_vertex_program */
|
||||
struct gl_ati_fragment_shader_state ATIFragmentShader; /**< GL_ATI_fragment_shader */
|
||||
|
||||
struct gl_fragment_program *_TexEnvProgram; /**< Texture state as fragment program */
|
||||
struct gl_vertex_program *_TnlProgram; /**< Fixed func TNL state as vertex program */
|
||||
|
||||
GLboolean _MaintainTnlProgram;
|
||||
GLboolean _MaintainTexEnvProgram;
|
||||
GLboolean _UseTexEnvProgram;
|
||||
|
||||
struct gl_query_state Query; /**< GL_ARB_occlusion_query */
|
||||
|
||||
struct gl_shader_objects_state ShaderObjects; /* GL_ARB_shader_objects */
|
||||
struct gl_shader_state Shader; /**< GLSL shader object state */
|
||||
/*@}*/
|
||||
|
||||
#if FEATURE_EXT_framebuffer_object
|
||||
|
||||
+154
-293
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -252,85 +252,76 @@ _mesa_PixelStoref( GLenum pname, GLfloat param )
|
||||
/***** glPixelMap *****/
|
||||
/**********************************************************************/
|
||||
|
||||
/**
|
||||
* Return pointer to a pixelmap by name.
|
||||
*/
|
||||
static struct gl_pixelmap *
|
||||
get_pixelmap(GLcontext *ctx, GLenum map)
|
||||
{
|
||||
switch (map) {
|
||||
case GL_PIXEL_MAP_I_TO_I:
|
||||
return &ctx->PixelMaps.ItoI;
|
||||
case GL_PIXEL_MAP_S_TO_S:
|
||||
return &ctx->PixelMaps.StoS;
|
||||
case GL_PIXEL_MAP_I_TO_R:
|
||||
return &ctx->PixelMaps.ItoR;
|
||||
case GL_PIXEL_MAP_I_TO_G:
|
||||
return &ctx->PixelMaps.ItoG;
|
||||
case GL_PIXEL_MAP_I_TO_B:
|
||||
return &ctx->PixelMaps.ItoB;
|
||||
case GL_PIXEL_MAP_I_TO_A:
|
||||
return &ctx->PixelMaps.ItoA;
|
||||
case GL_PIXEL_MAP_R_TO_R:
|
||||
return &ctx->PixelMaps.RtoR;
|
||||
case GL_PIXEL_MAP_G_TO_G:
|
||||
return &ctx->PixelMaps.GtoG;
|
||||
case GL_PIXEL_MAP_B_TO_B:
|
||||
return &ctx->PixelMaps.BtoB;
|
||||
case GL_PIXEL_MAP_A_TO_A:
|
||||
return &ctx->PixelMaps.AtoA;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper routine used by the other _mesa_PixelMap() functions.
|
||||
*/
|
||||
static void
|
||||
pixelmap(GLcontext *ctx, GLenum map, GLsizei mapsize, const GLfloat *values)
|
||||
store_pixelmap(GLcontext *ctx, GLenum map, GLsizei mapsize,
|
||||
const GLfloat *values)
|
||||
{
|
||||
GLint i;
|
||||
struct gl_pixelmap *pm = get_pixelmap(ctx, map);
|
||||
if (!pm) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glPixelMap(map)");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (map) {
|
||||
case GL_PIXEL_MAP_S_TO_S:
|
||||
ctx->Pixel.MapStoSsize = mapsize;
|
||||
/* special case */
|
||||
ctx->PixelMaps.StoS.Size = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
ctx->Pixel.MapStoS[i] = IROUND(values[i]);
|
||||
ctx->PixelMaps.StoS.Map[i] = IROUND(values[i]);
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_I:
|
||||
ctx->Pixel.MapItoIsize = mapsize;
|
||||
/* special case */
|
||||
ctx->PixelMaps.ItoI.Size = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
ctx->Pixel.MapItoI[i] = values[i];
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_R:
|
||||
ctx->Pixel.MapItoRsize = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
|
||||
ctx->Pixel.MapItoR[i] = val;
|
||||
ctx->Pixel.MapItoR8[i] = (GLint) (val * 255.0F);
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_G:
|
||||
ctx->Pixel.MapItoGsize = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
|
||||
ctx->Pixel.MapItoG[i] = val;
|
||||
ctx->Pixel.MapItoG8[i] = (GLint) (val * 255.0F);
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_B:
|
||||
ctx->Pixel.MapItoBsize = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
|
||||
ctx->Pixel.MapItoB[i] = val;
|
||||
ctx->Pixel.MapItoB8[i] = (GLint) (val * 255.0F);
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_A:
|
||||
ctx->Pixel.MapItoAsize = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
|
||||
ctx->Pixel.MapItoA[i] = val;
|
||||
ctx->Pixel.MapItoA8[i] = (GLint) (val * 255.0F);
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_R_TO_R:
|
||||
ctx->Pixel.MapRtoRsize = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
ctx->Pixel.MapRtoR[i] = CLAMP( values[i], 0.0F, 1.0F );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_G_TO_G:
|
||||
ctx->Pixel.MapGtoGsize = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
ctx->Pixel.MapGtoG[i] = CLAMP( values[i], 0.0F, 1.0F );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_B_TO_B:
|
||||
ctx->Pixel.MapBtoBsize = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
ctx->Pixel.MapBtoB[i] = CLAMP( values[i], 0.0F, 1.0F );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_A_TO_A:
|
||||
ctx->Pixel.MapAtoAsize = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
ctx->Pixel.MapAtoA[i] = CLAMP( values[i], 0.0F, 1.0F );
|
||||
ctx->PixelMaps.ItoI.Map[i] = values[i];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_mesa_error( ctx, GL_INVALID_ENUM, "glPixelMap(map)" );
|
||||
/* general case */
|
||||
pm->Size = mapsize;
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
GLfloat val = CLAMP(values[i], 0.0F, 1.0F);
|
||||
pm->Map[i] = val;
|
||||
pm->Map8[i] = (GLint) (val * 255.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +376,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
|
||||
return;
|
||||
}
|
||||
|
||||
pixelmap(ctx, map, mapsize, values);
|
||||
store_pixelmap(ctx, map, mapsize, values);
|
||||
|
||||
if (ctx->Unpack.BufferObj->Name) {
|
||||
ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
|
||||
@@ -394,7 +385,6 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
|
||||
{
|
||||
@@ -464,11 +454,10 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
|
||||
ctx->Unpack.BufferObj);
|
||||
}
|
||||
|
||||
pixelmap(ctx, map, mapsize, fvalues);
|
||||
store_pixelmap(ctx, map, mapsize, fvalues);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
|
||||
{
|
||||
@@ -539,40 +528,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
|
||||
ctx->Unpack.BufferObj);
|
||||
}
|
||||
|
||||
pixelmap(ctx, map, mapsize, fvalues);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return size of the named map.
|
||||
*/
|
||||
static GLuint
|
||||
get_map_size(GLcontext *ctx, GLenum map)
|
||||
{
|
||||
switch (map) {
|
||||
case GL_PIXEL_MAP_I_TO_I:
|
||||
return ctx->Pixel.MapItoIsize;
|
||||
case GL_PIXEL_MAP_S_TO_S:
|
||||
return ctx->Pixel.MapStoSsize;
|
||||
case GL_PIXEL_MAP_I_TO_R:
|
||||
return ctx->Pixel.MapItoRsize;
|
||||
case GL_PIXEL_MAP_I_TO_G:
|
||||
return ctx->Pixel.MapItoGsize;
|
||||
case GL_PIXEL_MAP_I_TO_B:
|
||||
return ctx->Pixel.MapItoBsize;
|
||||
case GL_PIXEL_MAP_I_TO_A:
|
||||
return ctx->Pixel.MapItoAsize;
|
||||
case GL_PIXEL_MAP_R_TO_R:
|
||||
return ctx->Pixel.MapRtoRsize;
|
||||
case GL_PIXEL_MAP_G_TO_G:
|
||||
return ctx->Pixel.MapGtoGsize;
|
||||
case GL_PIXEL_MAP_B_TO_B:
|
||||
return ctx->Pixel.MapBtoBsize;
|
||||
case GL_PIXEL_MAP_A_TO_A:
|
||||
return ctx->Pixel.MapAtoAsize;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
store_pixelmap(ctx, map, mapsize, fvalues);
|
||||
}
|
||||
|
||||
|
||||
@@ -581,9 +537,17 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLuint mapsize, i;
|
||||
const struct gl_pixelmap *pm;
|
||||
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
mapsize = get_map_size(ctx, map);
|
||||
pm = get_pixelmap(ctx, map);
|
||||
if (!pm) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapfv(map)");
|
||||
return;
|
||||
}
|
||||
|
||||
mapsize = pm->Size;
|
||||
|
||||
if (ctx->Pack.BufferObj->Name) {
|
||||
/* pack pixelmap into PBO */
|
||||
@@ -613,41 +577,14 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values )
|
||||
return;
|
||||
}
|
||||
|
||||
switch (map) {
|
||||
case GL_PIXEL_MAP_I_TO_I:
|
||||
MEMCPY(values, ctx->Pixel.MapItoI, mapsize * sizeof(GLfloat));
|
||||
break;
|
||||
case GL_PIXEL_MAP_S_TO_S:
|
||||
if (map == GL_PIXEL_MAP_S_TO_S) {
|
||||
/* special case */
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = (GLfloat) ctx->Pixel.MapStoS[i];
|
||||
values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i];
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_R:
|
||||
MEMCPY(values, ctx->Pixel.MapItoR, mapsize * sizeof(GLfloat));
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_G:
|
||||
MEMCPY(values, ctx->Pixel.MapItoG, mapsize * sizeof(GLfloat));
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_B:
|
||||
MEMCPY(values, ctx->Pixel.MapItoB, mapsize * sizeof(GLfloat));
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_A:
|
||||
MEMCPY(values, ctx->Pixel.MapItoA, mapsize * sizeof(GLfloat));
|
||||
break;
|
||||
case GL_PIXEL_MAP_R_TO_R:
|
||||
MEMCPY(values, ctx->Pixel.MapRtoR, mapsize * sizeof(GLfloat));
|
||||
break;
|
||||
case GL_PIXEL_MAP_G_TO_G:
|
||||
MEMCPY(values, ctx->Pixel.MapGtoG, mapsize * sizeof(GLfloat));
|
||||
break;
|
||||
case GL_PIXEL_MAP_B_TO_B:
|
||||
MEMCPY(values, ctx->Pixel.MapBtoB, mapsize * sizeof(GLfloat));
|
||||
break;
|
||||
case GL_PIXEL_MAP_A_TO_A:
|
||||
MEMCPY(values, ctx->Pixel.MapAtoA, mapsize * sizeof(GLfloat));
|
||||
break;
|
||||
default:
|
||||
_mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" );
|
||||
}
|
||||
else {
|
||||
MEMCPY(values, pm->Map, mapsize * sizeof(GLfloat));
|
||||
}
|
||||
|
||||
if (ctx->Pack.BufferObj->Name) {
|
||||
@@ -662,9 +599,16 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLint mapsize, i;
|
||||
const struct gl_pixelmap *pm;
|
||||
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
mapsize = get_map_size(ctx, map);
|
||||
pm = get_pixelmap(ctx, map);
|
||||
if (!pm) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapuiv(map)");
|
||||
return;
|
||||
}
|
||||
mapsize = pm->Size;
|
||||
|
||||
if (ctx->Pack.BufferObj->Name) {
|
||||
/* pack pixelmap into PBO */
|
||||
@@ -694,57 +638,14 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values )
|
||||
return;
|
||||
}
|
||||
|
||||
switch (map) {
|
||||
case GL_PIXEL_MAP_I_TO_I:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoI[i] );
|
||||
if (map == GL_PIXEL_MAP_S_TO_S) {
|
||||
/* special case */
|
||||
MEMCPY(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint));
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_S_TO_S:
|
||||
MEMCPY(values, ctx->Pixel.MapStoS, mapsize * sizeof(GLint));
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_R:
|
||||
else {
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoR[i] );
|
||||
values[i] = FLOAT_TO_UINT( pm->Map[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_G:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoG[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_B:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoB[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_A:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoA[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_R_TO_R:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = FLOAT_TO_UINT( ctx->Pixel.MapRtoR[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_G_TO_G:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = FLOAT_TO_UINT( ctx->Pixel.MapGtoG[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_B_TO_B:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = FLOAT_TO_UINT( ctx->Pixel.MapBtoB[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_A_TO_A:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = FLOAT_TO_UINT( ctx->Pixel.MapAtoA[i] );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" );
|
||||
}
|
||||
|
||||
if (ctx->Pack.BufferObj->Name) {
|
||||
@@ -759,9 +660,16 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLint mapsize, i;
|
||||
const struct gl_pixelmap *pm;
|
||||
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
mapsize = get_map_size(ctx, map);
|
||||
pm = get_pixelmap(ctx, map);
|
||||
if (!pm) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapusv(map)");
|
||||
return;
|
||||
}
|
||||
mapsize = pm ? pm->Size : 0;
|
||||
|
||||
if (ctx->Pack.BufferObj->Name) {
|
||||
/* pack pixelmap into PBO */
|
||||
@@ -793,58 +701,21 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values )
|
||||
}
|
||||
|
||||
switch (map) {
|
||||
/* special cases */
|
||||
case GL_PIXEL_MAP_I_TO_I:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = (GLushort) CLAMP(ctx->Pixel.MapItoI[i], 0.0, 65535.0);
|
||||
values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.);
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_S_TO_S:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
values[i] = (GLushort) CLAMP(ctx->Pixel.MapStoS[i], 0.0, 65535.0);
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_R:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoR[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_G:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoG[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_B:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoB[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_I_TO_A:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoA[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_R_TO_R:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapRtoR[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_G_TO_G:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapGtoG[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_B_TO_B:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapBtoB[i] );
|
||||
}
|
||||
break;
|
||||
case GL_PIXEL_MAP_A_TO_A:
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapAtoA[i] );
|
||||
values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" );
|
||||
for (i = 0; i < mapsize; i++) {
|
||||
CLAMPED_FLOAT_TO_USHORT(values[i], pm->Map[i] );
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->Pack.BufferObj->Name) {
|
||||
@@ -1040,16 +911,16 @@ _mesa_PixelTransferf( GLenum pname, GLfloat param )
|
||||
ctx->Pixel.PostConvolutionBias[2] = param;
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_ALPHA_SCALE:
|
||||
if (ctx->Pixel.PostConvolutionScale[2] == param)
|
||||
if (ctx->Pixel.PostConvolutionScale[3] == param)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_PIXEL);
|
||||
ctx->Pixel.PostConvolutionScale[2] = param;
|
||||
ctx->Pixel.PostConvolutionScale[3] = param;
|
||||
break;
|
||||
case GL_POST_CONVOLUTION_ALPHA_BIAS:
|
||||
if (ctx->Pixel.PostConvolutionBias[2] == param)
|
||||
if (ctx->Pixel.PostConvolutionBias[3] == param)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_PIXEL);
|
||||
ctx->Pixel.PostConvolutionBias[2] = param;
|
||||
ctx->Pixel.PostConvolutionBias[3] = param;
|
||||
break;
|
||||
default:
|
||||
_mesa_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" );
|
||||
@@ -1113,14 +984,14 @@ _mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4],
|
||||
void
|
||||
_mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
|
||||
{
|
||||
const GLfloat rscale = (GLfloat) (ctx->Pixel.MapRtoRsize - 1);
|
||||
const GLfloat gscale = (GLfloat) (ctx->Pixel.MapGtoGsize - 1);
|
||||
const GLfloat bscale = (GLfloat) (ctx->Pixel.MapBtoBsize - 1);
|
||||
const GLfloat ascale = (GLfloat) (ctx->Pixel.MapAtoAsize - 1);
|
||||
const GLfloat *rMap = ctx->Pixel.MapRtoR;
|
||||
const GLfloat *gMap = ctx->Pixel.MapGtoG;
|
||||
const GLfloat *bMap = ctx->Pixel.MapBtoB;
|
||||
const GLfloat *aMap = ctx->Pixel.MapAtoA;
|
||||
const GLfloat rscale = (GLfloat) (ctx->PixelMaps.RtoR.Size - 1);
|
||||
const GLfloat gscale = (GLfloat) (ctx->PixelMaps.GtoG.Size - 1);
|
||||
const GLfloat bscale = (GLfloat) (ctx->PixelMaps.BtoB.Size - 1);
|
||||
const GLfloat ascale = (GLfloat) (ctx->PixelMaps.AtoA.Size - 1);
|
||||
const GLfloat *rMap = ctx->PixelMaps.RtoR.Map;
|
||||
const GLfloat *gMap = ctx->PixelMaps.GtoG.Map;
|
||||
const GLfloat *bMap = ctx->PixelMaps.BtoB.Map;
|
||||
const GLfloat *aMap = ctx->PixelMaps.AtoA.Map;
|
||||
GLuint i;
|
||||
for (i=0;i<n;i++) {
|
||||
GLfloat r = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F);
|
||||
@@ -1413,14 +1284,14 @@ void
|
||||
_mesa_map_ci_to_rgba( const GLcontext *ctx, GLuint n,
|
||||
const GLuint index[], GLfloat rgba[][4] )
|
||||
{
|
||||
GLuint rmask = ctx->Pixel.MapItoRsize - 1;
|
||||
GLuint gmask = ctx->Pixel.MapItoGsize - 1;
|
||||
GLuint bmask = ctx->Pixel.MapItoBsize - 1;
|
||||
GLuint amask = ctx->Pixel.MapItoAsize - 1;
|
||||
const GLfloat *rMap = ctx->Pixel.MapItoR;
|
||||
const GLfloat *gMap = ctx->Pixel.MapItoG;
|
||||
const GLfloat *bMap = ctx->Pixel.MapItoB;
|
||||
const GLfloat *aMap = ctx->Pixel.MapItoA;
|
||||
GLuint rmask = ctx->PixelMaps.ItoR.Size - 1;
|
||||
GLuint gmask = ctx->PixelMaps.ItoG.Size - 1;
|
||||
GLuint bmask = ctx->PixelMaps.ItoB.Size - 1;
|
||||
GLuint amask = ctx->PixelMaps.ItoA.Size - 1;
|
||||
const GLfloat *rMap = ctx->PixelMaps.ItoR.Map;
|
||||
const GLfloat *gMap = ctx->PixelMaps.ItoG.Map;
|
||||
const GLfloat *bMap = ctx->PixelMaps.ItoB.Map;
|
||||
const GLfloat *aMap = ctx->PixelMaps.ItoA.Map;
|
||||
GLuint i;
|
||||
for (i=0;i<n;i++) {
|
||||
rgba[i][RCOMP] = rMap[index[i] & rmask];
|
||||
@@ -1438,14 +1309,14 @@ void
|
||||
_mesa_map_ci8_to_rgba8(const GLcontext *ctx, GLuint n, const GLubyte index[],
|
||||
GLubyte rgba[][4])
|
||||
{
|
||||
GLuint rmask = ctx->Pixel.MapItoRsize - 1;
|
||||
GLuint gmask = ctx->Pixel.MapItoGsize - 1;
|
||||
GLuint bmask = ctx->Pixel.MapItoBsize - 1;
|
||||
GLuint amask = ctx->Pixel.MapItoAsize - 1;
|
||||
const GLubyte *rMap = ctx->Pixel.MapItoR8;
|
||||
const GLubyte *gMap = ctx->Pixel.MapItoG8;
|
||||
const GLubyte *bMap = ctx->Pixel.MapItoB8;
|
||||
const GLubyte *aMap = ctx->Pixel.MapItoA8;
|
||||
GLuint rmask = ctx->PixelMaps.ItoR.Size - 1;
|
||||
GLuint gmask = ctx->PixelMaps.ItoG.Size - 1;
|
||||
GLuint bmask = ctx->PixelMaps.ItoB.Size - 1;
|
||||
GLuint amask = ctx->PixelMaps.ItoA.Size - 1;
|
||||
const GLubyte *rMap = ctx->PixelMaps.ItoR.Map8;
|
||||
const GLubyte *gMap = ctx->PixelMaps.ItoG.Map8;
|
||||
const GLubyte *bMap = ctx->PixelMaps.ItoB.Map8;
|
||||
const GLubyte *aMap = ctx->PixelMaps.ItoA.Map8;
|
||||
GLuint i;
|
||||
for (i=0;i<n;i++) {
|
||||
rgba[i][RCOMP] = rMap[index[i] & rmask];
|
||||
@@ -1496,7 +1367,7 @@ update_image_transfer_state(GLcontext *ctx)
|
||||
if (ctx->Pixel.MapColorFlag)
|
||||
mask |= IMAGE_MAP_COLOR_BIT;
|
||||
|
||||
if (ctx->Pixel.ColorTableEnabled)
|
||||
if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION])
|
||||
mask |= IMAGE_COLOR_TABLE_BIT;
|
||||
|
||||
if (ctx->Pixel.Convolution1DEnabled ||
|
||||
@@ -1515,7 +1386,7 @@ update_image_transfer_state(GLcontext *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->Pixel.PostConvolutionColorTableEnabled)
|
||||
if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION])
|
||||
mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT;
|
||||
|
||||
if (ctx->ColorMatrixStack.Top->type != MATRIX_IDENTITY ||
|
||||
@@ -1529,7 +1400,7 @@ update_image_transfer_state(GLcontext *ctx)
|
||||
ctx->Pixel.PostColorMatrixBias[3] != 0.0F)
|
||||
mask |= IMAGE_COLOR_MATRIX_BIT;
|
||||
|
||||
if (ctx->Pixel.PostColorMatrixColorTableEnabled)
|
||||
if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX])
|
||||
mask |= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT;
|
||||
|
||||
if (ctx->Pixel.HistogramEnabled)
|
||||
@@ -1558,6 +1429,14 @@ void _mesa_update_pixel( GLcontext *ctx, GLuint new_state )
|
||||
/***** Initialization *****/
|
||||
/**********************************************************************/
|
||||
|
||||
static void
|
||||
init_pixelmap(struct gl_pixelmap *map)
|
||||
{
|
||||
map->Size = 1;
|
||||
map->Map[0] = 0.0;
|
||||
map->Map8[0] = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the context's PIXEL attribute group.
|
||||
@@ -1584,43 +1463,25 @@ _mesa_init_pixel( GLcontext *ctx )
|
||||
ctx->Pixel.ZoomY = 1.0;
|
||||
ctx->Pixel.MapColorFlag = GL_FALSE;
|
||||
ctx->Pixel.MapStencilFlag = GL_FALSE;
|
||||
ctx->Pixel.MapStoSsize = 1;
|
||||
ctx->Pixel.MapItoIsize = 1;
|
||||
ctx->Pixel.MapItoRsize = 1;
|
||||
ctx->Pixel.MapItoGsize = 1;
|
||||
ctx->Pixel.MapItoBsize = 1;
|
||||
ctx->Pixel.MapItoAsize = 1;
|
||||
ctx->Pixel.MapRtoRsize = 1;
|
||||
ctx->Pixel.MapGtoGsize = 1;
|
||||
ctx->Pixel.MapBtoBsize = 1;
|
||||
ctx->Pixel.MapAtoAsize = 1;
|
||||
ctx->Pixel.MapStoS[0] = 0;
|
||||
ctx->Pixel.MapItoI[0] = 0.0;
|
||||
ctx->Pixel.MapItoR[0] = 0.0;
|
||||
ctx->Pixel.MapItoG[0] = 0.0;
|
||||
ctx->Pixel.MapItoB[0] = 0.0;
|
||||
ctx->Pixel.MapItoA[0] = 0.0;
|
||||
ctx->Pixel.MapItoR8[0] = 0;
|
||||
ctx->Pixel.MapItoG8[0] = 0;
|
||||
ctx->Pixel.MapItoB8[0] = 0;
|
||||
ctx->Pixel.MapItoA8[0] = 0;
|
||||
ctx->Pixel.MapRtoR[0] = 0.0;
|
||||
ctx->Pixel.MapGtoG[0] = 0.0;
|
||||
ctx->Pixel.MapBtoB[0] = 0.0;
|
||||
ctx->Pixel.MapAtoA[0] = 0.0;
|
||||
init_pixelmap(&ctx->PixelMaps.StoS);
|
||||
init_pixelmap(&ctx->PixelMaps.ItoI);
|
||||
init_pixelmap(&ctx->PixelMaps.ItoR);
|
||||
init_pixelmap(&ctx->PixelMaps.ItoG);
|
||||
init_pixelmap(&ctx->PixelMaps.ItoB);
|
||||
init_pixelmap(&ctx->PixelMaps.ItoA);
|
||||
init_pixelmap(&ctx->PixelMaps.RtoR);
|
||||
init_pixelmap(&ctx->PixelMaps.GtoG);
|
||||
init_pixelmap(&ctx->PixelMaps.BtoB);
|
||||
init_pixelmap(&ctx->PixelMaps.AtoA);
|
||||
ctx->Pixel.HistogramEnabled = GL_FALSE;
|
||||
ctx->Pixel.MinMaxEnabled = GL_FALSE;
|
||||
ASSIGN_4V(ctx->Pixel.PostColorMatrixScale, 1.0, 1.0, 1.0, 1.0);
|
||||
ASSIGN_4V(ctx->Pixel.PostColorMatrixBias, 0.0, 0.0, 0.0, 0.0);
|
||||
ASSIGN_4V(ctx->Pixel.ColorTableScale, 1.0, 1.0, 1.0, 1.0);
|
||||
ASSIGN_4V(ctx->Pixel.ColorTableBias, 0.0, 0.0, 0.0, 0.0);
|
||||
ASSIGN_4V(ctx->Pixel.PCCTscale, 1.0, 1.0, 1.0, 1.0);
|
||||
ASSIGN_4V(ctx->Pixel.PCCTbias, 0.0, 0.0, 0.0, 0.0);
|
||||
ASSIGN_4V(ctx->Pixel.PCMCTscale, 1.0, 1.0, 1.0, 1.0);
|
||||
ASSIGN_4V(ctx->Pixel.PCMCTbias, 0.0, 0.0, 0.0, 0.0);
|
||||
ctx->Pixel.ColorTableEnabled = GL_FALSE;
|
||||
ctx->Pixel.PostConvolutionColorTableEnabled = GL_FALSE;
|
||||
ctx->Pixel.PostColorMatrixColorTableEnabled = GL_FALSE;
|
||||
for (i = 0; i < COLORTABLE_MAX; i++) {
|
||||
ASSIGN_4V(ctx->Pixel.ColorTableScale[i], 1.0, 1.0, 1.0, 1.0);
|
||||
ASSIGN_4V(ctx->Pixel.ColorTableBias[i], 0.0, 0.0, 0.0, 0.0);
|
||||
ctx->Pixel.ColorTableEnabled[i] = GL_FALSE;
|
||||
}
|
||||
ctx->Pixel.Convolution1DEnabled = GL_FALSE;
|
||||
ctx->Pixel.Convolution2DEnabled = GL_FALSE;
|
||||
ctx->Pixel.Separable2DEnabled = GL_FALSE;
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 6.5.1
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -57,6 +57,13 @@ _mesa_PointSize( GLfloat size )
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_POINT);
|
||||
ctx->Point.Size = size;
|
||||
ctx->Point._Size = CLAMP(ctx->Point.Size,
|
||||
ctx->Point.MinSize,
|
||||
ctx->Point.MaxSize);
|
||||
|
||||
ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 ||
|
||||
ctx->Point.Params[1] != 0.0 ||
|
||||
ctx->Point.Params[2] != 0.0);
|
||||
|
||||
if (ctx->Driver.PointSize)
|
||||
ctx->Driver.PointSize(ctx, size);
|
||||
@@ -231,36 +238,6 @@ _mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update derived point-related state.
|
||||
*/
|
||||
void
|
||||
_mesa_update_point(GLcontext *ctx)
|
||||
{
|
||||
/* clamp to user-specified limits now, clamp to ctx->Const.Min/Max
|
||||
* limits during rasterization.
|
||||
*/
|
||||
ctx->Point._Size = CLAMP(ctx->Point.Size,
|
||||
ctx->Point.MinSize,
|
||||
ctx->Point.MaxSize);
|
||||
|
||||
if (ctx->Point._Size == 1.0F)
|
||||
ctx->_TriangleCaps &= ~DD_POINT_SIZE;
|
||||
else
|
||||
ctx->_TriangleCaps |= DD_POINT_SIZE;
|
||||
|
||||
ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 ||
|
||||
ctx->Point.Params[1] != 0.0 ||
|
||||
ctx->Point.Params[2] != 0.0);
|
||||
|
||||
if (ctx->Point._Attenuated)
|
||||
ctx->_TriangleCaps |= DD_POINT_ATTEN;
|
||||
else
|
||||
ctx->_TriangleCaps &= ~DD_POINT_ATTEN;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the context point state.
|
||||
*
|
||||
|
||||
@@ -50,9 +50,6 @@ _mesa_PointParameterfEXT( GLenum pname, GLfloat param );
|
||||
extern void GLAPIENTRY
|
||||
_mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params );
|
||||
|
||||
extern void
|
||||
_mesa_update_point(GLcontext *ctx);
|
||||
|
||||
extern void
|
||||
_mesa_init_point( GLcontext * ctx );
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.3
|
||||
* Version: 6.5.1
|
||||
*
|
||||
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -167,13 +167,8 @@ _mesa_PolygonMode( GLenum face, GLenum mode )
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->_TriangleCaps &= ~DD_TRI_UNFILLED;
|
||||
if (ctx->Polygon.FrontMode!=GL_FILL || ctx->Polygon.BackMode!=GL_FILL)
|
||||
ctx->_TriangleCaps |= DD_TRI_UNFILLED;
|
||||
|
||||
if (ctx->Driver.PolygonMode) {
|
||||
(*ctx->Driver.PolygonMode)( ctx, face, mode );
|
||||
}
|
||||
if (ctx->Driver.PolygonMode)
|
||||
ctx->Driver.PolygonMode(ctx, face, mode);
|
||||
}
|
||||
|
||||
#if _HAVE_FULL_GL
|
||||
@@ -320,32 +315,6 @@ _mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
|
||||
#endif
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/** \name State Management */
|
||||
/*@{*/
|
||||
|
||||
/*
|
||||
* Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
|
||||
* in ctx->_TriangleCaps if needed.
|
||||
*/
|
||||
void _mesa_update_polygon( GLcontext *ctx )
|
||||
{
|
||||
ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET);
|
||||
|
||||
if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
|
||||
ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
|
||||
|
||||
/* Any Polygon offsets enabled? */
|
||||
if (ctx->Polygon.OffsetPoint ||
|
||||
ctx->Polygon.OffsetLine ||
|
||||
ctx->Polygon.OffsetFill) {
|
||||
ctx->_TriangleCaps |= DD_TRI_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/** \name Initialization */
|
||||
/*@{*/
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.3
|
||||
* Version: 6.5.1
|
||||
*
|
||||
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -60,9 +60,6 @@ _mesa_PolygonStipple( const GLubyte *mask );
|
||||
extern void GLAPIENTRY
|
||||
_mesa_GetPolygonStipple( GLubyte *mask );
|
||||
|
||||
extern void
|
||||
_mesa_update_polygon( GLcontext *ctx );
|
||||
|
||||
extern void
|
||||
_mesa_init_polygon( GLcontext * ctx );
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "context.h"
|
||||
#include "hash.h"
|
||||
#include "imports.h"
|
||||
#include "occlude.h"
|
||||
#include "queryobj.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.3
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -112,9 +112,7 @@ userclip_point( GLcontext *ctx, const GLfloat v[] )
|
||||
|
||||
|
||||
/**
|
||||
* This has been split off to allow the normal shade routines to
|
||||
* get a little closer to the vertex buffer, and to use the
|
||||
* GLvector objects directly.
|
||||
* Compute lighting for the raster position. Both RGB and CI modes computed.
|
||||
* \param ctx the context
|
||||
* \param vertex vertex location
|
||||
* \param normal normal vector
|
||||
@@ -130,42 +128,44 @@ shade_rastpos(GLcontext *ctx,
|
||||
GLfloat Rspec[4],
|
||||
GLfloat *Rindex)
|
||||
{
|
||||
GLfloat (*base)[3] = ctx->Light._BaseColor;
|
||||
struct gl_light *light;
|
||||
GLfloat diffuseColor[4], specularColor[4];
|
||||
GLfloat diffuse = 0, specular = 0;
|
||||
/*const*/ GLfloat (*base)[3] = ctx->Light._BaseColor;
|
||||
const struct gl_light *light;
|
||||
GLfloat diffuseColor[4], specularColor[4]; /* for RGB mode only */
|
||||
GLfloat diffuseCI = 0.0, specularCI = 0.0; /* for CI mode only */
|
||||
|
||||
if (!ctx->_ShineTable[0] || !ctx->_ShineTable[1])
|
||||
_mesa_validate_all_lighting_tables( ctx );
|
||||
|
||||
COPY_3V(diffuseColor, base[0]);
|
||||
diffuseColor[3] = CLAMP(
|
||||
ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3], 0.0F, 1.0F );
|
||||
ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 0.0);
|
||||
ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
foreach (light, &ctx->Light.EnabledList) {
|
||||
GLfloat n_dot_h;
|
||||
GLfloat attenuation = 1.0;
|
||||
GLfloat VP[3];
|
||||
GLfloat VP[3]; /* vector from vertex to light pos */
|
||||
GLfloat n_dot_VP;
|
||||
GLfloat *h;
|
||||
GLfloat diffuseContrib[3], specularContrib[3];
|
||||
GLboolean normalized;
|
||||
|
||||
if (!(light->_Flags & LIGHT_POSITIONAL)) {
|
||||
/* light at infinity */
|
||||
COPY_3V(VP, light->_VP_inf_norm);
|
||||
attenuation = light->_VP_inf_spot_attenuation;
|
||||
}
|
||||
else {
|
||||
/* local/positional light */
|
||||
GLfloat d;
|
||||
|
||||
/* VP = vector from vertex pos to light[i].pos */
|
||||
SUB_3V(VP, light->_Position, vertex);
|
||||
/* d = length(VP) */
|
||||
d = (GLfloat) LEN_3FV( VP );
|
||||
|
||||
if ( d > 1e-6) {
|
||||
if (d > 1.0e-6) {
|
||||
/* normalize VP */
|
||||
GLfloat invd = 1.0F / d;
|
||||
SELF_SCALE_SCALAR_3V(VP, invd);
|
||||
}
|
||||
|
||||
/* atti */
|
||||
attenuation = 1.0F / (light->ConstantAttenuation + d *
|
||||
(light->LinearAttenuation + d *
|
||||
light->QuadraticAttenuation));
|
||||
@@ -196,43 +196,39 @@ shade_rastpos(GLcontext *ctx,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Ambient + diffuse */
|
||||
COPY_3V(diffuseContrib, light->_MatAmbient[0]);
|
||||
ACC_SCALE_SCALAR_3V(diffuseContrib, n_dot_VP, light->_MatDiffuse[0]);
|
||||
diffuse += n_dot_VP * light->_dli * attenuation;
|
||||
diffuseCI += n_dot_VP * light->_dli * attenuation;
|
||||
|
||||
/* Specular */
|
||||
{
|
||||
const GLfloat *h;
|
||||
GLfloat n_dot_h;
|
||||
|
||||
ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0);
|
||||
|
||||
{
|
||||
if (ctx->Light.Model.LocalViewer) {
|
||||
GLfloat v[3];
|
||||
COPY_3V(v, vertex);
|
||||
NORMALIZE_3FV(v);
|
||||
SUB_3V(VP, VP, v);
|
||||
NORMALIZE_3FV(VP);
|
||||
h = VP;
|
||||
normalized = 0;
|
||||
}
|
||||
else if (light->_Flags & LIGHT_POSITIONAL) {
|
||||
ACC_3V(VP, ctx->_EyeZDir);
|
||||
NORMALIZE_3FV(VP);
|
||||
h = VP;
|
||||
ACC_3V(h, ctx->_EyeZDir);
|
||||
normalized = 0;
|
||||
}
|
||||
else {
|
||||
h = light->_h_inf_norm;
|
||||
normalized = 1;
|
||||
}
|
||||
|
||||
n_dot_h = DOT3(normal, h);
|
||||
|
||||
if (n_dot_h > 0.0F) {
|
||||
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
|
||||
GLfloat spec_coef;
|
||||
GLfloat shininess = mat[MAT_ATTRIB_FRONT_SHININESS][0];
|
||||
|
||||
if (!normalized) {
|
||||
n_dot_h *= n_dot_h;
|
||||
n_dot_h /= LEN_SQUARED_3FV( h );
|
||||
shininess *= .5;
|
||||
}
|
||||
|
||||
GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec_coef );
|
||||
|
||||
if (spec_coef > 1.0e-10) {
|
||||
@@ -244,7 +240,8 @@ shade_rastpos(GLcontext *ctx,
|
||||
ACC_SCALE_SCALAR_3V( diffuseContrib, spec_coef,
|
||||
light->_MatSpecular[0]);
|
||||
}
|
||||
specular += spec_coef * light->_sli * attenuation;
|
||||
/*assert(light->_sli > 0.0);*/
|
||||
specularCI += spec_coef * light->_sli * attenuation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,8 +265,8 @@ shade_rastpos(GLcontext *ctx,
|
||||
GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT];
|
||||
GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT];
|
||||
GLfloat i = (ind[MAT_INDEX_AMBIENT]
|
||||
+ diffuse * (1.0F-specular) * d_a
|
||||
+ specular * s_a);
|
||||
+ diffuseCI * (1.0F-specularCI) * d_a
|
||||
+ specularCI * s_a);
|
||||
if (i > ind[MAT_INDEX_SPECULAR]) {
|
||||
i = ind[MAT_INDEX_SPECULAR];
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.1
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -45,7 +45,7 @@ Delete_wrapper(struct gl_renderbuffer *rb)
|
||||
/* Decrement reference count on the buffer we're wrapping and delete
|
||||
* it if refcount hits zero.
|
||||
*/
|
||||
_mesa_dereference_renderbuffer(&rb->Wrapped);
|
||||
_mesa_reference_renderbuffer(&rb->Wrapped, NULL);
|
||||
|
||||
/* delete myself */
|
||||
_mesa_delete_renderbuffer(rb);
|
||||
|
||||
@@ -1192,9 +1192,12 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
ASSERT(rb->PutMonoValues);
|
||||
|
||||
/* free old buffer storage */
|
||||
if (rb->Data)
|
||||
if (rb->Data) {
|
||||
_mesa_free(rb->Data);
|
||||
rb->Data = NULL;
|
||||
}
|
||||
|
||||
if (width > 0 && height > 0) {
|
||||
/* allocate new buffer storage */
|
||||
rb->Data = _mesa_malloc(width * height * pixelSize);
|
||||
if (rb->Data == NULL) {
|
||||
@@ -1205,6 +1208,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
width, height, pixelSize);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
rb->Width = width;
|
||||
rb->Height = height;
|
||||
@@ -1431,6 +1435,17 @@ put_mono_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src)
|
||||
{
|
||||
ASSERT(dst->_ActualFormat == GL_ALPHA8);
|
||||
ASSERT(src->_ActualFormat == GL_ALPHA8);
|
||||
ASSERT(dst->Width == src->Width);
|
||||
ASSERT(dst->Height == src->Height);
|
||||
|
||||
_mesa_memcpy(dst->Data, src->Data, dst->Width * dst->Height * sizeof(GLubyte));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/**********************************************************************/
|
||||
@@ -1456,9 +1471,10 @@ _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
|
||||
{
|
||||
_glthread_INIT_MUTEX(rb->Mutex);
|
||||
|
||||
rb->Magic = RB_MAGIC;
|
||||
rb->ClassID = 0;
|
||||
rb->Name = name;
|
||||
rb->RefCount = 1;
|
||||
rb->RefCount = 0;
|
||||
rb->Delete = _mesa_delete_renderbuffer;
|
||||
|
||||
/* The rest of these should be set later by the caller of this function or
|
||||
@@ -1761,6 +1777,27 @@ _mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For framebuffers that use a software alpha channel wrapper
|
||||
* created by _mesa_add_alpha_renderbuffer or _mesa_add_soft_renderbuffers,
|
||||
* copy the back buffer alpha channel into the front buffer alpha channel.
|
||||
*/
|
||||
void
|
||||
_mesa_copy_soft_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb)
|
||||
{
|
||||
if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer &&
|
||||
fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer)
|
||||
copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer,
|
||||
fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
|
||||
|
||||
|
||||
if (fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer &&
|
||||
fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer)
|
||||
copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer,
|
||||
fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a software-based depth renderbuffer to the given framebuffer.
|
||||
* This is a helper routine for device drivers when creating a
|
||||
@@ -2069,9 +2106,7 @@ _mesa_add_renderbuffer(struct gl_framebuffer *fb,
|
||||
|
||||
fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT;
|
||||
fb->Attachment[bufferName].Complete = GL_TRUE;
|
||||
fb->Attachment[bufferName].Renderbuffer = rb;
|
||||
|
||||
rb->RefCount++;
|
||||
_mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb);
|
||||
}
|
||||
|
||||
|
||||
@@ -2089,37 +2124,60 @@ _mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName)
|
||||
if (!rb)
|
||||
return;
|
||||
|
||||
_mesa_dereference_renderbuffer(&rb);
|
||||
_mesa_reference_renderbuffer(&rb, NULL);
|
||||
|
||||
fb->Attachment[bufferName].Renderbuffer = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrement the reference count on a renderbuffer and delete it when
|
||||
* the refcount hits zero.
|
||||
* Note: we pass the address of a pointer and set it to NULL if we delete it.
|
||||
* Set *ptr to point to rb. If *ptr points to another renderbuffer,
|
||||
* dereference that buffer first. The new renderbuffer's refcount will
|
||||
* be incremented. The old renderbuffer's refcount will be decremented.
|
||||
*/
|
||||
void
|
||||
_mesa_dereference_renderbuffer(struct gl_renderbuffer **rb)
|
||||
_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr,
|
||||
struct gl_renderbuffer *rb)
|
||||
{
|
||||
GLboolean deleteFlag = GL_FALSE;
|
||||
|
||||
_glthread_LOCK_MUTEX((*rb)->Mutex);
|
||||
{
|
||||
ASSERT((*rb)->RefCount > 0);
|
||||
(*rb)->RefCount--;
|
||||
deleteFlag = ((*rb)->RefCount == 0);
|
||||
assert(ptr);
|
||||
if (*ptr == rb) {
|
||||
/* no change */
|
||||
return;
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX((*rb)->Mutex);
|
||||
|
||||
if (*ptr) {
|
||||
/* Unreference the old renderbuffer */
|
||||
GLboolean deleteFlag = GL_FALSE;
|
||||
struct gl_renderbuffer *oldRb = *ptr;
|
||||
|
||||
assert(oldRb->Magic == RB_MAGIC);
|
||||
_glthread_LOCK_MUTEX(oldRb->Mutex);
|
||||
assert(oldRb->Magic == RB_MAGIC);
|
||||
ASSERT(oldRb->RefCount > 0);
|
||||
oldRb->RefCount--;
|
||||
/*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/
|
||||
deleteFlag = (oldRb->RefCount == 0);
|
||||
_glthread_UNLOCK_MUTEX(oldRb->Mutex);
|
||||
|
||||
if (deleteFlag) {
|
||||
(*rb)->Delete(*rb);
|
||||
*rb = NULL;
|
||||
}
|
||||
oldRb->Magic = 0; /* now invalid memory! */
|
||||
oldRb->Delete(oldRb);
|
||||
}
|
||||
|
||||
*ptr = NULL;
|
||||
}
|
||||
assert(!*ptr);
|
||||
|
||||
if (rb) {
|
||||
assert(rb->Magic == RB_MAGIC);
|
||||
/* reference new renderbuffer */
|
||||
_glthread_LOCK_MUTEX(rb->Mutex);
|
||||
rb->RefCount++;
|
||||
/*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/
|
||||
_glthread_UNLOCK_MUTEX(rb->Mutex);
|
||||
*ptr = rb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -2143,4 +2201,3 @@ _mesa_new_depthstencil_renderbuffer(GLcontext *ctx, GLuint name)
|
||||
|
||||
return dsrb;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,9 @@ _mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
|
||||
GLboolean frontLeft, GLboolean backLeft,
|
||||
GLboolean frontRight, GLboolean backRight);
|
||||
|
||||
extern void
|
||||
_mesa_copy_soft_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
|
||||
GLuint depthBits);
|
||||
@@ -99,7 +102,8 @@ extern void
|
||||
_mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName);
|
||||
|
||||
extern void
|
||||
_mesa_dereference_renderbuffer(struct gl_renderbuffer **rb);
|
||||
_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr,
|
||||
struct gl_renderbuffer *rb);
|
||||
|
||||
extern struct gl_renderbuffer *
|
||||
_mesa_new_depthstencil_renderbuffer(GLcontext *ctx, GLuint name);
|
||||
|
||||
@@ -0,0 +1,680 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 2004-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "shaders.h"
|
||||
|
||||
|
||||
/**
|
||||
* These are basically just wrappers/adaptors for calling the
|
||||
* ctx->Driver.foobar() GLSL-related functions.
|
||||
*
|
||||
* Things are biased toward the OpenGL 2.0 functions rather than the
|
||||
* ARB extensions (i.e. the ARB functions are layered on the 2.0 functions).
|
||||
*
|
||||
* The general idea here is to allow enough modularity such that a
|
||||
* completely different GLSL implemenation can be plugged in and co-exist
|
||||
* with Mesa's native GLSL code.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_AttachObjectARB(GLhandleARB program, GLhandleARB shader)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.AttachShader(ctx, program, shader);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_AttachShader(GLuint program, GLuint shader)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.AttachShader(ctx, program, shader);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_BindAttribLocationARB(GLhandleARB program, GLuint index,
|
||||
const GLcharARB *name)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.BindAttribLocation(ctx, program, index, name);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_CompileShaderARB(GLhandleARB shaderObj)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.CompileShader(ctx, shaderObj);
|
||||
}
|
||||
|
||||
|
||||
GLuint GLAPIENTRY
|
||||
_mesa_CreateShader(GLenum type)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.CreateShader(ctx, type);
|
||||
}
|
||||
|
||||
|
||||
GLhandleARB APIENTRY
|
||||
_mesa_CreateShaderObjectARB(GLenum type)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.CreateShader(ctx, type);
|
||||
}
|
||||
|
||||
|
||||
GLuint GLAPIENTRY
|
||||
_mesa_CreateProgram(void)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.CreateProgram(ctx);
|
||||
}
|
||||
|
||||
|
||||
GLhandleARB APIENTRY
|
||||
_mesa_CreateProgramObjectARB(void)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.CreateProgram(ctx);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_DeleteObjectARB(GLhandleARB obj)
|
||||
{
|
||||
if (obj) {
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
if (ctx->Driver.IsProgram(ctx, obj)) {
|
||||
ctx->Driver.DeleteProgram2(ctx, obj);
|
||||
}
|
||||
else if (ctx->Driver.IsShader(ctx, obj)) {
|
||||
ctx->Driver.DeleteShader(ctx, obj);
|
||||
}
|
||||
else {
|
||||
/* error? */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_DeleteProgram(GLuint name)
|
||||
{
|
||||
if (name) {
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.DeleteProgram2(ctx, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_DeleteShader(GLuint name)
|
||||
{
|
||||
if (name) {
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.DeleteShader(ctx, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_DetachObjectARB(GLhandleARB program, GLhandleARB shader)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.DetachShader(ctx, program, shader);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_DetachShader(GLuint program, GLuint shader)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.DetachShader(ctx, program, shader);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetActiveAttribARB(GLhandleARB program, GLuint index,
|
||||
GLsizei maxLength, GLsizei * length, GLint * size,
|
||||
GLenum * type, GLcharARB * name)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetActiveAttrib(ctx, program, index, maxLength, length, size,
|
||||
type, name);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetActiveUniformARB(GLhandleARB program, GLuint index,
|
||||
GLsizei maxLength, GLsizei * length, GLint * size,
|
||||
GLenum * type, GLcharARB * name)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetActiveUniform(ctx, program, index, maxLength, length, size,
|
||||
type, name);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetAttachedObjectsARB(GLhandleARB container, GLsizei maxCount,
|
||||
GLsizei * count, GLhandleARB * obj)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetAttachedShaders(ctx, container, maxCount, count, obj);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetAttachedShaders(GLuint program, GLsizei maxCount,
|
||||
GLsizei *count, GLuint *obj)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetAttachedShaders(ctx, program, maxCount, count, obj);
|
||||
}
|
||||
|
||||
|
||||
GLint GLAPIENTRY
|
||||
_mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.GetAttribLocation(ctx, program, name);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei * length,
|
||||
GLcharARB * infoLog)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
/* Implement in terms of GetProgramInfoLog, GetShaderInfoLog */
|
||||
if (ctx->Driver.IsProgram(ctx, object)) {
|
||||
ctx->Driver.GetProgramInfoLog(ctx, object, maxLength, length, infoLog);
|
||||
}
|
||||
else if (ctx->Driver.IsShader(ctx, object)) {
|
||||
ctx->Driver.GetShaderInfoLog(ctx, object, maxLength, length, infoLog);
|
||||
}
|
||||
else {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetInfoLogARB");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
/* Implement in terms of GetProgramiv, GetShaderiv */
|
||||
if (ctx->Driver.IsProgram(ctx, object)) {
|
||||
ctx->Driver.GetProgramiv(ctx, object, pname, params);
|
||||
}
|
||||
else if (ctx->Driver.IsShader(ctx, object)) {
|
||||
ctx->Driver.GetShaderiv(ctx, object, pname, params);
|
||||
}
|
||||
else {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetObjectParameterfvARB(GLhandleARB object, GLenum pname,
|
||||
GLfloat *params)
|
||||
{
|
||||
GLint iparams[1]; /* XXX is one element enough? */
|
||||
_mesa_GetObjectParameterivARB(object, pname, iparams);
|
||||
params[0] = (GLfloat) iparams[0];
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetProgramiv(ctx, program, pname, params);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetShaderiv(ctx, shader, pname, params);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize,
|
||||
GLsizei *length, GLchar *infoLog)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetProgramInfoLog(ctx, program, bufSize, length, infoLog);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize,
|
||||
GLsizei *length, GLchar *infoLog)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetShaderInfoLog(ctx, shader, bufSize, length, infoLog);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetShaderSourceARB(GLhandleARB shader, GLsizei maxLength,
|
||||
GLsizei *length, GLcharARB *sourceOut)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetShaderSource(ctx, shader, maxLength, length, sourceOut);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetUniformfvARB(GLhandleARB program, GLint location, GLfloat * params)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.GetUniformfv(ctx, program, location, params);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint * params)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLfloat fparams[16]; /* XXX is 16 enough? */
|
||||
GLuint i;
|
||||
ctx->Driver.GetUniformfv(ctx, program, location, fparams);
|
||||
for (i = 0; i < 16; i++)
|
||||
params[i] = (GLint) fparams[i]; /* XXX correct? */
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
GLint APIENTRY
|
||||
_mesa_GetUniformLocation(GLuint program, const GLcharARB *name)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.GetUniformLocation(ctx, program, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
GLhandleARB GLAPIENTRY
|
||||
_mesa_GetHandleARB(GLenum pname)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.GetHandle(ctx, pname);
|
||||
}
|
||||
|
||||
|
||||
GLint APIENTRY
|
||||
_mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.GetUniformLocation(ctx, programObj, name);
|
||||
}
|
||||
|
||||
|
||||
GLboolean GLAPIENTRY
|
||||
_mesa_IsProgram(GLuint name)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.IsProgram(ctx, name);
|
||||
}
|
||||
|
||||
|
||||
GLboolean GLAPIENTRY
|
||||
_mesa_IsShader(GLuint name)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
return ctx->Driver.IsShader(ctx, name);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_LinkProgramARB(GLhandleARB programObj)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.LinkProgram(ctx, programObj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via glShaderSource() and glShaderSourceARB() API functions.
|
||||
* Basically, concatenate the source code strings into one long string
|
||||
* and pass it to ctx->Driver.ShaderSource().
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
_mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count,
|
||||
const GLcharARB ** string, const GLint * length)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLint *offsets;
|
||||
GLsizei i, totalLength;
|
||||
GLcharARB *source;
|
||||
|
||||
if (string == NULL) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* This array holds offsets of where the appropriate string ends, thus the
|
||||
* last element will be set to the total length of the source code.
|
||||
*/
|
||||
offsets = (GLint *) _mesa_malloc(count * sizeof(GLint));
|
||||
if (offsets == NULL) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (string[i] == NULL) {
|
||||
_mesa_free((GLvoid *) offsets);
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB(null string)");
|
||||
return;
|
||||
}
|
||||
if (length == NULL || length[i] < 0)
|
||||
offsets[i] = _mesa_strlen(string[i]);
|
||||
else
|
||||
offsets[i] = length[i];
|
||||
/* accumulate string lengths */
|
||||
if (i > 0)
|
||||
offsets[i] += offsets[i - 1];
|
||||
}
|
||||
|
||||
/* Total length of source string is sum off all strings plus two.
|
||||
* One extra byte for terminating zero, another extra byte to silence
|
||||
* valgrind warnings in the parser/grammer code.
|
||||
*/
|
||||
totalLength = offsets[count - 1] + 2;
|
||||
source = (GLcharARB *) _mesa_malloc(totalLength * sizeof(GLcharARB));
|
||||
if (source == NULL) {
|
||||
_mesa_free((GLvoid *) offsets);
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
GLint start = (i > 0) ? offsets[i - 1] : 0;
|
||||
_mesa_memcpy(source + start, string[i],
|
||||
(offsets[i] - start) * sizeof(GLcharARB));
|
||||
}
|
||||
source[totalLength - 1] = '\0';
|
||||
source[totalLength - 2] = '\0';
|
||||
|
||||
ctx->Driver.ShaderSource(ctx, shaderObj, source);
|
||||
|
||||
_mesa_free(offsets);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform1fARB(GLint location, GLfloat v0)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, 1, &v0, GL_FLOAT);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform2fARB(GLint location, GLfloat v0, GLfloat v1)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLfloat v[2];
|
||||
v[0] = v0;
|
||||
v[1] = v1;
|
||||
ctx->Driver.Uniform(ctx, location, 1, v, GL_FLOAT_VEC2);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform3fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLfloat v[3];
|
||||
v[0] = v0;
|
||||
v[1] = v1;
|
||||
v[2] = v2;
|
||||
ctx->Driver.Uniform(ctx, location, 1, v, GL_FLOAT_VEC3);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform4fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2,
|
||||
GLfloat v3)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLfloat v[4];
|
||||
v[0] = v0;
|
||||
v[1] = v1;
|
||||
v[2] = v2;
|
||||
v[3] = v3;
|
||||
ctx->Driver.Uniform(ctx, location, 1, v, GL_FLOAT_VEC4);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform1iARB(GLint location, GLint v0)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, 1, &v0, GL_INT);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform2iARB(GLint location, GLint v0, GLint v1)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLint v[2];
|
||||
v[0] = v0;
|
||||
v[1] = v1;
|
||||
ctx->Driver.Uniform(ctx, location, 1, v, GL_INT_VEC2);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform3iARB(GLint location, GLint v0, GLint v1, GLint v2)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLint v[3];
|
||||
v[0] = v0;
|
||||
v[1] = v1;
|
||||
v[2] = v2;
|
||||
ctx->Driver.Uniform(ctx, location, 1, v, GL_INT_VEC3);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform4iARB(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLint v[4];
|
||||
v[0] = v0;
|
||||
v[1] = v1;
|
||||
v[2] = v2;
|
||||
v[3] = v3;
|
||||
ctx->Driver.Uniform(ctx, location, 1, v, GL_INT_VEC4);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform1fvARB(GLint location, GLsizei count, const GLfloat * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, count, value, GL_FLOAT);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform2fvARB(GLint location, GLsizei count, const GLfloat * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, count, value, GL_FLOAT_VEC2);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform3fvARB(GLint location, GLsizei count, const GLfloat * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, count, value, GL_FLOAT_VEC3);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform4fvARB(GLint location, GLsizei count, const GLfloat * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, count, value, GL_FLOAT_VEC4);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform1ivARB(GLint location, GLsizei count, const GLint * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, count, value, GL_INT);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform2ivARB(GLint location, GLsizei count, const GLint * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, count, value, GL_INT_VEC2);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform3ivARB(GLint location, GLsizei count, const GLint * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, count, value, GL_INT_VEC3);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_Uniform4ivARB(GLint location, GLsizei count, const GLint * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.Uniform(ctx, location, count, value, GL_INT_VEC4);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.UniformMatrix(ctx, 2, 2, GL_FLOAT_MAT2,
|
||||
location, count, transpose, value);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.UniformMatrix(ctx, 3, 3, GL_FLOAT_MAT3,
|
||||
location, count, transpose, value);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat * value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.UniformMatrix(ctx, 4, 4, GL_FLOAT_MAT4,
|
||||
location, count, transpose, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Non-square UniformMatrix are OpenGL 2.1
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat *value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.UniformMatrix(ctx, 2, 3, GL_FLOAT_MAT2x3,
|
||||
location, count, transpose, value);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat *value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.UniformMatrix(ctx, 3, 2, GL_FLOAT_MAT3x2,
|
||||
location, count, transpose, value);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat *value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.UniformMatrix(ctx, 2, 4, GL_FLOAT_MAT2x4,
|
||||
location, count, transpose, value);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat *value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.UniformMatrix(ctx, 4, 2, GL_FLOAT_MAT4x2,
|
||||
location, count, transpose, value);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat *value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.UniformMatrix(ctx, 3, 4, GL_FLOAT_MAT3x4,
|
||||
location, count, transpose, value);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat *value)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.UniformMatrix(ctx, 4, 3, GL_FLOAT_MAT4x3,
|
||||
location, count, transpose, value);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_UseProgramObjectARB(GLhandleARB program)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
ctx->Driver.UseProgram(ctx, program);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_ValidateProgramARB(GLhandleARB program)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ctx->Driver.ValidateProgram(ctx, program);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 2004-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 2004-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -22,124 +22,13 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SHADEROBJECTS_H
|
||||
#define SHADEROBJECTS_H
|
||||
|
||||
#include "context.h"
|
||||
#ifndef SHADERS_H
|
||||
#define SHADERS_H
|
||||
|
||||
#if FEATURE_ARB_shader_objects
|
||||
|
||||
/**
|
||||
* gl2 unique interface identifier.
|
||||
* Each gl2 interface has its own interface id used for object queries.
|
||||
*/
|
||||
enum gl2_uiid
|
||||
{
|
||||
UIID_UNKNOWN, /* supported by all objects */
|
||||
UIID_GENERIC, /* generic object */
|
||||
UIID_CONTAINER, /* contains generic objects */
|
||||
UIID_SHADER, /* shader object */
|
||||
UIID_FRAGMENT_SHADER, /* fragment shader */
|
||||
UIID_VERTEX_SHADER, /* vertex shader */
|
||||
UIID_PROGRAM, /* program object */
|
||||
UIID_3DLABS_SHHANDLE, /* encapsulates 3DLabs' ShHandle */
|
||||
UIID_DEBUG /* debug object */
|
||||
};
|
||||
|
||||
struct gl2_unknown_intf
|
||||
{
|
||||
GLvoid (* AddRef) (struct gl2_unknown_intf **);
|
||||
GLvoid (* Release) (struct gl2_unknown_intf **);
|
||||
struct gl2_unknown_intf **(* QueryInterface) (struct gl2_unknown_intf **, enum gl2_uiid uiid);
|
||||
};
|
||||
|
||||
struct gl2_generic_intf
|
||||
{
|
||||
struct gl2_unknown_intf _unknown;
|
||||
GLvoid (* Delete) (struct gl2_generic_intf **);
|
||||
GLenum (* GetType) (struct gl2_generic_intf **);
|
||||
GLhandleARB (* GetName) (struct gl2_generic_intf **);
|
||||
GLboolean (* GetDeleteStatus) (struct gl2_generic_intf **);
|
||||
GLvoid (* GetInfoLog) (struct gl2_generic_intf **, GLsizei, GLcharARB *);
|
||||
GLsizei (* GetInfoLogLength) (struct gl2_generic_intf **);
|
||||
};
|
||||
|
||||
struct gl2_container_intf
|
||||
{
|
||||
struct gl2_generic_intf _generic;
|
||||
GLboolean (* Attach) (struct gl2_container_intf **, struct gl2_generic_intf **);
|
||||
GLboolean (* Detach) (struct gl2_container_intf **, struct gl2_generic_intf **);
|
||||
GLsizei (* GetAttachedCount) (struct gl2_container_intf **);
|
||||
struct gl2_generic_intf **(* GetAttached) (struct gl2_container_intf **, GLuint);
|
||||
};
|
||||
|
||||
struct gl2_shader_intf
|
||||
{
|
||||
struct gl2_generic_intf _generic;
|
||||
GLenum (* GetSubType) (struct gl2_shader_intf **);
|
||||
GLboolean (* GetCompileStatus) (struct gl2_shader_intf **);
|
||||
GLvoid (* SetSource) (struct gl2_shader_intf **, GLcharARB *, GLint *, GLsizei);
|
||||
const GLcharARB *(* GetSource) (struct gl2_shader_intf **);
|
||||
GLvoid (* Compile) (struct gl2_shader_intf **);
|
||||
};
|
||||
|
||||
struct gl2_program_intf
|
||||
{
|
||||
struct gl2_container_intf _container;
|
||||
GLboolean (* GetLinkStatus) (struct gl2_program_intf **);
|
||||
GLboolean (* GetValidateStatus) (struct gl2_program_intf **);
|
||||
GLvoid (* Link) (struct gl2_program_intf **);
|
||||
GLvoid (* Validate) (struct gl2_program_intf **);
|
||||
GLvoid (* UpdateFixedUniforms) (struct gl2_program_intf **);
|
||||
GLvoid (* UpdateFixedAttrib) (struct gl2_program_intf **, GLuint, GLvoid *, GLuint, GLuint,
|
||||
GLboolean);
|
||||
GLvoid (* UpdateFixedVarying) (struct gl2_program_intf **, GLuint, GLvoid *, GLuint, GLuint,
|
||||
GLboolean);
|
||||
GLvoid (* GetTextureImageUsage) (struct gl2_program_intf **, GLbitfield *);
|
||||
GLboolean (* IsShaderPresent) (struct gl2_program_intf **, GLenum);
|
||||
GLvoid (* GetActiveUniform) (struct gl2_program_intf **, GLuint index, GLsizei maxLength,
|
||||
GLsizei *length, GLint *size, GLenum *type, GLchar *name);
|
||||
GLuint (* GetActiveUniformMaxLength) (struct gl2_program_intf **);
|
||||
GLuint (* GetActiveUniformCount) (struct gl2_program_intf **);
|
||||
GLint (* GetUniformLocation) (struct gl2_program_intf **, const GLchar *name);
|
||||
GLboolean (* WriteUniform) (struct gl2_program_intf **, GLint loc, GLsizei count,
|
||||
const GLvoid *data, GLenum type);
|
||||
GLboolean (* ReadUniform) (struct gl2_program_intf **, GLint loc, GLsizei count,
|
||||
GLvoid *data, GLenum type);
|
||||
GLvoid (* GetActiveAttrib) (struct gl2_program_intf **, GLuint index, GLsizei maxLength,
|
||||
GLsizei *length, GLint *size, GLenum *type, GLchar *name);
|
||||
GLuint (* GetActiveAttribMaxLength) (struct gl2_program_intf **);
|
||||
GLuint (* GetActiveAttribCount) (struct gl2_program_intf **);
|
||||
GLint (* GetAttribLocation) (struct gl2_program_intf **, const GLchar *name);
|
||||
GLvoid (* OverrideAttribBinding) (struct gl2_program_intf **, GLuint, const GLchar *);
|
||||
GLvoid (* WriteAttrib) (struct gl2_program_intf **, GLuint, const GLfloat *);
|
||||
GLvoid (* UpdateVarying) (struct gl2_program_intf **, GLuint, GLfloat *, GLboolean);
|
||||
};
|
||||
|
||||
struct gl2_fragment_shader_intf
|
||||
{
|
||||
struct gl2_shader_intf _shader;
|
||||
};
|
||||
|
||||
struct gl2_vertex_shader_intf
|
||||
{
|
||||
struct gl2_shader_intf _shader;
|
||||
};
|
||||
|
||||
struct gl2_3dlabs_shhandle_intf
|
||||
{
|
||||
struct gl2_unknown_intf _unknown;
|
||||
GLvoid *(* GetShHandle) (struct gl2_3dlabs_shhandle_intf **);
|
||||
};
|
||||
|
||||
struct gl2_debug_intf
|
||||
{
|
||||
struct gl2_generic_intf _generic;
|
||||
GLvoid (* ClearDebugLog) (struct gl2_debug_intf **, GLenum logType, GLenum shaderType);
|
||||
GLvoid (* GetDebugLog) (struct gl2_debug_intf **, GLenum logType, GLenum shaderType,
|
||||
GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
|
||||
GLsizei (* GetDebugLogLength) (struct gl2_debug_intf **, GLenum logType, GLenum shaderType);
|
||||
};
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
|
||||
extern void GLAPIENTRY
|
||||
@@ -344,10 +233,4 @@ _mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat *value);
|
||||
|
||||
|
||||
|
||||
#endif /* FEATURE_ARB_shader_objects */
|
||||
|
||||
extern void
|
||||
_mesa_init_shaderobjects (GLcontext *ctx);
|
||||
|
||||
#endif /* SHADEROBJECTS_H */
|
||||
#endif /* SHADERS_H */
|
||||
@@ -70,12 +70,12 @@
|
||||
#include "lines.h"
|
||||
#include "macros.h"
|
||||
#include "matrix.h"
|
||||
#if FEATURE_ARB_occlusion_query || FEATURE_EXT_timer_query
|
||||
#include "occlude.h"
|
||||
#endif
|
||||
#include "pixel.h"
|
||||
#include "points.h"
|
||||
#include "polygon.h"
|
||||
#if FEATURE_ARB_occlusion_query || FEATURE_EXT_timer_query
|
||||
#include "queryobj.h"
|
||||
#endif
|
||||
#include "rastpos.h"
|
||||
#include "state.h"
|
||||
#include "stencil.h"
|
||||
@@ -93,7 +93,7 @@
|
||||
#include "texenvprogram.h"
|
||||
#endif
|
||||
#if FEATURE_ARB_shader_objects
|
||||
#include "shaderobjects.h"
|
||||
#include "shaders.h"
|
||||
#endif
|
||||
#include "debug.h"
|
||||
#include "dispatch.h"
|
||||
@@ -821,16 +821,6 @@ _mesa_init_exec_table(struct _glapi_table *exec)
|
||||
/*@{*/
|
||||
|
||||
|
||||
static void
|
||||
update_separate_specular( GLcontext *ctx )
|
||||
{
|
||||
if (NEED_SECONDARY_COLOR(ctx))
|
||||
ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
|
||||
else
|
||||
ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update state dependent on vertex arrays.
|
||||
*/
|
||||
@@ -842,11 +832,7 @@ update_arrays( GLcontext *ctx )
|
||||
/* find min of _MaxElement values for all enabled arrays */
|
||||
|
||||
/* 0 */
|
||||
if (ctx->ShaderObjects._VertexShaderPresent
|
||||
&& ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
|
||||
min = ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0]._MaxElement;
|
||||
}
|
||||
else if (ctx->VertexProgram._Enabled
|
||||
if (ctx->VertexProgram._Current
|
||||
&& ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
|
||||
min = ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS]._MaxElement;
|
||||
}
|
||||
@@ -913,8 +899,8 @@ update_arrays( GLcontext *ctx )
|
||||
|
||||
/* 7 */
|
||||
if (ctx->VertexProgram._Enabled
|
||||
&& ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_SEVEN].Enabled) {
|
||||
min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_SEVEN]._MaxElement);
|
||||
&& ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
|
||||
min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]._MaxElement);
|
||||
}
|
||||
|
||||
/* 8..15 */
|
||||
@@ -930,7 +916,7 @@ update_arrays( GLcontext *ctx )
|
||||
}
|
||||
|
||||
/* 16..31 */
|
||||
if (ctx->ShaderObjects._VertexShaderPresent) {
|
||||
if (ctx->VertexProgram._Current) {
|
||||
for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) {
|
||||
if (ctx->Array.ArrayObj->VertexAttrib[i].Enabled) {
|
||||
min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[i]._MaxElement);
|
||||
@@ -953,10 +939,9 @@ update_arrays( GLcontext *ctx )
|
||||
static void
|
||||
update_program(GLcontext *ctx)
|
||||
{
|
||||
/* For now, just set the _Enabled (really enabled) flags.
|
||||
* In the future we may have to check other state to be sure we really
|
||||
* have a runable program or shader.
|
||||
*/
|
||||
const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
|
||||
|
||||
/* These _Enabled flags indicate if the program is enabled AND valid. */
|
||||
ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
|
||||
&& ctx->VertexProgram.Current->Base.Instructions;
|
||||
ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
|
||||
@@ -964,18 +949,65 @@ update_program(GLcontext *ctx)
|
||||
ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
|
||||
&& ctx->ATIFragmentShader.Current->Instructions;
|
||||
|
||||
/*
|
||||
* Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current
|
||||
* pointers to the programs that should be enabled/used.
|
||||
*
|
||||
* These programs may come from several sources. The priority is as
|
||||
* follows:
|
||||
* 1. OpenGL 2.0/ARB vertex/fragment shaders
|
||||
* 2. ARB/NV vertex/fragment programs
|
||||
* 3. Programs derived from fixed-function state.
|
||||
*/
|
||||
|
||||
ctx->FragmentProgram._Current = NULL;
|
||||
|
||||
if (shProg && shProg->LinkStatus) {
|
||||
/* Use shader programs */
|
||||
/* XXX this isn't quite right, since we may have either a vertex
|
||||
* _or_ fragment shader (not always both).
|
||||
*/
|
||||
ctx->VertexProgram._Current = shProg->VertexProgram;
|
||||
ctx->FragmentProgram._Current = shProg->FragmentProgram;
|
||||
}
|
||||
else {
|
||||
if (ctx->VertexProgram._Enabled) {
|
||||
/* use user-defined vertex program */
|
||||
ctx->VertexProgram._Current = ctx->VertexProgram.Current;
|
||||
}
|
||||
else if (ctx->VertexProgram._MaintainTnlProgram) {
|
||||
/* Use vertex program generated from fixed-function state.
|
||||
* The _Current pointer will get set in
|
||||
* _tnl_UpdateFixedFunctionProgram() later if appropriate.
|
||||
*/
|
||||
ctx->VertexProgram._Current = NULL;
|
||||
}
|
||||
else {
|
||||
/* no vertex program */
|
||||
ctx->VertexProgram._Current = NULL;
|
||||
}
|
||||
|
||||
if (ctx->FragmentProgram._Enabled) {
|
||||
/* use user-defined vertex program */
|
||||
ctx->FragmentProgram._Current = ctx->FragmentProgram.Current;
|
||||
}
|
||||
else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
|
||||
/* Use fragment program generated from fixed-function state.
|
||||
* The _Current pointer will get set in _mesa_UpdateTexEnvProgram()
|
||||
* later if appropriate.
|
||||
*/
|
||||
ctx->FragmentProgram._Current = NULL;
|
||||
}
|
||||
else {
|
||||
/* no fragment program */
|
||||
ctx->FragmentProgram._Current = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled;
|
||||
|
||||
if (ctx->_MaintainTexEnvProgram && !ctx->FragmentProgram._Enabled) {
|
||||
#if 0
|
||||
if (!ctx->_TexEnvProgram)
|
||||
ctx->_TexEnvProgram = (struct gl_fragment_program *)
|
||||
ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
|
||||
ctx->FragmentProgram._Current = ctx->_TexEnvProgram;
|
||||
#endif
|
||||
|
||||
if (ctx->_UseTexEnvProgram)
|
||||
if (ctx->FragmentProgram._MaintainTexEnvProgram &&
|
||||
!ctx->FragmentProgram._Enabled) {
|
||||
if (ctx->FragmentProgram._UseTexEnvProgram)
|
||||
ctx->FragmentProgram._Active = GL_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1013,17 +1045,90 @@ update_color(GLcontext *ctx)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If __GLcontextRec::NewState is non-zero then this function \b must be called
|
||||
* before rendering any primitive. Basically, function pointers and
|
||||
* miscellaneous flags are updated to reflect the current state of the state
|
||||
* machine.
|
||||
* Update the ctx->_TriangleCaps bitfield.
|
||||
* XXX that bitfield should really go away someday!
|
||||
* This function must be called after other update_*() functions since
|
||||
* there are dependencies on some other derived values.
|
||||
*/
|
||||
static void
|
||||
update_tricaps(GLcontext *ctx, GLbitfield new_state)
|
||||
{
|
||||
ctx->_TriangleCaps = 0;
|
||||
|
||||
/*
|
||||
* Points
|
||||
*/
|
||||
if (1/*new_state & _NEW_POINT*/) {
|
||||
if (ctx->Point.SmoothFlag)
|
||||
ctx->_TriangleCaps |= DD_POINT_SMOOTH;
|
||||
if (ctx->Point._Size != 1.0F)
|
||||
ctx->_TriangleCaps |= DD_POINT_SIZE;
|
||||
if (ctx->Point._Attenuated)
|
||||
ctx->_TriangleCaps |= DD_POINT_ATTEN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lines
|
||||
*/
|
||||
if (1/*new_state & _NEW_LINE*/) {
|
||||
if (ctx->Line.SmoothFlag)
|
||||
ctx->_TriangleCaps |= DD_LINE_SMOOTH;
|
||||
if (ctx->Line.StippleFlag)
|
||||
ctx->_TriangleCaps |= DD_LINE_STIPPLE;
|
||||
if (ctx->Line._Width != 1.0)
|
||||
ctx->_TriangleCaps |= DD_LINE_WIDTH;
|
||||
}
|
||||
|
||||
/*
|
||||
* Polygons
|
||||
*/
|
||||
if (1/*new_state & _NEW_POLYGON*/) {
|
||||
if (ctx->Polygon.SmoothFlag)
|
||||
ctx->_TriangleCaps |= DD_TRI_SMOOTH;
|
||||
if (ctx->Polygon.StippleFlag)
|
||||
ctx->_TriangleCaps |= DD_TRI_STIPPLE;
|
||||
if (ctx->Polygon.FrontMode != GL_FILL
|
||||
|| ctx->Polygon.BackMode != GL_FILL)
|
||||
ctx->_TriangleCaps |= DD_TRI_UNFILLED;
|
||||
if (ctx->Polygon.CullFlag
|
||||
&& ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
|
||||
ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
|
||||
if (ctx->Polygon.OffsetPoint ||
|
||||
ctx->Polygon.OffsetLine ||
|
||||
ctx->Polygon.OffsetFill)
|
||||
ctx->_TriangleCaps |= DD_TRI_OFFSET;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lighting and shading
|
||||
*/
|
||||
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
|
||||
ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
|
||||
if (ctx->Light.ShadeModel == GL_FLAT)
|
||||
ctx->_TriangleCaps |= DD_FLATSHADE;
|
||||
if (NEED_SECONDARY_COLOR(ctx))
|
||||
ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
|
||||
|
||||
/*
|
||||
* Stencil
|
||||
*/
|
||||
if (ctx->Stencil._TestTwoSide)
|
||||
ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compute derived GL state.
|
||||
* If __GLcontextRec::NewState is non-zero then this function \b must
|
||||
* be called before rendering anything.
|
||||
*
|
||||
* Calls dd_function_table::UpdateState to perform any internal state
|
||||
* management necessary.
|
||||
*
|
||||
* \sa _mesa_update_modelview_project(), _mesa_update_texture(),
|
||||
* _mesa_update_buffer_bounds(), _mesa_update_polygon(),
|
||||
* _mesa_update_buffer_bounds(),
|
||||
* _mesa_update_lighting() and _mesa_update_tnl_spaces().
|
||||
*/
|
||||
void
|
||||
@@ -1049,12 +1154,6 @@ _mesa_update_state_locked( GLcontext *ctx )
|
||||
if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
|
||||
_mesa_update_draw_buffer_bounds( ctx );
|
||||
|
||||
if (new_state & _NEW_POINT)
|
||||
_mesa_update_point( ctx );
|
||||
|
||||
if (new_state & _NEW_POLYGON)
|
||||
_mesa_update_polygon( ctx );
|
||||
|
||||
if (new_state & _NEW_LIGHT)
|
||||
_mesa_update_lighting( ctx );
|
||||
|
||||
@@ -1064,9 +1163,6 @@ _mesa_update_state_locked( GLcontext *ctx )
|
||||
if (new_state & _IMAGE_NEW_TRANSFER_STATE)
|
||||
_mesa_update_pixel( ctx, new_state );
|
||||
|
||||
if (new_state & _DD_NEW_SEPARATE_SPECULAR)
|
||||
update_separate_specular( ctx );
|
||||
|
||||
if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
|
||||
update_arrays( ctx );
|
||||
|
||||
@@ -1076,7 +1172,11 @@ _mesa_update_state_locked( GLcontext *ctx )
|
||||
if (new_state & _NEW_COLOR)
|
||||
update_color( ctx );
|
||||
|
||||
if (ctx->_MaintainTexEnvProgram) {
|
||||
if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT
|
||||
| _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR))
|
||||
update_tricaps( ctx, new_state );
|
||||
|
||||
if (ctx->FragmentProgram._MaintainTexEnvProgram) {
|
||||
if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))
|
||||
_mesa_UpdateTexEnvProgram(ctx);
|
||||
}
|
||||
@@ -1122,3 +1222,5 @@ _mesa_update_state( GLcontext *ctx )
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
@@ -119,23 +119,7 @@ _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )
|
||||
|
||||
ref = CLAMP( ref, 0, stencilMax );
|
||||
|
||||
if (ctx->Extensions.EXT_stencil_two_side) {
|
||||
/* only set active face state */
|
||||
const GLint face = ctx->Stencil.ActiveFace;
|
||||
if (ctx->Stencil.Function[face] == func &&
|
||||
ctx->Stencil.ValueMask[face] == mask &&
|
||||
ctx->Stencil.Ref[face] == ref)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_STENCIL);
|
||||
ctx->Stencil.Function[face] = func;
|
||||
ctx->Stencil.Ref[face] = ref;
|
||||
ctx->Stencil.ValueMask[face] = mask;
|
||||
if (ctx->Driver.StencilFuncSeparate) {
|
||||
ctx->Driver.StencilFuncSeparate(ctx, face ? GL_BACK : GL_FRONT,
|
||||
func, ref, mask);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ctx->Extensions.ATI_separate_stencil) {
|
||||
/* set both front and back state */
|
||||
if (ctx->Stencil.Function[0] == func &&
|
||||
ctx->Stencil.Function[1] == func &&
|
||||
@@ -153,6 +137,22 @@ _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )
|
||||
func, ref, mask);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* only set active face state */
|
||||
const GLint face = ctx->Stencil.ActiveFace;
|
||||
if (ctx->Stencil.Function[face] == func &&
|
||||
ctx->Stencil.ValueMask[face] == mask &&
|
||||
ctx->Stencil.Ref[face] == ref)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_STENCIL);
|
||||
ctx->Stencil.Function[face] = func;
|
||||
ctx->Stencil.Ref[face] = ref;
|
||||
ctx->Stencil.ValueMask[face] = mask;
|
||||
if (ctx->Driver.StencilFuncSeparate) {
|
||||
ctx->Driver.StencilFuncSeparate(ctx, face ? GL_BACK : GL_FRONT,
|
||||
func, ref, mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,18 +173,7 @@ _mesa_StencilMask( GLuint mask )
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
if (ctx->Extensions.EXT_stencil_two_side) {
|
||||
/* only set active face state */
|
||||
const GLint face = ctx->Stencil.ActiveFace;
|
||||
if (ctx->Stencil.WriteMask[face] == mask)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_STENCIL);
|
||||
ctx->Stencil.WriteMask[face] = mask;
|
||||
if (ctx->Driver.StencilMaskSeparate) {
|
||||
ctx->Driver.StencilMaskSeparate(ctx, face ? GL_BACK : GL_FRONT, mask);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ctx->Extensions.ATI_separate_stencil) {
|
||||
/* set both front and back state */
|
||||
if (ctx->Stencil.WriteMask[0] == mask &&
|
||||
ctx->Stencil.WriteMask[1] == mask)
|
||||
@@ -195,6 +184,17 @@ _mesa_StencilMask( GLuint mask )
|
||||
ctx->Driver.StencilMaskSeparate(ctx, GL_FRONT_AND_BACK, mask);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* only set active face state */
|
||||
const GLint face = ctx->Stencil.ActiveFace;
|
||||
if (ctx->Stencil.WriteMask[face] == mask)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_STENCIL);
|
||||
ctx->Stencil.WriteMask[face] = mask;
|
||||
if (ctx->Driver.StencilMaskSeparate) {
|
||||
ctx->Driver.StencilMaskSeparate(ctx, face ? GL_BACK : GL_FRONT, mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -273,23 +273,7 @@ _mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx->Extensions.EXT_stencil_two_side) {
|
||||
/* only set active face state */
|
||||
const GLint face = ctx->Stencil.ActiveFace;
|
||||
if (ctx->Stencil.ZFailFunc[face] == zfail &&
|
||||
ctx->Stencil.ZPassFunc[face] == zpass &&
|
||||
ctx->Stencil.FailFunc[face] == fail)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_STENCIL);
|
||||
ctx->Stencil.ZFailFunc[face] = zfail;
|
||||
ctx->Stencil.ZPassFunc[face] = zpass;
|
||||
ctx->Stencil.FailFunc[face] = fail;
|
||||
if (ctx->Driver.StencilOpSeparate) {
|
||||
ctx->Driver.StencilOpSeparate(ctx, face ? GL_BACK : GL_FRONT,
|
||||
fail, zfail, zpass);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ctx->Extensions.ATI_separate_stencil) {
|
||||
/* set both front and back state */
|
||||
if (ctx->Stencil.ZFailFunc[0] == zfail &&
|
||||
ctx->Stencil.ZFailFunc[1] == zfail &&
|
||||
@@ -307,6 +291,22 @@ _mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
|
||||
fail, zfail, zpass);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* only set active face state */
|
||||
const GLint face = ctx->Stencil.ActiveFace;
|
||||
if (ctx->Stencil.ZFailFunc[face] == zfail &&
|
||||
ctx->Stencil.ZPassFunc[face] == zpass &&
|
||||
ctx->Stencil.FailFunc[face] == fail)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_STENCIL);
|
||||
ctx->Stencil.ZFailFunc[face] = zfail;
|
||||
ctx->Stencil.ZPassFunc[face] = zpass;
|
||||
ctx->Stencil.FailFunc[face] = fail;
|
||||
if (ctx->Driver.StencilOpSeparate) {
|
||||
ctx->Driver.StencilOpSeparate(ctx, face ? GL_BACK : GL_FRONT,
|
||||
fail, zfail, zpass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -752,16 +752,18 @@ fxt1_quantize_ALPHA1 (GLuint *cc,
|
||||
GLint minColL = 0, maxColL = 0;
|
||||
GLint minColR = 0, maxColR = 0;
|
||||
GLint sumL = 0, sumR = 0;
|
||||
|
||||
GLint nn_comp;
|
||||
/* Our solution here is to find the darkest and brightest colors in
|
||||
* the 4x4 tile and use those as the two representative colors.
|
||||
* There are probably better algorithms to use (histogram-based).
|
||||
*/
|
||||
nn_comp = n_comp;
|
||||
while ((minColL == maxColL) && nn_comp) {
|
||||
minSum = 2000; /* big enough */
|
||||
maxSum = -1; /* small enough */
|
||||
for (k = 0; k < N_TEXELS / 2; k++) {
|
||||
GLint sum = 0;
|
||||
for (i = 0; i < n_comp; i++) {
|
||||
for (i = 0; i < nn_comp; i++) {
|
||||
sum += input[k][i];
|
||||
}
|
||||
if (minSum > sum) {
|
||||
@@ -774,11 +776,17 @@ fxt1_quantize_ALPHA1 (GLuint *cc,
|
||||
}
|
||||
sumL += sum;
|
||||
}
|
||||
|
||||
nn_comp--;
|
||||
}
|
||||
|
||||
nn_comp = n_comp;
|
||||
while ((minColR == maxColR) && nn_comp) {
|
||||
minSum = 2000; /* big enough */
|
||||
maxSum = -1; /* small enough */
|
||||
for (; k < N_TEXELS; k++) {
|
||||
for (k = N_TEXELS / 2; k < N_TEXELS; k++) {
|
||||
GLint sum = 0;
|
||||
for (i = 0; i < n_comp; i++) {
|
||||
for (i = 0; i < nn_comp; i++) {
|
||||
sum += input[k][i];
|
||||
}
|
||||
if (minSum > sum) {
|
||||
@@ -792,6 +800,9 @@ fxt1_quantize_ALPHA1 (GLuint *cc,
|
||||
sumR += sum;
|
||||
}
|
||||
|
||||
nn_comp--;
|
||||
}
|
||||
|
||||
/* choose the common vector (yuck!) */
|
||||
{
|
||||
GLint j1, j2;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -91,7 +91,7 @@ _mesa_dlopen(const char *libname, int flags)
|
||||
return dlopen(libname, flags);
|
||||
#endif
|
||||
#else
|
||||
return (GenericFunc) NULL;
|
||||
return NULL;
|
||||
#endif /* USE_EXTERNAL_DXTN_LIB */
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ texstore_rgb_dxt1(TEXSTORE_PARAMS)
|
||||
dst, dstRowStride);
|
||||
}
|
||||
else {
|
||||
_mesa_problem(ctx, "external dxt library not available");
|
||||
_mesa_warning(ctx, "external dxt library not available");
|
||||
}
|
||||
|
||||
if (tempImage)
|
||||
@@ -307,7 +307,7 @@ texstore_rgba_dxt1(TEXSTORE_PARAMS)
|
||||
dst, dstRowStride);
|
||||
}
|
||||
else {
|
||||
_mesa_problem(ctx, "external dxt library not available");
|
||||
_mesa_warning(ctx, "external dxt library not available");
|
||||
}
|
||||
|
||||
if (tempImage)
|
||||
@@ -368,7 +368,7 @@ texstore_rgba_dxt3(TEXSTORE_PARAMS)
|
||||
dst, dstRowStride);
|
||||
}
|
||||
else {
|
||||
_mesa_problem(ctx, "external dxt library not available");
|
||||
_mesa_warning(ctx, "external dxt library not available");
|
||||
}
|
||||
|
||||
if (tempImage)
|
||||
@@ -429,7 +429,7 @@ texstore_rgba_dxt5(TEXSTORE_PARAMS)
|
||||
dst, dstRowStride);
|
||||
}
|
||||
else {
|
||||
_mesa_problem(ctx, "external dxt library not available");
|
||||
_mesa_warning(ctx, "external dxt library not available");
|
||||
}
|
||||
|
||||
if (tempImage)
|
||||
|
||||
@@ -28,11 +28,12 @@
|
||||
#include "glheader.h"
|
||||
#include "macros.h"
|
||||
#include "enums.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "prog_instruction.h"
|
||||
#include "prog_print.h"
|
||||
#include "prog_statevars.h"
|
||||
#include "texenvprogram.h"
|
||||
|
||||
#include "shader/program.h"
|
||||
#include "shader/program_instruction.h"
|
||||
|
||||
/**
|
||||
* According to Glean's texCombine test, no more than 21 instructions
|
||||
* are needed. Allow a few extra just in case.
|
||||
@@ -410,31 +411,29 @@ static void release_temps( struct texenv_fragment_program *p )
|
||||
}
|
||||
|
||||
|
||||
static struct ureg register_param6( struct texenv_fragment_program *p,
|
||||
static struct ureg register_param5( struct texenv_fragment_program *p,
|
||||
GLint s0,
|
||||
GLint s1,
|
||||
GLint s2,
|
||||
GLint s3,
|
||||
GLint s4,
|
||||
GLint s5)
|
||||
GLint s4)
|
||||
{
|
||||
GLint tokens[6];
|
||||
gl_state_index tokens[STATE_LENGTH];
|
||||
GLuint idx;
|
||||
tokens[0] = s0;
|
||||
tokens[1] = s1;
|
||||
tokens[2] = s2;
|
||||
tokens[3] = s3;
|
||||
tokens[4] = s4;
|
||||
tokens[5] = s5;
|
||||
idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens );
|
||||
return make_ureg(PROGRAM_STATE_VAR, idx);
|
||||
}
|
||||
|
||||
|
||||
#define register_param1(p,s0) register_param6(p,s0,0,0,0,0,0)
|
||||
#define register_param2(p,s0,s1) register_param6(p,s0,s1,0,0,0,0)
|
||||
#define register_param3(p,s0,s1,s2) register_param6(p,s0,s1,s2,0,0,0)
|
||||
#define register_param4(p,s0,s1,s2,s3) register_param6(p,s0,s1,s2,s3,0,0)
|
||||
#define register_param1(p,s0) register_param5(p,s0,0,0,0,0)
|
||||
#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0)
|
||||
#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0)
|
||||
#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0)
|
||||
|
||||
|
||||
static struct ureg register_input( struct texenv_fragment_program *p, GLuint input )
|
||||
@@ -523,7 +522,7 @@ static struct ureg emit_arith( struct texenv_fragment_program *p,
|
||||
if (dest.file == PROGRAM_TEMPORARY)
|
||||
p->alu_temps |= 1 << dest.idx;
|
||||
|
||||
p->program->NumAluInstructions++;
|
||||
p->program->Base.NumAluInstructions++;
|
||||
return dest;
|
||||
}
|
||||
|
||||
@@ -545,7 +544,7 @@ static struct ureg emit_texld( struct texenv_fragment_program *p,
|
||||
inst->TexSrcTarget = tex_idx;
|
||||
inst->TexSrcUnit = tex_unit;
|
||||
|
||||
p->program->NumTexInstructions++;
|
||||
p->program->Base.NumTexInstructions++;
|
||||
|
||||
/* Is this a texture indirection?
|
||||
*/
|
||||
@@ -553,7 +552,7 @@ static struct ureg emit_texld( struct texenv_fragment_program *p,
|
||||
(p->temps_output & (1<<coord.idx))) ||
|
||||
(dest.file == PROGRAM_TEMPORARY &&
|
||||
(p->alu_temps & (1<<dest.idx)))) {
|
||||
p->program->NumTexIndirections++;
|
||||
p->program->Base.NumTexIndirections++;
|
||||
p->temps_output = 1<<coord.idx;
|
||||
p->alu_temps = 0;
|
||||
assert(0); /* KW: texture env crossbar */
|
||||
@@ -570,12 +569,14 @@ static struct ureg register_const4f( struct texenv_fragment_program *p,
|
||||
GLfloat s3)
|
||||
{
|
||||
GLfloat values[4];
|
||||
GLuint idx;
|
||||
GLuint idx, swizzle;
|
||||
values[0] = s0;
|
||||
values[1] = s1;
|
||||
values[2] = s2;
|
||||
values[3] = s3;
|
||||
idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4 );
|
||||
idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
|
||||
&swizzle );
|
||||
ASSERT(swizzle == SWIZZLE_NOOP);
|
||||
return make_ureg(PROGRAM_STATE_VAR, idx);
|
||||
}
|
||||
|
||||
@@ -1010,10 +1011,10 @@ create_new_program(GLcontext *ctx, struct state_key *key,
|
||||
*/
|
||||
p.program->Base.Instructions = instBuffer;
|
||||
p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB;
|
||||
p.program->NumTexIndirections = 1; /* correct? */
|
||||
p.program->NumTexInstructions = 0;
|
||||
p.program->NumAluInstructions = 0;
|
||||
p.program->Base.String = 0;
|
||||
p.program->Base.NumTexIndirections = 1; /* correct? */
|
||||
p.program->Base.NumTexInstructions = 0;
|
||||
p.program->Base.NumAluInstructions = 0;
|
||||
p.program->Base.String = NULL;
|
||||
p.program->Base.NumInstructions =
|
||||
p.program->Base.NumTemporaries =
|
||||
p.program->Base.NumParameters =
|
||||
@@ -1083,13 +1084,13 @@ create_new_program(GLcontext *ctx, struct state_key *key,
|
||||
} else
|
||||
p.program->FogOption = GL_NONE;
|
||||
|
||||
if (p.program->NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections)
|
||||
if (p.program->Base.NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections)
|
||||
program_error(&p, "Exceeded max nr indirect texture lookups");
|
||||
|
||||
if (p.program->NumTexInstructions > ctx->Const.FragmentProgram.MaxTexInstructions)
|
||||
if (p.program->Base.NumTexInstructions > ctx->Const.FragmentProgram.MaxTexInstructions)
|
||||
program_error(&p, "Exceeded max TEX instructions");
|
||||
|
||||
if (p.program->NumAluInstructions > ctx->Const.FragmentProgram.MaxAluInstructions)
|
||||
if (p.program->Base.NumAluInstructions > ctx->Const.FragmentProgram.MaxAluInstructions)
|
||||
program_error(&p, "Exceeded max ALU instructions");
|
||||
|
||||
ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS);
|
||||
@@ -1102,9 +1103,8 @@ create_new_program(GLcontext *ctx, struct state_key *key,
|
||||
"generating tex env program");
|
||||
return;
|
||||
}
|
||||
_mesa_memcpy(program->Base.Instructions, instBuffer,
|
||||
sizeof(struct prog_instruction)
|
||||
* program->Base.NumInstructions);
|
||||
_mesa_copy_instructions(program->Base.Instructions, instBuffer,
|
||||
program->Base.NumInstructions);
|
||||
|
||||
/* Notify driver the fragment program has (actually) changed.
|
||||
*/
|
||||
@@ -1184,13 +1184,14 @@ static void cache_item( struct texenvprog_cache *cache,
|
||||
const struct state_key *key,
|
||||
void *data )
|
||||
{
|
||||
struct texenvprog_cache_item *c = MALLOC(sizeof(*c));
|
||||
struct texenvprog_cache_item *c
|
||||
= (struct texenvprog_cache_item *) MALLOC(sizeof(*c));
|
||||
c->hash = hash;
|
||||
|
||||
c->key = _mesa_malloc(sizeof(*key));
|
||||
memcpy(c->key, key, sizeof(*key));
|
||||
|
||||
c->data = data;
|
||||
c->data = (struct gl_fragment_program *) data;
|
||||
|
||||
if (cache->n_items > cache->size * 1.5) {
|
||||
if (cache->size < 1000)
|
||||
@@ -1221,32 +1222,49 @@ static GLuint hash_key( const struct state_key *key )
|
||||
return hash;
|
||||
}
|
||||
|
||||
void _mesa_UpdateTexEnvProgram( GLcontext *ctx )
|
||||
|
||||
/**
|
||||
* If _MaintainTexEnvProgram is set we'll generate a fragment program that
|
||||
* implements the current texture env/combine mode.
|
||||
* This function generates that program and puts it into effect.
|
||||
*/
|
||||
void
|
||||
_mesa_UpdateTexEnvProgram( GLcontext *ctx )
|
||||
{
|
||||
struct state_key key;
|
||||
GLuint hash;
|
||||
const struct gl_fragment_program *prev = ctx->FragmentProgram._Current;
|
||||
|
||||
if (!ctx->FragmentProgram._Enabled) {
|
||||
ASSERT(ctx->FragmentProgram._MaintainTexEnvProgram);
|
||||
|
||||
/* If a conventional fragment program/shader isn't in effect... */
|
||||
if (!ctx->FragmentProgram._Enabled &&
|
||||
!ctx->Shader.CurrentProgram) {
|
||||
make_state_key(ctx, &key);
|
||||
hash = hash_key(&key);
|
||||
|
||||
ctx->FragmentProgram._Current =
|
||||
ctx->_TexEnvProgram =
|
||||
ctx->FragmentProgram._TexEnvProgram =
|
||||
search_cache(&ctx->Texture.env_fp_cache, hash, &key, sizeof(key));
|
||||
|
||||
if (!ctx->_TexEnvProgram) {
|
||||
if (0) _mesa_printf("Building new texenv proggy for key %x\n", hash);
|
||||
if (!ctx->FragmentProgram._TexEnvProgram) {
|
||||
if (0)
|
||||
_mesa_printf("Building new texenv proggy for key %x\n", hash);
|
||||
|
||||
ctx->FragmentProgram._Current = ctx->_TexEnvProgram =
|
||||
/* create new tex env program */
|
||||
ctx->FragmentProgram._Current =
|
||||
ctx->FragmentProgram._TexEnvProgram =
|
||||
(struct gl_fragment_program *)
|
||||
ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
|
||||
|
||||
create_new_program(ctx, &key, ctx->_TexEnvProgram);
|
||||
create_new_program(ctx, &key, ctx->FragmentProgram._TexEnvProgram);
|
||||
|
||||
cache_item(&ctx->Texture.env_fp_cache, hash, &key, ctx->_TexEnvProgram);
|
||||
} else {
|
||||
if (0) _mesa_printf("Found existing texenv program for key %x\n", hash);
|
||||
cache_item(&ctx->Texture.env_fp_cache, hash, &key,
|
||||
ctx->FragmentProgram._TexEnvProgram);
|
||||
}
|
||||
else {
|
||||
if (0)
|
||||
_mesa_printf("Found existing texenv program for key %x\n", hash);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -2061,12 +2061,6 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions,
|
||||
}
|
||||
|
||||
if (teximage->IsCompressed) {
|
||||
if (!_mesa_source_buffer_exists(ctx, teximage->_BaseFormat)) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glCopyTexSubImage%dD(missing readbuffer)", dimensions);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
if (target != GL_TEXTURE_2D) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
"glCopyTexSubImage%d(target)", dimensions);
|
||||
@@ -2096,6 +2090,12 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions,
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
if (!_mesa_source_buffer_exists(ctx, teximage->_BaseFormat)) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glCopyTexSubImage%dD(missing readbuffer)", dimensions);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) {
|
||||
if (!ctx->ReadBuffer->_DepthBuffer) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
|
||||
@@ -699,7 +699,7 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
|
||||
= _mesa_lookup_texture(ctx, textures[i]);
|
||||
|
||||
if (delObj) {
|
||||
GLboolean delete;
|
||||
GLboolean deleted;
|
||||
|
||||
_mesa_lock_texture(ctx, delObj);
|
||||
|
||||
@@ -728,14 +728,14 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
|
||||
* XXX all RefCount accesses should be protected by a mutex.
|
||||
*/
|
||||
delObj->RefCount--;
|
||||
delete = (delObj->RefCount == 0);
|
||||
deleted = (delObj->RefCount == 0);
|
||||
_mesa_unlock_texture(ctx, delObj);
|
||||
|
||||
/* We know that refcount went to zero above, so this is
|
||||
* the only pointer left to delObj, so we don't have to
|
||||
* worry about locking any more:
|
||||
*/
|
||||
if (delete) {
|
||||
if (deleted) {
|
||||
ASSERT(delObj->Name != 0); /* Never delete default tex objs */
|
||||
ASSERT(ctx->Driver.DeleteTexture);
|
||||
(*ctx->Driver.DeleteTexture)(ctx, delObj);
|
||||
|
||||
@@ -325,7 +325,7 @@ wrap_texture(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
|
||||
trb->Base.PutMonoValues = texture_put_mono_values;
|
||||
|
||||
/* update attachment point */
|
||||
att->Renderbuffer = &(trb->Base);
|
||||
_mesa_reference_renderbuffer(&att->Renderbuffer, &(trb->Base));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.1
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -41,8 +41,6 @@
|
||||
#include "texenvprogram.h"
|
||||
#include "mtypes.h"
|
||||
#include "math/m_xform.h"
|
||||
#include "shaderobjects.h"
|
||||
|
||||
|
||||
|
||||
#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
|
||||
@@ -1445,7 +1443,7 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)");
|
||||
return;
|
||||
}
|
||||
if (target == GL_TEXTURE_RECTANGLE_NV && params[0] != 0.0) {
|
||||
if (target == GL_TEXTURE_RECTANGLE_ARB && params[0] != 0.0) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)");
|
||||
return;
|
||||
}
|
||||
@@ -1457,6 +1455,10 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)");
|
||||
return;
|
||||
}
|
||||
if (target == GL_TEXTURE_RECTANGLE_ARB) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glTexParameter(param)");
|
||||
return;
|
||||
}
|
||||
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
|
||||
texObj->MaxLevel = (GLint) params[0];
|
||||
break;
|
||||
@@ -2919,11 +2921,25 @@ static void
|
||||
update_texture_state( GLcontext *ctx )
|
||||
{
|
||||
GLuint unit;
|
||||
struct gl_fragment_program *fprog = NULL;
|
||||
struct gl_vertex_program *vprog = NULL;
|
||||
|
||||
#if FEATURE_ARB_fragment_shader
|
||||
struct gl2_program_intf **prog = ctx->ShaderObjects.CurrentProgram;
|
||||
GLbitfield progteximageusage[MAX_TEXTURE_IMAGE_UNITS];
|
||||
#endif
|
||||
if (ctx->Shader.CurrentProgram &&
|
||||
ctx->Shader.CurrentProgram->LinkStatus) {
|
||||
fprog = ctx->Shader.CurrentProgram->FragmentProgram;
|
||||
vprog = ctx->Shader.CurrentProgram->VertexProgram;
|
||||
}
|
||||
else {
|
||||
if (ctx->FragmentProgram._Enabled) {
|
||||
fprog = ctx->FragmentProgram.Current;
|
||||
}
|
||||
if (ctx->VertexProgram._Enabled) {
|
||||
/* XXX enable this if/when non-shader vertex programs get
|
||||
* texture fetches:
|
||||
vprog = ctx->VertexProgram.Current;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
ctx->NewState |= _NEW_TEXTURE; /* TODO: only set this if there are
|
||||
* actual changes.
|
||||
@@ -2934,17 +2950,6 @@ update_texture_state( GLcontext *ctx )
|
||||
ctx->Texture._TexMatEnabled = 0;
|
||||
ctx->Texture._TexGenEnabled = 0;
|
||||
|
||||
#if FEATURE_ARB_fragment_shader
|
||||
/*
|
||||
* Grab texture image usage state from shader program. It must be
|
||||
* grabbed every time uniform sampler changes, so maybe there is a
|
||||
* better place to perform these rather expensive computations.
|
||||
*/
|
||||
if (ctx->ShaderObjects._FragmentShaderPresent) {
|
||||
(**prog).GetTextureImageUsage (prog, progteximageusage);
|
||||
}
|
||||
#endif /* FEATURE_ARB_fragment_shader */
|
||||
|
||||
/*
|
||||
* Update texture unit state.
|
||||
*/
|
||||
@@ -2956,15 +2961,18 @@ update_texture_state( GLcontext *ctx )
|
||||
texUnit->_ReallyEnabled = 0;
|
||||
texUnit->_GenFlags = 0;
|
||||
|
||||
/* Get the bitmask of texture enables */
|
||||
#if FEATURE_ARB_fragment_shader
|
||||
if (ctx->ShaderObjects._FragmentShaderPresent) {
|
||||
enableBits = progteximageusage[unit];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (ctx->FragmentProgram._Enabled) {
|
||||
enableBits = ctx->FragmentProgram.Current->TexturesUsed[unit];
|
||||
/* Get the bitmask of texture enables.
|
||||
* enableBits will be a mask of the TEXTURE_*_BIT flags indicating
|
||||
* which texture targets are enabled (fixed function) or referenced
|
||||
* by a fragment shader/program. When multiple flags are set, we'll
|
||||
* settle on the one with highest priority (see texture_override below).
|
||||
*/
|
||||
if (fprog || vprog) {
|
||||
enableBits = 0x0;
|
||||
if (fprog)
|
||||
enableBits |= fprog->Base.TexturesUsed[unit];
|
||||
if (vprog)
|
||||
enableBits |= vprog->Base.TexturesUsed[unit];
|
||||
}
|
||||
else {
|
||||
if (!texUnit->Enabled)
|
||||
@@ -3081,21 +3089,23 @@ update_texture_state( GLcontext *ctx )
|
||||
ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
|
||||
}
|
||||
|
||||
/* Determine which texture coordinate sets are actually needed */
|
||||
if (fprog) {
|
||||
const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1;
|
||||
ctx->Texture._EnabledCoordUnits
|
||||
= (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask;
|
||||
}
|
||||
else {
|
||||
ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits;
|
||||
/* Fragment programs may need texture coordinates but not the
|
||||
* corresponding texture images.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update texture-related derived state.
|
||||
*/
|
||||
if (ctx->ShaderObjects.CurrentProgram != NULL) {
|
||||
ctx->Texture._EnabledCoordUnits |= (1 << ctx->Const.MaxTextureCoordUnits) - 1;
|
||||
}
|
||||
else if (ctx->FragmentProgram._Enabled) {
|
||||
ctx->Texture._EnabledCoordUnits |=
|
||||
(ctx->FragmentProgram.Current->Base.InputsRead >> FRAG_ATTRIB_TEX0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _mesa_update_texture( GLcontext *ctx, GLuint new_state )
|
||||
void
|
||||
_mesa_update_texture( GLcontext *ctx, GLuint new_state )
|
||||
{
|
||||
if (new_state & _NEW_TEXTURE_MATRIX)
|
||||
update_texture_matrices( ctx );
|
||||
|
||||
@@ -808,7 +808,8 @@ _mesa_swizzle_ubyte_image(GLcontext *ctx,
|
||||
|
||||
/* _mesa_printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */
|
||||
|
||||
if (srcRowStride == srcWidth * srcComponents &&
|
||||
if (srcRowStride == dstRowStride &&
|
||||
srcRowStride == srcWidth * srcComponents &&
|
||||
dimensions < 3) {
|
||||
/* 1 and 2D images only */
|
||||
GLubyte *dstImage = (GLubyte *) dstAddr
|
||||
@@ -2770,8 +2771,8 @@ fetch_texel_chan_to_float(const struct gl_texture_image *texImage,
|
||||
/**
|
||||
* Initialize the texture image's FetchTexelc and FetchTexelf methods.
|
||||
*/
|
||||
static void
|
||||
set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
|
||||
void
|
||||
_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
|
||||
{
|
||||
ASSERT(dims == 1 || dims == 2 || dims == 3);
|
||||
ASSERT(texImage->TexFormat);
|
||||
@@ -2831,7 +2832,7 @@ choose_texture_format(GLcontext *ctx, struct gl_texture_image *texImage,
|
||||
|
||||
ASSERT(texImage->TexFormat);
|
||||
|
||||
set_fetch_functions(texImage, dims);
|
||||
_mesa_set_fetch_functions(texImage, dims);
|
||||
|
||||
if (texImage->TexFormat->TexelBytes == 0) {
|
||||
/* must be a compressed format */
|
||||
@@ -3607,6 +3608,25 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint col;
|
||||
for (col = 0; col < width; col++) {
|
||||
(*texImage->FetchTexelf)(texImage, col, row, img, rgba[col]);
|
||||
if (texImage->TexFormat->BaseFormat == GL_ALPHA) {
|
||||
rgba[col][RCOMP] = 0.0;
|
||||
rgba[col][GCOMP] = 0.0;
|
||||
rgba[col][BCOMP] = 0.0;
|
||||
}
|
||||
else if (texImage->TexFormat->BaseFormat == GL_LUMINANCE) {
|
||||
rgba[col][GCOMP] = 0.0;
|
||||
rgba[col][BCOMP] = 0.0;
|
||||
rgba[col][ACOMP] = 1.0;
|
||||
}
|
||||
else if (texImage->TexFormat->BaseFormat == GL_LUMINANCE_ALPHA) {
|
||||
rgba[col][GCOMP] = 0.0;
|
||||
rgba[col][BCOMP] = 0.0;
|
||||
}
|
||||
else if (texImage->TexFormat->BaseFormat == GL_INTENSITY) {
|
||||
rgba[col][GCOMP] = 0.0;
|
||||
rgba[col][BCOMP] = 0.0;
|
||||
rgba[col][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
_mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
|
||||
format, type, dest,
|
||||
|
||||
@@ -85,6 +85,10 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
|
||||
const struct gl_pixelstore_attrib *srcPacking);
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims);
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint internalFormat,
|
||||
|
||||
@@ -76,7 +76,8 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
|
||||
*/
|
||||
if (ctx->Array.ArrayBufferObj->Name)
|
||||
array->_MaxElement = ((GLsizeiptrARB) ctx->Array.ArrayBufferObj->Size
|
||||
- (GLsizeiptrARB) array->Ptr) / array->StrideB;
|
||||
- (GLsizeiptrARB) array->Ptr + array->StrideB
|
||||
- elementSize) / array->StrideB;
|
||||
else
|
||||
#endif
|
||||
array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -30,8 +30,8 @@
|
||||
/* Mesa version */
|
||||
#define MESA_MAJOR 6
|
||||
#define MESA_MINOR 5
|
||||
#define MESA_PATCH 2
|
||||
#define MESA_VERSION_STRING "6.5.2"
|
||||
#define MESA_PATCH 3
|
||||
#define MESA_VERSION_STRING "6.5.3"
|
||||
|
||||
/* To make version comparison easy */
|
||||
#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
||||
@@ -39,10 +39,10 @@
|
||||
|
||||
|
||||
/* OpenGL API version */
|
||||
#define OPENGL_MAJOR 1
|
||||
#define OPENGL_MINOR 5
|
||||
#define OPENGL_MAJOR 2
|
||||
#define OPENGL_MINOR 0
|
||||
#define OPENGL_PATCH 0
|
||||
#define OPENGL_VERSION_STRING "1.5"
|
||||
#define OPENGL_VERSION_STRING "2.0"
|
||||
|
||||
/* To make version comparison easy */
|
||||
#define OPENGL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.1
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -35,10 +35,12 @@
|
||||
#include "arbprogparse.h"
|
||||
#include "grammar_mesa.h"
|
||||
#include "program.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "prog_statevars.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "program_instruction.h"
|
||||
#include "prog_instruction.h"
|
||||
|
||||
|
||||
/* For ARB programs, use the NV instruction limits */
|
||||
@@ -1008,7 +1010,7 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra
|
||||
|
||||
switch (mat) {
|
||||
case MATRIX_MODELVIEW:
|
||||
*matrix = STATE_MODELVIEW;
|
||||
*matrix = STATE_MODELVIEW_MATRIX;
|
||||
*matrix_idx = parse_integer (inst, Program);
|
||||
if (*matrix_idx > 0) {
|
||||
program_error(ctx, Program->Position,
|
||||
@@ -1018,15 +1020,15 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra
|
||||
break;
|
||||
|
||||
case MATRIX_PROJECTION:
|
||||
*matrix = STATE_PROJECTION;
|
||||
*matrix = STATE_PROJECTION_MATRIX;
|
||||
break;
|
||||
|
||||
case MATRIX_MVP:
|
||||
*matrix = STATE_MVP;
|
||||
*matrix = STATE_MVP_MATRIX;
|
||||
break;
|
||||
|
||||
case MATRIX_TEXTURE:
|
||||
*matrix = STATE_TEXTURE;
|
||||
*matrix = STATE_TEXTURE_MATRIX;
|
||||
*matrix_idx = parse_integer (inst, Program);
|
||||
if (*matrix_idx >= (GLint) ctx->Const.MaxTextureUnits) {
|
||||
program_error(ctx, Program->Position, "Invalid Texture Unit");
|
||||
@@ -1044,7 +1046,7 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra
|
||||
break;
|
||||
|
||||
case MATRIX_PROGRAM:
|
||||
*matrix = STATE_PROGRAM;
|
||||
*matrix = STATE_PROGRAM_MATRIX;
|
||||
*matrix_idx = parse_integer (inst, Program);
|
||||
if (*matrix_idx >= (GLint) ctx->Const.MaxProgramMatrices) {
|
||||
program_error(ctx, Program->Position, "Invalid Program Matrix");
|
||||
@@ -1083,7 +1085,8 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra
|
||||
*/
|
||||
static GLuint
|
||||
parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
|
||||
struct arb_program *Program, GLint * state_tokens)
|
||||
struct arb_program *Program,
|
||||
gl_state_index state_tokens[STATE_LENGTH])
|
||||
{
|
||||
switch (*(*inst)++) {
|
||||
case STATE_MATERIAL_PARSER:
|
||||
@@ -1136,7 +1139,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
|
||||
state_tokens[2] = STATE_ATTENUATION;
|
||||
break;
|
||||
case LIGHT_HALF:
|
||||
state_tokens[2] = STATE_HALF;
|
||||
state_tokens[2] = STATE_HALF_VECTOR;
|
||||
break;
|
||||
case LIGHT_SPOT_DIRECTION:
|
||||
state_tokens[2] = STATE_SPOT_DIRECTION;
|
||||
@@ -1265,7 +1268,8 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
|
||||
case STATE_CLIP_PLANE:
|
||||
state_tokens[0] = STATE_CLIPPLANE;
|
||||
state_tokens[1] = parse_integer (inst, Program);
|
||||
if (parse_clipplane_num (ctx, inst, Program, &state_tokens[1]))
|
||||
if (parse_clipplane_num (ctx, inst, Program,
|
||||
(GLint *) &state_tokens[1]))
|
||||
return 1;
|
||||
break;
|
||||
|
||||
@@ -1283,17 +1287,17 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
|
||||
|
||||
/* XXX: I think this is the correct format for a matrix row */
|
||||
case STATE_MATRIX_ROWS:
|
||||
state_tokens[0] = STATE_MATRIX;
|
||||
if (parse_matrix
|
||||
(ctx, inst, Program, &state_tokens[1], &state_tokens[2],
|
||||
&state_tokens[5]))
|
||||
if (parse_matrix(ctx, inst, Program,
|
||||
(GLint *) &state_tokens[0],
|
||||
(GLint *) &state_tokens[1],
|
||||
(GLint *) &state_tokens[4]))
|
||||
return 1;
|
||||
|
||||
state_tokens[3] = parse_integer (inst, Program); /* The first row to grab */
|
||||
state_tokens[2] = parse_integer (inst, Program); /* The first row to grab */
|
||||
|
||||
if ((**inst) != 0) { /* Either the last row, 0 */
|
||||
state_tokens[4] = parse_integer (inst, Program);
|
||||
if (state_tokens[4] < state_tokens[3]) {
|
||||
state_tokens[3] = parse_integer (inst, Program);
|
||||
if (state_tokens[3] < state_tokens[2]) {
|
||||
program_error(ctx, Program->Position,
|
||||
"Second matrix index less than the first");
|
||||
/* state_tokens[4] vs. state_tokens[3] */
|
||||
@@ -1301,7 +1305,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
|
||||
}
|
||||
}
|
||||
else {
|
||||
state_tokens[4] = state_tokens[3];
|
||||
state_tokens[3] = state_tokens[2];
|
||||
(*inst)++;
|
||||
}
|
||||
break;
|
||||
@@ -1342,7 +1346,8 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
|
||||
*/
|
||||
static GLuint
|
||||
parse_program_single_item (GLcontext * ctx, const GLubyte ** inst,
|
||||
struct arb_program *Program, GLint * state_tokens)
|
||||
struct arb_program *Program,
|
||||
gl_state_index state_tokens[STATE_LENGTH])
|
||||
{
|
||||
if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB)
|
||||
state_tokens[0] = STATE_FRAGMENT_PROGRAM;
|
||||
@@ -1459,7 +1464,7 @@ parse_attrib_binding(GLcontext * ctx, const GLubyte ** inst,
|
||||
break;
|
||||
case FRAGMENT_ATTRIB_TEXCOORD:
|
||||
{
|
||||
GLuint texcoord;
|
||||
GLuint texcoord = 0;
|
||||
err = parse_texcoord_num (ctx, inst, Program, &texcoord);
|
||||
*inputReg = FRAG_ATTRIB_TEX0 + texcoord;
|
||||
}
|
||||
@@ -1520,7 +1525,7 @@ parse_attrib_binding(GLcontext * ctx, const GLubyte ** inst,
|
||||
|
||||
case VERTEX_ATTRIB_TEXCOORD:
|
||||
{
|
||||
GLuint unit;
|
||||
GLuint unit = 0;
|
||||
err = parse_texcoord_num (ctx, inst, Program, &unit);
|
||||
*inputReg = VERT_ATTRIB_TEX0 + unit;
|
||||
}
|
||||
@@ -1717,7 +1722,7 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst,
|
||||
{
|
||||
GLint idx;
|
||||
GLuint err = 0;
|
||||
GLint state_tokens[6];
|
||||
gl_state_index state_tokens[STATE_LENGTH];
|
||||
GLfloat const_values[4];
|
||||
|
||||
switch (*(*inst)++) {
|
||||
@@ -1728,14 +1733,18 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst,
|
||||
/* If we adding STATE_MATRIX that has multiple rows, we need to
|
||||
* unroll it and call _mesa_add_state_reference() for each row
|
||||
*/
|
||||
if ((state_tokens[0] == STATE_MATRIX)
|
||||
&& (state_tokens[3] != state_tokens[4])) {
|
||||
if ((state_tokens[0] == STATE_MODELVIEW_MATRIX ||
|
||||
state_tokens[0] == STATE_PROJECTION_MATRIX ||
|
||||
state_tokens[0] == STATE_MVP_MATRIX ||
|
||||
state_tokens[0] == STATE_TEXTURE_MATRIX ||
|
||||
state_tokens[0] == STATE_PROGRAM_MATRIX)
|
||||
&& (state_tokens[2] != state_tokens[3])) {
|
||||
GLint row;
|
||||
GLint first_row = state_tokens[3];
|
||||
GLint last_row = state_tokens[4];
|
||||
const GLint first_row = state_tokens[2];
|
||||
const GLint last_row = state_tokens[3];
|
||||
|
||||
for (row = first_row; row <= last_row; row++) {
|
||||
state_tokens[3] = state_tokens[4] = row;
|
||||
state_tokens[2] = state_tokens[3] = row;
|
||||
|
||||
idx = _mesa_add_state_reference(Program->Base.Parameters,
|
||||
state_tokens);
|
||||
@@ -3328,186 +3337,6 @@ parse_vp_instruction (GLcontext * ctx, const GLubyte ** inst,
|
||||
|
||||
#if DEBUG_PARSING
|
||||
|
||||
static GLvoid
|
||||
print_state_token (GLint token)
|
||||
{
|
||||
switch (token) {
|
||||
case STATE_MATERIAL:
|
||||
fprintf (stderr, "STATE_MATERIAL ");
|
||||
break;
|
||||
case STATE_LIGHT:
|
||||
fprintf (stderr, "STATE_LIGHT ");
|
||||
break;
|
||||
|
||||
case STATE_LIGHTMODEL_AMBIENT:
|
||||
fprintf (stderr, "STATE_AMBIENT ");
|
||||
break;
|
||||
|
||||
case STATE_LIGHTMODEL_SCENECOLOR:
|
||||
fprintf (stderr, "STATE_SCENECOLOR ");
|
||||
break;
|
||||
|
||||
case STATE_LIGHTPROD:
|
||||
fprintf (stderr, "STATE_LIGHTPROD ");
|
||||
break;
|
||||
|
||||
case STATE_TEXGEN:
|
||||
fprintf (stderr, "STATE_TEXGEN ");
|
||||
break;
|
||||
|
||||
case STATE_FOG_COLOR:
|
||||
fprintf (stderr, "STATE_FOG_COLOR ");
|
||||
break;
|
||||
|
||||
case STATE_FOG_PARAMS:
|
||||
fprintf (stderr, "STATE_FOG_PARAMS ");
|
||||
break;
|
||||
|
||||
case STATE_CLIPPLANE:
|
||||
fprintf (stderr, "STATE_CLIPPLANE ");
|
||||
break;
|
||||
|
||||
case STATE_POINT_SIZE:
|
||||
fprintf (stderr, "STATE_POINT_SIZE ");
|
||||
break;
|
||||
|
||||
case STATE_POINT_ATTENUATION:
|
||||
fprintf (stderr, "STATE_ATTENUATION ");
|
||||
break;
|
||||
|
||||
case STATE_MATRIX:
|
||||
fprintf (stderr, "STATE_MATRIX ");
|
||||
break;
|
||||
|
||||
case STATE_MODELVIEW:
|
||||
fprintf (stderr, "STATE_MODELVIEW ");
|
||||
break;
|
||||
|
||||
case STATE_PROJECTION:
|
||||
fprintf (stderr, "STATE_PROJECTION ");
|
||||
break;
|
||||
|
||||
case STATE_MVP:
|
||||
fprintf (stderr, "STATE_MVP ");
|
||||
break;
|
||||
|
||||
case STATE_TEXTURE:
|
||||
fprintf (stderr, "STATE_TEXTURE ");
|
||||
break;
|
||||
|
||||
case STATE_PROGRAM:
|
||||
fprintf (stderr, "STATE_PROGRAM ");
|
||||
break;
|
||||
|
||||
case STATE_MATRIX_INVERSE:
|
||||
fprintf (stderr, "STATE_INVERSE ");
|
||||
break;
|
||||
|
||||
case STATE_MATRIX_TRANSPOSE:
|
||||
fprintf (stderr, "STATE_TRANSPOSE ");
|
||||
break;
|
||||
|
||||
case STATE_MATRIX_INVTRANS:
|
||||
fprintf (stderr, "STATE_INVTRANS ");
|
||||
break;
|
||||
|
||||
case STATE_AMBIENT:
|
||||
fprintf (stderr, "STATE_AMBIENT ");
|
||||
break;
|
||||
|
||||
case STATE_DIFFUSE:
|
||||
fprintf (stderr, "STATE_DIFFUSE ");
|
||||
break;
|
||||
|
||||
case STATE_SPECULAR:
|
||||
fprintf (stderr, "STATE_SPECULAR ");
|
||||
break;
|
||||
|
||||
case STATE_EMISSION:
|
||||
fprintf (stderr, "STATE_EMISSION ");
|
||||
break;
|
||||
|
||||
case STATE_SHININESS:
|
||||
fprintf (stderr, "STATE_SHININESS ");
|
||||
break;
|
||||
|
||||
case STATE_HALF:
|
||||
fprintf (stderr, "STATE_HALF ");
|
||||
break;
|
||||
|
||||
case STATE_POSITION:
|
||||
fprintf (stderr, "STATE_POSITION ");
|
||||
break;
|
||||
|
||||
case STATE_ATTENUATION:
|
||||
fprintf (stderr, "STATE_ATTENUATION ");
|
||||
break;
|
||||
|
||||
case STATE_SPOT_DIRECTION:
|
||||
fprintf (stderr, "STATE_DIRECTION ");
|
||||
break;
|
||||
|
||||
case STATE_TEXGEN_EYE_S:
|
||||
fprintf (stderr, "STATE_TEXGEN_EYE_S ");
|
||||
break;
|
||||
|
||||
case STATE_TEXGEN_EYE_T:
|
||||
fprintf (stderr, "STATE_TEXGEN_EYE_T ");
|
||||
break;
|
||||
|
||||
case STATE_TEXGEN_EYE_R:
|
||||
fprintf (stderr, "STATE_TEXGEN_EYE_R ");
|
||||
break;
|
||||
|
||||
case STATE_TEXGEN_EYE_Q:
|
||||
fprintf (stderr, "STATE_TEXGEN_EYE_Q ");
|
||||
break;
|
||||
|
||||
case STATE_TEXGEN_OBJECT_S:
|
||||
fprintf (stderr, "STATE_TEXGEN_EYE_S ");
|
||||
break;
|
||||
|
||||
case STATE_TEXGEN_OBJECT_T:
|
||||
fprintf (stderr, "STATE_TEXGEN_OBJECT_T ");
|
||||
break;
|
||||
|
||||
case STATE_TEXGEN_OBJECT_R:
|
||||
fprintf (stderr, "STATE_TEXGEN_OBJECT_R ");
|
||||
break;
|
||||
|
||||
case STATE_TEXGEN_OBJECT_Q:
|
||||
fprintf (stderr, "STATE_TEXGEN_OBJECT_Q ");
|
||||
break;
|
||||
|
||||
case STATE_TEXENV_COLOR:
|
||||
fprintf (stderr, "STATE_TEXENV_COLOR ");
|
||||
break;
|
||||
|
||||
case STATE_DEPTH_RANGE:
|
||||
fprintf (stderr, "STATE_DEPTH_RANGE ");
|
||||
break;
|
||||
|
||||
case STATE_VERTEX_PROGRAM:
|
||||
fprintf (stderr, "STATE_VERTEX_PROGRAM ");
|
||||
break;
|
||||
|
||||
case STATE_FRAGMENT_PROGRAM:
|
||||
fprintf (stderr, "STATE_FRAGMENT_PROGRAM ");
|
||||
break;
|
||||
|
||||
case STATE_ENV:
|
||||
fprintf (stderr, "STATE_ENV ");
|
||||
break;
|
||||
|
||||
case STATE_LOCAL:
|
||||
fprintf (stderr, "STATE_LOCAL ");
|
||||
break;
|
||||
|
||||
}
|
||||
fprintf (stderr, "[%d] ", token);
|
||||
}
|
||||
|
||||
|
||||
static GLvoid
|
||||
debug_variables (GLcontext * ctx, struct var_cache *vc_head,
|
||||
struct arb_program *Program)
|
||||
@@ -3515,12 +3344,12 @@ debug_variables (GLcontext * ctx, struct var_cache *vc_head,
|
||||
struct var_cache *vc;
|
||||
GLint a, b;
|
||||
|
||||
fprintf (stderr, "debug_variables, vc_head: %x\n", vc_head);
|
||||
fprintf (stderr, "debug_variables, vc_head: %p\n", (void*) vc_head);
|
||||
|
||||
/* First of all, print out the contents of the var_cache */
|
||||
vc = vc_head;
|
||||
while (vc) {
|
||||
fprintf (stderr, "[%x]\n", vc);
|
||||
fprintf (stderr, "[%p]\n", (void*) vc);
|
||||
switch (vc->type) {
|
||||
case vt_none:
|
||||
fprintf (stderr, "UNDEFINED %s\n", vc->name);
|
||||
@@ -3535,27 +3364,20 @@ debug_variables (GLcontext * ctx, struct var_cache *vc_head,
|
||||
b = vc->param_binding_begin;
|
||||
for (a = 0; a < vc->param_binding_length; a++) {
|
||||
fprintf (stderr, "%s\n",
|
||||
Program->Parameters->Parameters[a + b].Name);
|
||||
if (Program->Parameters->Parameters[a + b].Type == STATE) {
|
||||
print_state_token (Program->Parameters->Parameters[a + b].
|
||||
StateIndexes[0]);
|
||||
print_state_token (Program->Parameters->Parameters[a + b].
|
||||
StateIndexes[1]);
|
||||
print_state_token (Program->Parameters->Parameters[a + b].
|
||||
StateIndexes[2]);
|
||||
print_state_token (Program->Parameters->Parameters[a + b].
|
||||
StateIndexes[3]);
|
||||
print_state_token (Program->Parameters->Parameters[a + b].
|
||||
StateIndexes[4]);
|
||||
print_state_token (Program->Parameters->Parameters[a + b].
|
||||
StateIndexes[5]);
|
||||
Program->Base.Parameters->Parameters[a + b].Name);
|
||||
if (Program->Base.Parameters->Parameters[a + b].Type == PROGRAM_STATE_VAR) {
|
||||
const char *s;
|
||||
s = _mesa_program_state_string(Program->Base.Parameters->Parameters
|
||||
[a + b].StateIndexes);
|
||||
fprintf(stderr, "%s\n", s);
|
||||
_mesa_free((char *) s);
|
||||
}
|
||||
else
|
||||
fprintf (stderr, "%f %f %f %f\n",
|
||||
Program->Parameters->Parameters[a + b].Values[0],
|
||||
Program->Parameters->Parameters[a + b].Values[1],
|
||||
Program->Parameters->Parameters[a + b].Values[2],
|
||||
Program->Parameters->Parameters[a + b].Values[3]);
|
||||
Program->Base.Parameters->ParameterValues[a + b][0],
|
||||
Program->Base.Parameters->ParameterValues[a + b][1],
|
||||
Program->Base.Parameters->ParameterValues[a + b][2],
|
||||
Program->Base.Parameters->ParameterValues[a + b][3]);
|
||||
}
|
||||
break;
|
||||
case vt_temp:
|
||||
@@ -3568,9 +3390,12 @@ debug_variables (GLcontext * ctx, struct var_cache *vc_head,
|
||||
break;
|
||||
case vt_alias:
|
||||
fprintf (stderr, "ALIAS %s\n", vc->name);
|
||||
fprintf (stderr, " binding: 0x%x (%s)\n",
|
||||
vc->alias_binding, vc->alias_binding->name);
|
||||
fprintf (stderr, " binding: 0x%p (%s)\n",
|
||||
(void*) vc->alias_binding, vc->alias_binding->name);
|
||||
break;
|
||||
default:
|
||||
/* nothing */
|
||||
;
|
||||
}
|
||||
vc = vc->next;
|
||||
}
|
||||
@@ -3703,7 +3528,7 @@ parse_instructions(GLcontext * ctx, const GLubyte * inst,
|
||||
|
||||
|
||||
/* XXX temporary */
|
||||
__extension__ static char core_grammar_text[] =
|
||||
LONGSTRING static char core_grammar_text[] =
|
||||
#include "grammar_syn.h"
|
||||
;
|
||||
|
||||
@@ -4027,17 +3852,18 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target,
|
||||
program->Base.NumNativeParameters = ap.Base.NumNativeParameters;
|
||||
program->Base.NumNativeAttributes = ap.Base.NumNativeAttributes;
|
||||
program->Base.NumNativeAddressRegs = ap.Base.NumNativeAddressRegs;
|
||||
program->NumAluInstructions = ap.NumAluInstructions;
|
||||
program->NumTexInstructions = ap.NumTexInstructions;
|
||||
program->NumTexIndirections = ap.NumTexIndirections;
|
||||
program->NumNativeAluInstructions = ap.NumAluInstructions;
|
||||
program->NumNativeTexInstructions = ap.NumTexInstructions;
|
||||
program->NumNativeTexIndirections = ap.NumTexIndirections;
|
||||
program->Base.NumAluInstructions = ap.Base.NumAluInstructions;
|
||||
program->Base.NumTexInstructions = ap.Base.NumTexInstructions;
|
||||
program->Base.NumTexIndirections = ap.Base.NumTexIndirections;
|
||||
program->Base.NumNativeAluInstructions = ap.Base.NumAluInstructions;
|
||||
program->Base.NumNativeTexInstructions = ap.Base.NumTexInstructions;
|
||||
program->Base.NumNativeTexIndirections = ap.Base.NumTexIndirections;
|
||||
program->Base.InputsRead = ap.Base.InputsRead;
|
||||
program->Base.OutputsWritten = ap.Base.OutputsWritten;
|
||||
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
|
||||
program->TexturesUsed[i] = ap.TexturesUsed[i];
|
||||
program->Base.TexturesUsed[i] = ap.TexturesUsed[i];
|
||||
program->FogOption = ap.FogOption;
|
||||
program->UsesKill = ap.UsesKill;
|
||||
|
||||
if (program->Base.Instructions)
|
||||
_mesa_free(program->Base.Instructions);
|
||||
@@ -4101,7 +3927,7 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target,
|
||||
program->Base.Parameters = ap.Base.Parameters;
|
||||
|
||||
#if DEBUG_VP
|
||||
_mesa_printf("____________Vertex program %u __________\n", program->Base.ID);
|
||||
_mesa_printf("____________Vertex program %u __________\n", program->Base.Id);
|
||||
_mesa_print_program(&program->Base);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
|
||||
const GLfloat *params)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
unsigned i;
|
||||
GLint i;
|
||||
GLfloat * dest;
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
@@ -464,7 +464,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
struct gl_program *prog;
|
||||
unsigned i;
|
||||
GLint i;
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
@@ -720,22 +720,22 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
|
||||
const struct gl_fragment_program *fp = ctx->FragmentProgram.Current;
|
||||
switch (pname) {
|
||||
case GL_PROGRAM_ALU_INSTRUCTIONS_ARB:
|
||||
*params = fp->NumNativeAluInstructions;
|
||||
*params = fp->Base.NumNativeAluInstructions;
|
||||
return;
|
||||
case GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
|
||||
*params = fp->NumAluInstructions;
|
||||
*params = fp->Base.NumAluInstructions;
|
||||
return;
|
||||
case GL_PROGRAM_TEX_INSTRUCTIONS_ARB:
|
||||
*params = fp->NumTexInstructions;
|
||||
*params = fp->Base.NumTexInstructions;
|
||||
return;
|
||||
case GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
|
||||
*params = fp->NumNativeTexInstructions;
|
||||
*params = fp->Base.NumNativeTexInstructions;
|
||||
return;
|
||||
case GL_PROGRAM_TEX_INDIRECTIONS_ARB:
|
||||
*params = fp->NumTexIndirections;
|
||||
*params = fp->Base.NumTexIndirections;
|
||||
return;
|
||||
case GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
|
||||
*params = fp->NumNativeTexIndirections;
|
||||
*params = fp->Base.NumNativeTexIndirections;
|
||||
return;
|
||||
case GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB:
|
||||
*params = limits->MaxAluInstructions;
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# Makefile for core library for VMS
|
||||
# contributed by Jouk Jansen [email protected]
|
||||
# Last revision : 1 June 2005
|
||||
|
||||
.first
|
||||
define gl [----.include.gl]
|
||||
define math [--.math]
|
||||
define swrast [--.swrast]
|
||||
define array_cache [--.array_cache]
|
||||
|
||||
.include [----]mms-config.
|
||||
|
||||
##### MACROS #####
|
||||
|
||||
VPATH = RCS
|
||||
|
||||
INCDIR = [----.include],[],[--.main],[--.glapi],[-.slang]
|
||||
LIBDIR = [----.lib]
|
||||
CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
|
||||
|
||||
SOURCES = grammar_mesa.c
|
||||
|
||||
OBJECTS = grammar_mesa.obj
|
||||
|
||||
##### RULES #####
|
||||
|
||||
VERSION=Mesa V3.4
|
||||
|
||||
##### TARGETS #####
|
||||
all :
|
||||
$(MMS)$(MMSQUALIFIERS) $(LIBDIR)$(GL_LIB)
|
||||
|
||||
# Make the library
|
||||
$(LIBDIR)$(GL_LIB) : $(OBJECTS)
|
||||
@ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
|
||||
|
||||
clean :
|
||||
purge
|
||||
delete *.obj;*
|
||||
|
||||
grammar_mesa.obj : grammar_mesa.c grammar.c
|
||||
@@ -260,6 +260,8 @@
|
||||
first).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static void mem_free (void **);
|
||||
|
||||
/*
|
||||
@@ -2691,13 +2693,15 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
|
||||
|
||||
if (status == mr_matched)
|
||||
{
|
||||
if (sp->m_emits != NULL)
|
||||
if (emit_push (sp->m_emits, _BP->_F + _P, text[ind - 1], save_ind, &ctx))
|
||||
if (sp->m_emits != NULL) {
|
||||
const byte ch = (ind <= 0) ? 0 : text[ind - 1];
|
||||
if (emit_push (sp->m_emits, _BP->_F + _P, ch, save_ind, &ctx))
|
||||
{
|
||||
free_regbyte_ctx_stack (ctx, *rbc);
|
||||
return mr_internal_error;
|
||||
}
|
||||
|
||||
}
|
||||
_P = _P2;
|
||||
}
|
||||
|
||||
@@ -2797,10 +2801,16 @@ static void grammar_load_state_destroy (grammar_load_state **gr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void error_msg(int line, const char *msg)
|
||||
{
|
||||
fprintf(stderr, "Error in grammar_load_from_text() at line %d: %s\n", line, msg);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
the API
|
||||
*/
|
||||
|
||||
grammar grammar_load_from_text (const byte *text)
|
||||
{
|
||||
grammar_load_state *g = NULL;
|
||||
@@ -2809,13 +2819,16 @@ grammar grammar_load_from_text (const byte *text)
|
||||
clear_last_error ();
|
||||
|
||||
grammar_load_state_create (&g);
|
||||
if (g == NULL)
|
||||
if (g == NULL) {
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
dict_create (&g->di);
|
||||
if (g->di == NULL)
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2829,6 +2842,7 @@ grammar grammar_load_from_text (const byte *text)
|
||||
if (get_identifier (&text, &g->syntax_symbol))
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
eat_spaces (&text);
|
||||
@@ -2848,6 +2862,7 @@ grammar grammar_load_from_text (const byte *text)
|
||||
if (get_identifier (&text, &symbol))
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
eat_spaces (&text);
|
||||
@@ -2862,6 +2877,7 @@ grammar grammar_load_from_text (const byte *text)
|
||||
if (get_emtcode (&text, &ma))
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2877,6 +2893,7 @@ grammar grammar_load_from_text (const byte *text)
|
||||
if (get_regbyte (&text, &ma))
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2892,6 +2909,7 @@ grammar grammar_load_from_text (const byte *text)
|
||||
if (get_errtext (&text, &ma))
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2905,12 +2923,14 @@ grammar grammar_load_from_text (const byte *text)
|
||||
if (g->di->m_string != NULL)
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (get_identifier (&text, &g->string_symbol))
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2927,6 +2947,7 @@ grammar grammar_load_from_text (const byte *text)
|
||||
if (get_rule (&text, &ru, g->maps, g->mapb))
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2940,6 +2961,7 @@ grammar grammar_load_from_text (const byte *text)
|
||||
if (ma == NULL)
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2953,6 +2975,7 @@ grammar grammar_load_from_text (const byte *text)
|
||||
g->di->m_regbytes))
|
||||
{
|
||||
grammar_load_state_destroy (&g);
|
||||
error_msg(__LINE__, "update_dependencies() failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
MESA_SHADER_GRAMMAR_SOURCES = \
|
||||
grammar_mesa.c
|
||||
|
||||
MESA_SHADER_GRAMMAR_HEADERS = \
|
||||
grammar.c \
|
||||
grammar.h \
|
||||
grammar_mesa.h \
|
||||
grammar_syn.h
|
||||
@@ -39,13 +39,11 @@
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "hash.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "program_instruction.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "prog_instruction.h"
|
||||
#include "nvfragparse.h"
|
||||
#include "nvprogram.h"
|
||||
#include "program.h"
|
||||
|
||||
|
||||
@@ -1041,7 +1039,8 @@ Parse_VectorSrc(struct parse_state *parseState,
|
||||
GLuint paramIndex;
|
||||
if (!Parse_ScalarConstant(parseState, values))
|
||||
RETURN_ERROR;
|
||||
paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values, 4);
|
||||
paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
|
||||
values, 4, NULL);
|
||||
srcReg->File = PROGRAM_NAMED_PARAM;
|
||||
srcReg->Index = paramIndex;
|
||||
}
|
||||
@@ -1052,7 +1051,8 @@ Parse_VectorSrc(struct parse_state *parseState,
|
||||
(void) Parse_String(parseState, "{");
|
||||
if (!Parse_VectorConstant(parseState, values))
|
||||
RETURN_ERROR;
|
||||
paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values, 4);
|
||||
paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
|
||||
values, 4, NULL);
|
||||
srcReg->File = PROGRAM_NAMED_PARAM;
|
||||
srcReg->Index = paramIndex;
|
||||
}
|
||||
@@ -1142,7 +1142,8 @@ Parse_ScalarSrcReg(struct parse_state *parseState,
|
||||
(void) Parse_String(parseState, "{");
|
||||
if (!Parse_VectorConstant(parseState, values))
|
||||
RETURN_ERROR;
|
||||
paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values, 4);
|
||||
paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
|
||||
values, 4, NULL);
|
||||
srcReg->File = PROGRAM_NAMED_PARAM;
|
||||
srcReg->Index = paramIndex;
|
||||
}
|
||||
@@ -1166,7 +1167,8 @@ Parse_ScalarSrcReg(struct parse_state *parseState,
|
||||
GLuint paramIndex;
|
||||
if (!Parse_ScalarConstant(parseState, values))
|
||||
RETURN_ERROR;
|
||||
paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values, 4);
|
||||
paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
|
||||
values, 4, NULL);
|
||||
srcReg->Index = paramIndex;
|
||||
srcReg->File = PROGRAM_NAMED_PARAM;
|
||||
needSuffix = GL_FALSE;
|
||||
@@ -1539,8 +1541,7 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget,
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
|
||||
return; /* out of memory */
|
||||
}
|
||||
_mesa_memcpy(newInst, instBuffer,
|
||||
parseState.numInst * sizeof(struct prog_instruction));
|
||||
_mesa_copy_instructions(newInst, instBuffer, parseState.numInst);
|
||||
|
||||
/* install the program */
|
||||
program->Base.Target = target;
|
||||
@@ -1557,7 +1558,7 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget,
|
||||
program->Base.InputsRead = parseState.inputsRead;
|
||||
program->Base.OutputsWritten = parseState.outputsWritten;
|
||||
for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++)
|
||||
program->TexturesUsed[u] = parseState.texturesUsed[u];
|
||||
program->Base.TexturesUsed[u] = parseState.texturesUsed[u];
|
||||
|
||||
/* save program parameters */
|
||||
program->Base.Parameters = parseState.parameters;
|
||||
|
||||
@@ -42,10 +42,9 @@
|
||||
#include "hash.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "prog_instruction.h"
|
||||
#include "nvfragparse.h"
|
||||
#include "program_instruction.h"
|
||||
#include "nvvertexec.h"
|
||||
#include "nvvertparse.h"
|
||||
#include "nvprogram.h"
|
||||
#include "program.h"
|
||||
@@ -77,7 +76,7 @@ _mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
|
||||
return;
|
||||
}
|
||||
|
||||
_mesa_exec_vertex_state_program(ctx, vprog, params);
|
||||
_mesa_problem(ctx, "glExecuteProgramNV() not supported");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,835 +0,0 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file nvvertexec.c
|
||||
* Code to execute vertex programs.
|
||||
* \author Brian Paul
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "nvvertexec.h"
|
||||
#include "program_instruction.h"
|
||||
#include "program.h"
|
||||
#include "math/m_matrix.h"
|
||||
|
||||
|
||||
static const GLfloat ZeroVec[4] = { 0.0F, 0.0F, 0.0F, 0.0F };
|
||||
|
||||
|
||||
/**
|
||||
* Load/initialize the vertex program registers which need to be set
|
||||
* per-vertex.
|
||||
*/
|
||||
void
|
||||
_mesa_init_vp_per_vertex_registers(GLcontext *ctx, struct vp_machine *machine)
|
||||
{
|
||||
/* Input registers get initialized from the current vertex attribs */
|
||||
MEMCPY(machine->Inputs, ctx->Current.Attrib,
|
||||
MAX_VERTEX_PROGRAM_ATTRIBS * 4 * sizeof(GLfloat));
|
||||
|
||||
if (ctx->VertexProgram.Current->IsNVProgram) {
|
||||
GLuint i;
|
||||
/* Output/result regs are initialized to [0,0,0,1] */
|
||||
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_OUTPUTS; i++) {
|
||||
ASSIGN_4V(machine->Outputs[i], 0.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
/* Temp regs are initialized to [0,0,0,0] */
|
||||
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_TEMPS; i++) {
|
||||
ASSIGN_4V(machine->Temporaries[i], 0.0F, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
ASSIGN_4V(machine->AddressReg, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Copy the 16 elements of a matrix into four consecutive program
|
||||
* registers starting at 'pos'.
|
||||
*/
|
||||
static void
|
||||
load_matrix(GLfloat registers[][4], GLuint pos, const GLfloat mat[16])
|
||||
{
|
||||
GLuint i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
registers[pos + i][0] = mat[0 + i];
|
||||
registers[pos + i][1] = mat[4 + i];
|
||||
registers[pos + i][2] = mat[8 + i];
|
||||
registers[pos + i][3] = mat[12 + i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* As above, but transpose the matrix.
|
||||
*/
|
||||
static void
|
||||
load_transpose_matrix(GLfloat registers[][4], GLuint pos,
|
||||
const GLfloat mat[16])
|
||||
{
|
||||
MEMCPY(registers[pos], mat, 16 * sizeof(GLfloat));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load program parameter registers with tracked matrices (if NV program)
|
||||
* or GL state values (if ARB program).
|
||||
* This needs to be done per glBegin/glEnd, not per-vertex.
|
||||
*/
|
||||
void
|
||||
_mesa_init_vp_per_primitive_registers(GLcontext *ctx)
|
||||
{
|
||||
if (ctx->VertexProgram.Current->IsNVProgram) {
|
||||
GLuint i;
|
||||
|
||||
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) {
|
||||
/* point 'mat' at source matrix */
|
||||
GLmatrix *mat;
|
||||
if (ctx->VertexProgram.TrackMatrix[i] == GL_MODELVIEW) {
|
||||
mat = ctx->ModelviewMatrixStack.Top;
|
||||
}
|
||||
else if (ctx->VertexProgram.TrackMatrix[i] == GL_PROJECTION) {
|
||||
mat = ctx->ProjectionMatrixStack.Top;
|
||||
}
|
||||
else if (ctx->VertexProgram.TrackMatrix[i] == GL_TEXTURE) {
|
||||
mat = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top;
|
||||
}
|
||||
else if (ctx->VertexProgram.TrackMatrix[i] == GL_COLOR) {
|
||||
mat = ctx->ColorMatrixStack.Top;
|
||||
}
|
||||
else if (ctx->VertexProgram.TrackMatrix[i]==GL_MODELVIEW_PROJECTION_NV) {
|
||||
/* XXX verify the combined matrix is up to date */
|
||||
mat = &ctx->_ModelProjectMatrix;
|
||||
}
|
||||
else if (ctx->VertexProgram.TrackMatrix[i] >= GL_MATRIX0_NV &&
|
||||
ctx->VertexProgram.TrackMatrix[i] <= GL_MATRIX7_NV) {
|
||||
GLuint n = ctx->VertexProgram.TrackMatrix[i] - GL_MATRIX0_NV;
|
||||
ASSERT(n < MAX_PROGRAM_MATRICES);
|
||||
mat = ctx->ProgramMatrixStack[n].Top;
|
||||
}
|
||||
else {
|
||||
/* no matrix is tracked, but we leave the register values as-is */
|
||||
assert(ctx->VertexProgram.TrackMatrix[i] == GL_NONE);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* load the matrix values into sequential registers */
|
||||
if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_IDENTITY_NV) {
|
||||
load_matrix(ctx->VertexProgram.Parameters, i*4, mat->m);
|
||||
}
|
||||
else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_INVERSE_NV) {
|
||||
_math_matrix_analyse(mat); /* update the inverse */
|
||||
ASSERT(!_math_matrix_is_dirty(mat));
|
||||
load_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv);
|
||||
}
|
||||
else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_TRANSPOSE_NV) {
|
||||
load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->m);
|
||||
}
|
||||
else {
|
||||
assert(ctx->VertexProgram.TrackMatrixTransform[i]
|
||||
== GL_INVERSE_TRANSPOSE_NV);
|
||||
_math_matrix_analyse(mat); /* update the inverse */
|
||||
ASSERT(!_math_matrix_is_dirty(mat));
|
||||
load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* ARB vertex program */
|
||||
if (ctx->VertexProgram.Current->Base.Parameters) {
|
||||
/* Grab the state GL state and put into registers */
|
||||
_mesa_load_state_parameters(ctx,
|
||||
ctx->VertexProgram.Current->Base.Parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* For debugging. Dump the current vertex program machine registers.
|
||||
*/
|
||||
void
|
||||
_mesa_dump_vp_state( const struct gl_vertex_program_state *state,
|
||||
const struct vp_machine *machine)
|
||||
{
|
||||
int i;
|
||||
_mesa_printf("VertexIn:\n");
|
||||
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_INPUTS; i++) {
|
||||
_mesa_printf("%d: %f %f %f %f ", i,
|
||||
machine->Inputs[i][0],
|
||||
machine->Inputs[i][1],
|
||||
machine->Inputs[i][2],
|
||||
machine->Inputs[i][3]);
|
||||
}
|
||||
_mesa_printf("\n");
|
||||
|
||||
_mesa_printf("VertexOut:\n");
|
||||
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_OUTPUTS; i++) {
|
||||
_mesa_printf("%d: %f %f %f %f ", i,
|
||||
machine->Outputs[i][0],
|
||||
machine->Outputs[i][1],
|
||||
machine->Outputs[i][2],
|
||||
machine->Outputs[i][3]);
|
||||
}
|
||||
_mesa_printf("\n");
|
||||
|
||||
_mesa_printf("Registers:\n");
|
||||
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_TEMPS; i++) {
|
||||
_mesa_printf("%d: %f %f %f %f ", i,
|
||||
machine->Temporaries[i][0],
|
||||
machine->Temporaries[i][1],
|
||||
machine->Temporaries[i][2],
|
||||
machine->Temporaries[i][3]);
|
||||
}
|
||||
_mesa_printf("\n");
|
||||
|
||||
_mesa_printf("Parameters:\n");
|
||||
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS; i++) {
|
||||
_mesa_printf("%d: %f %f %f %f ", i,
|
||||
state->Parameters[i][0],
|
||||
state->Parameters[i][1],
|
||||
state->Parameters[i][2],
|
||||
state->Parameters[i][3]);
|
||||
}
|
||||
_mesa_printf("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a pointer to the 4-element float vector specified by the given
|
||||
* source register.
|
||||
*/
|
||||
static INLINE const GLfloat *
|
||||
get_register_pointer( GLcontext *ctx,
|
||||
const struct prog_src_register *source,
|
||||
struct vp_machine *machine,
|
||||
const struct gl_vertex_program *program )
|
||||
{
|
||||
if (source->RelAddr) {
|
||||
const GLint reg = source->Index + machine->AddressReg[0];
|
||||
ASSERT( (source->File == PROGRAM_ENV_PARAM) ||
|
||||
(source->File == PROGRAM_STATE_VAR) );
|
||||
if (reg < 0 || reg > MAX_NV_VERTEX_PROGRAM_PARAMS)
|
||||
return ZeroVec;
|
||||
else if (source->File == PROGRAM_ENV_PARAM)
|
||||
return ctx->VertexProgram.Parameters[reg];
|
||||
else {
|
||||
ASSERT(source->File == PROGRAM_LOCAL_PARAM);
|
||||
return program->Base.Parameters->ParameterValues[reg];
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (source->File) {
|
||||
case PROGRAM_TEMPORARY:
|
||||
ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_TEMPS);
|
||||
return machine->Temporaries[source->Index];
|
||||
case PROGRAM_INPUT:
|
||||
ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_INPUTS);
|
||||
return machine->Inputs[source->Index];
|
||||
case PROGRAM_OUTPUT:
|
||||
/* This is only needed for the PRINT instruction */
|
||||
ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_OUTPUTS);
|
||||
return machine->Outputs[source->Index];
|
||||
case PROGRAM_LOCAL_PARAM:
|
||||
ASSERT(source->Index < MAX_PROGRAM_LOCAL_PARAMS);
|
||||
return program->Base.LocalParams[source->Index];
|
||||
case PROGRAM_ENV_PARAM:
|
||||
ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_PARAMS);
|
||||
return ctx->VertexProgram.Parameters[source->Index];
|
||||
case PROGRAM_STATE_VAR:
|
||||
ASSERT(source->Index < program->Base.Parameters->NumParameters);
|
||||
return program->Base.Parameters->ParameterValues[source->Index];
|
||||
default:
|
||||
_mesa_problem(NULL,
|
||||
"Bad source register file in get_register_pointer");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a 4-element float vector from the given source register.
|
||||
* Apply swizzling and negating as needed.
|
||||
*/
|
||||
static INLINE void
|
||||
fetch_vector4( GLcontext *ctx,
|
||||
const struct prog_src_register *source,
|
||||
struct vp_machine *machine,
|
||||
const struct gl_vertex_program *program,
|
||||
GLfloat result[4] )
|
||||
{
|
||||
const GLfloat *src = get_register_pointer(ctx, source, machine, program);
|
||||
ASSERT(src);
|
||||
result[0] = src[GET_SWZ(source->Swizzle, 0)];
|
||||
result[1] = src[GET_SWZ(source->Swizzle, 1)];
|
||||
result[2] = src[GET_SWZ(source->Swizzle, 2)];
|
||||
result[3] = src[GET_SWZ(source->Swizzle, 3)];
|
||||
if (source->NegateBase) {
|
||||
result[0] = -result[0];
|
||||
result[1] = -result[1];
|
||||
result[2] = -result[2];
|
||||
result[3] = -result[3];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* As above, but only return result[0] element.
|
||||
*/
|
||||
static INLINE void
|
||||
fetch_vector1( GLcontext *ctx,
|
||||
const struct prog_src_register *source,
|
||||
struct vp_machine *machine,
|
||||
const struct gl_vertex_program *program,
|
||||
GLfloat result[4] )
|
||||
{
|
||||
const GLfloat *src = get_register_pointer(ctx, source, machine, program);
|
||||
ASSERT(src);
|
||||
result[0] = src[GET_SWZ(source->Swizzle, 0)];
|
||||
if (source->NegateBase) {
|
||||
result[0] = -result[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store 4 floats into a register.
|
||||
*/
|
||||
static void
|
||||
store_vector4( const struct prog_instruction *inst,
|
||||
struct vp_machine *machine,
|
||||
const GLfloat value[4] )
|
||||
{
|
||||
const struct prog_dst_register *dest = &(inst->DstReg);
|
||||
GLfloat *dst;
|
||||
switch (dest->File) {
|
||||
case PROGRAM_OUTPUT:
|
||||
dst = machine->Outputs[dest->Index];
|
||||
break;
|
||||
case PROGRAM_TEMPORARY:
|
||||
dst = machine->Temporaries[dest->Index];
|
||||
break;
|
||||
case PROGRAM_ENV_PARAM:
|
||||
/* Only for VP state programs */
|
||||
{
|
||||
/* a slight hack */
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
dst = ctx->VertexProgram.Parameters[dest->Index];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(NULL, "Invalid register file in store_vector4(file=%d)",
|
||||
dest->File);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dest->WriteMask & WRITEMASK_X)
|
||||
dst[0] = value[0];
|
||||
if (dest->WriteMask & WRITEMASK_Y)
|
||||
dst[1] = value[1];
|
||||
if (dest->WriteMask & WRITEMASK_Z)
|
||||
dst[2] = value[2];
|
||||
if (dest->WriteMask & WRITEMASK_W)
|
||||
dst[3] = value[3];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set x to positive or negative infinity.
|
||||
*/
|
||||
#if defined(USE_IEEE) || defined(_WIN32)
|
||||
#define SET_POS_INFINITY(x) ( *((GLuint *) (void *)&x) = 0x7F800000 )
|
||||
#define SET_NEG_INFINITY(x) ( *((GLuint *) (void *)&x) = 0xFF800000 )
|
||||
#elif defined(VMS)
|
||||
#define SET_POS_INFINITY(x) x = __MAXFLOAT
|
||||
#define SET_NEG_INFINITY(x) x = -__MAXFLOAT
|
||||
#else
|
||||
#define SET_POS_INFINITY(x) x = (GLfloat) HUGE_VAL
|
||||
#define SET_NEG_INFINITY(x) x = (GLfloat) -HUGE_VAL
|
||||
#endif
|
||||
|
||||
#define SET_FLOAT_BITS(x, bits) ((fi_type *) (void *) &(x))->i = bits
|
||||
|
||||
|
||||
/**
|
||||
* Execute the given vertex program
|
||||
*/
|
||||
void
|
||||
_mesa_exec_vertex_program(GLcontext *ctx,
|
||||
struct vp_machine *machine,
|
||||
const struct gl_vertex_program *program)
|
||||
{
|
||||
const struct prog_instruction *inst;
|
||||
|
||||
ctx->_CurrentProgram = GL_VERTEX_PROGRAM_ARB; /* or NV, doesn't matter */
|
||||
|
||||
/* If the program is position invariant, multiply the input position
|
||||
* by the MVP matrix and store in the vertex position result register.
|
||||
*/
|
||||
if (ctx->VertexProgram.Current->IsPositionInvariant) {
|
||||
TRANSFORM_POINT( machine->Outputs[VERT_RESULT_HPOS],
|
||||
ctx->_ModelProjectMatrix.m,
|
||||
machine->Inputs[VERT_ATTRIB_POS]);
|
||||
|
||||
/* XXX: This could go elsewhere */
|
||||
ctx->VertexProgram.Current->Base.OutputsWritten |= VERT_BIT_POS;
|
||||
}
|
||||
|
||||
for (inst = program->Base.Instructions; ; inst++) {
|
||||
|
||||
if (ctx->VertexProgram.CallbackEnabled &&
|
||||
ctx->VertexProgram.Callback) {
|
||||
ctx->VertexProgram.CurrentPosition = inst->StringPos;
|
||||
ctx->VertexProgram.Callback(program->Base.Target,
|
||||
ctx->VertexProgram.CallbackData);
|
||||
}
|
||||
|
||||
switch (inst->Opcode) {
|
||||
case OPCODE_MOV:
|
||||
{
|
||||
GLfloat t[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_LIT:
|
||||
{
|
||||
const GLfloat epsilon = 1.0F / 256.0F; /* per NV spec */
|
||||
GLfloat t[4], lit[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
t[0] = MAX2(t[0], 0.0F);
|
||||
t[1] = MAX2(t[1], 0.0F);
|
||||
t[3] = CLAMP(t[3], -(128.0F - epsilon), (128.0F - epsilon));
|
||||
lit[0] = 1.0;
|
||||
lit[1] = t[0];
|
||||
lit[2] = (t[0] > 0.0) ? (GLfloat) _mesa_pow(t[1], t[3]) : 0.0F;
|
||||
lit[3] = 1.0;
|
||||
store_vector4( inst, machine, lit );
|
||||
}
|
||||
break;
|
||||
case OPCODE_RCP:
|
||||
{
|
||||
GLfloat t[4];
|
||||
fetch_vector1( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
if (t[0] != 1.0F)
|
||||
t[0] = 1.0F / t[0]; /* div by zero is infinity! */
|
||||
t[1] = t[2] = t[3] = t[0];
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_RSQ:
|
||||
{
|
||||
GLfloat t[4];
|
||||
fetch_vector1( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
t[0] = INV_SQRTF(FABSF(t[0]));
|
||||
t[1] = t[2] = t[3] = t[0];
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_EXP:
|
||||
{
|
||||
GLfloat t[4], q[4], floor_t0;
|
||||
fetch_vector1( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
floor_t0 = FLOORF(t[0]);
|
||||
if (floor_t0 > FLT_MAX_EXP) {
|
||||
SET_POS_INFINITY(q[0]);
|
||||
SET_POS_INFINITY(q[2]);
|
||||
}
|
||||
else if (floor_t0 < FLT_MIN_EXP) {
|
||||
q[0] = 0.0F;
|
||||
q[2] = 0.0F;
|
||||
}
|
||||
else {
|
||||
#ifdef USE_IEEE
|
||||
GLint ii = (GLint) floor_t0;
|
||||
ii = (ii < 23) + 0x3f800000;
|
||||
SET_FLOAT_BITS(q[0], ii);
|
||||
q[0] = *((GLfloat *) (void *)&ii);
|
||||
#else
|
||||
q[0] = (GLfloat) pow(2.0, floor_t0);
|
||||
#endif
|
||||
q[2] = (GLfloat) (q[0] * LOG2(q[1]));
|
||||
}
|
||||
q[1] = t[0] - floor_t0;
|
||||
q[3] = 1.0F;
|
||||
store_vector4( inst, machine, q );
|
||||
}
|
||||
break;
|
||||
case OPCODE_LOG:
|
||||
{
|
||||
GLfloat t[4], q[4], abs_t0;
|
||||
fetch_vector1( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
abs_t0 = FABSF(t[0]);
|
||||
if (abs_t0 != 0.0F) {
|
||||
/* Since we really can't handle infinite values on VMS
|
||||
* like other OSes we'll use __MAXFLOAT to represent
|
||||
* infinity. This may need some tweaking.
|
||||
*/
|
||||
#ifdef VMS
|
||||
if (abs_t0 == __MAXFLOAT)
|
||||
#else
|
||||
if (IS_INF_OR_NAN(abs_t0))
|
||||
#endif
|
||||
{
|
||||
SET_POS_INFINITY(q[0]);
|
||||
q[1] = 1.0F;
|
||||
SET_POS_INFINITY(q[2]);
|
||||
}
|
||||
else {
|
||||
int exponent;
|
||||
GLfloat mantissa = FREXPF(t[0], &exponent);
|
||||
q[0] = (GLfloat) (exponent - 1);
|
||||
q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */
|
||||
q[2] = (GLfloat) (q[0] + LOG2(q[1]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
SET_NEG_INFINITY(q[0]);
|
||||
q[1] = 1.0F;
|
||||
SET_NEG_INFINITY(q[2]);
|
||||
}
|
||||
q[3] = 1.0;
|
||||
store_vector4( inst, machine, q );
|
||||
}
|
||||
break;
|
||||
case OPCODE_MUL:
|
||||
{
|
||||
GLfloat t[4], u[4], prod[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
prod[0] = t[0] * u[0];
|
||||
prod[1] = t[1] * u[1];
|
||||
prod[2] = t[2] * u[2];
|
||||
prod[3] = t[3] * u[3];
|
||||
store_vector4( inst, machine, prod );
|
||||
}
|
||||
break;
|
||||
case OPCODE_ADD:
|
||||
{
|
||||
GLfloat t[4], u[4], sum[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
sum[0] = t[0] + u[0];
|
||||
sum[1] = t[1] + u[1];
|
||||
sum[2] = t[2] + u[2];
|
||||
sum[3] = t[3] + u[3];
|
||||
store_vector4( inst, machine, sum );
|
||||
}
|
||||
break;
|
||||
case OPCODE_DP3:
|
||||
{
|
||||
GLfloat t[4], u[4], dot[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
dot[0] = t[0] * u[0] + t[1] * u[1] + t[2] * u[2];
|
||||
dot[1] = dot[2] = dot[3] = dot[0];
|
||||
store_vector4( inst, machine, dot );
|
||||
}
|
||||
break;
|
||||
case OPCODE_DP4:
|
||||
{
|
||||
GLfloat t[4], u[4], dot[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
dot[0] = t[0] * u[0] + t[1] * u[1] + t[2] * u[2] + t[3] * u[3];
|
||||
dot[1] = dot[2] = dot[3] = dot[0];
|
||||
store_vector4( inst, machine, dot );
|
||||
}
|
||||
break;
|
||||
case OPCODE_DST:
|
||||
{
|
||||
GLfloat t[4], u[4], dst[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
dst[0] = 1.0F;
|
||||
dst[1] = t[1] * u[1];
|
||||
dst[2] = t[2];
|
||||
dst[3] = u[3];
|
||||
store_vector4( inst, machine, dst );
|
||||
}
|
||||
break;
|
||||
case OPCODE_MIN:
|
||||
{
|
||||
GLfloat t[4], u[4], min[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
min[0] = (t[0] < u[0]) ? t[0] : u[0];
|
||||
min[1] = (t[1] < u[1]) ? t[1] : u[1];
|
||||
min[2] = (t[2] < u[2]) ? t[2] : u[2];
|
||||
min[3] = (t[3] < u[3]) ? t[3] : u[3];
|
||||
store_vector4( inst, machine, min );
|
||||
}
|
||||
break;
|
||||
case OPCODE_MAX:
|
||||
{
|
||||
GLfloat t[4], u[4], max[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
max[0] = (t[0] > u[0]) ? t[0] : u[0];
|
||||
max[1] = (t[1] > u[1]) ? t[1] : u[1];
|
||||
max[2] = (t[2] > u[2]) ? t[2] : u[2];
|
||||
max[3] = (t[3] > u[3]) ? t[3] : u[3];
|
||||
store_vector4( inst, machine, max );
|
||||
}
|
||||
break;
|
||||
case OPCODE_SLT:
|
||||
{
|
||||
GLfloat t[4], u[4], slt[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
slt[0] = (t[0] < u[0]) ? 1.0F : 0.0F;
|
||||
slt[1] = (t[1] < u[1]) ? 1.0F : 0.0F;
|
||||
slt[2] = (t[2] < u[2]) ? 1.0F : 0.0F;
|
||||
slt[3] = (t[3] < u[3]) ? 1.0F : 0.0F;
|
||||
store_vector4( inst, machine, slt );
|
||||
}
|
||||
break;
|
||||
case OPCODE_SGE:
|
||||
{
|
||||
GLfloat t[4], u[4], sge[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
sge[0] = (t[0] >= u[0]) ? 1.0F : 0.0F;
|
||||
sge[1] = (t[1] >= u[1]) ? 1.0F : 0.0F;
|
||||
sge[2] = (t[2] >= u[2]) ? 1.0F : 0.0F;
|
||||
sge[3] = (t[3] >= u[3]) ? 1.0F : 0.0F;
|
||||
store_vector4( inst, machine, sge );
|
||||
}
|
||||
break;
|
||||
case OPCODE_MAD:
|
||||
{
|
||||
GLfloat t[4], u[4], v[4], sum[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
fetch_vector4( ctx, &inst->SrcReg[2], machine, program, v );
|
||||
sum[0] = t[0] * u[0] + v[0];
|
||||
sum[1] = t[1] * u[1] + v[1];
|
||||
sum[2] = t[2] * u[2] + v[2];
|
||||
sum[3] = t[3] * u[3] + v[3];
|
||||
store_vector4( inst, machine, sum );
|
||||
}
|
||||
break;
|
||||
case OPCODE_ARL:
|
||||
{
|
||||
GLfloat t[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
machine->AddressReg[0] = (GLint) FLOORF(t[0]);
|
||||
}
|
||||
break;
|
||||
case OPCODE_DPH:
|
||||
{
|
||||
GLfloat t[4], u[4], dot[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
dot[0] = t[0] * u[0] + t[1] * u[1] + t[2] * u[2] + u[3];
|
||||
dot[1] = dot[2] = dot[3] = dot[0];
|
||||
store_vector4( inst, machine, dot );
|
||||
}
|
||||
break;
|
||||
case OPCODE_RCC:
|
||||
{
|
||||
GLfloat t[4], u;
|
||||
fetch_vector1( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
if (t[0] == 1.0F)
|
||||
u = 1.0F;
|
||||
else
|
||||
u = 1.0F / t[0];
|
||||
if (u > 0.0F) {
|
||||
if (u > 1.884467e+019F) {
|
||||
u = 1.884467e+019F; /* IEEE 32-bit binary value 0x5F800000 */
|
||||
}
|
||||
else if (u < 5.42101e-020F) {
|
||||
u = 5.42101e-020F; /* IEEE 32-bit binary value 0x1F800000 */
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (u < -1.884467e+019F) {
|
||||
u = -1.884467e+019F; /* IEEE 32-bit binary value 0xDF800000 */
|
||||
}
|
||||
else if (u > -5.42101e-020F) {
|
||||
u = -5.42101e-020F; /* IEEE 32-bit binary value 0x9F800000 */
|
||||
}
|
||||
}
|
||||
t[0] = t[1] = t[2] = t[3] = u;
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_SUB: /* GL_NV_vertex_program1_1 */
|
||||
{
|
||||
GLfloat t[4], u[4], sum[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
sum[0] = t[0] - u[0];
|
||||
sum[1] = t[1] - u[1];
|
||||
sum[2] = t[2] - u[2];
|
||||
sum[3] = t[3] - u[3];
|
||||
store_vector4( inst, machine, sum );
|
||||
}
|
||||
break;
|
||||
case OPCODE_ABS: /* GL_NV_vertex_program1_1 */
|
||||
{
|
||||
GLfloat t[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
if (t[0] < 0.0) t[0] = -t[0];
|
||||
if (t[1] < 0.0) t[1] = -t[1];
|
||||
if (t[2] < 0.0) t[2] = -t[2];
|
||||
if (t[3] < 0.0) t[3] = -t[3];
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_FLR: /* GL_ARB_vertex_program */
|
||||
{
|
||||
GLfloat t[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
t[0] = FLOORF(t[0]);
|
||||
t[1] = FLOORF(t[1]);
|
||||
t[2] = FLOORF(t[2]);
|
||||
t[3] = FLOORF(t[3]);
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_FRC: /* GL_ARB_vertex_program */
|
||||
{
|
||||
GLfloat t[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
t[0] = t[0] - FLOORF(t[0]);
|
||||
t[1] = t[1] - FLOORF(t[1]);
|
||||
t[2] = t[2] - FLOORF(t[2]);
|
||||
t[3] = t[3] - FLOORF(t[3]);
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_EX2: /* GL_ARB_vertex_program */
|
||||
{
|
||||
GLfloat t[4];
|
||||
fetch_vector1( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
t[0] = t[1] = t[2] = t[3] = (GLfloat)_mesa_pow(2.0, t[0]);
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_LG2: /* GL_ARB_vertex_program */
|
||||
{
|
||||
GLfloat t[4];
|
||||
fetch_vector1( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
t[0] = t[1] = t[2] = t[3] = LOG2(t[0]);
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_POW: /* GL_ARB_vertex_program */
|
||||
{
|
||||
GLfloat t[4], u[4];
|
||||
fetch_vector1( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector1( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
t[0] = t[1] = t[2] = t[3] = (GLfloat)_mesa_pow(t[0], u[0]);
|
||||
store_vector4( inst, machine, t );
|
||||
}
|
||||
break;
|
||||
case OPCODE_XPD: /* GL_ARB_vertex_program */
|
||||
{
|
||||
GLfloat t[4], u[4], cross[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
fetch_vector4( ctx, &inst->SrcReg[1], machine, program, u );
|
||||
cross[0] = t[1] * u[2] - t[2] * u[1];
|
||||
cross[1] = t[2] * u[0] - t[0] * u[2];
|
||||
cross[2] = t[0] * u[1] - t[1] * u[0];
|
||||
store_vector4( inst, machine, cross );
|
||||
}
|
||||
break;
|
||||
case OPCODE_SWZ: /* GL_ARB_vertex_program */
|
||||
{
|
||||
const struct prog_src_register *source = &inst->SrcReg[0];
|
||||
const GLfloat *src = get_register_pointer(ctx, source,
|
||||
machine, program);
|
||||
GLfloat result[4];
|
||||
GLuint i;
|
||||
|
||||
/* do extended swizzling here */
|
||||
for (i = 0; i < 4; i++) {
|
||||
const GLuint swz = GET_SWZ(source->Swizzle, i);
|
||||
if (swz == SWIZZLE_ZERO)
|
||||
result[i] = 0.0;
|
||||
else if (swz == SWIZZLE_ONE)
|
||||
result[i] = 1.0;
|
||||
else {
|
||||
ASSERT(swz >= 0);
|
||||
ASSERT(swz <= 3);
|
||||
result[i] = src[swz];
|
||||
}
|
||||
if (source->NegateBase & (1 << i))
|
||||
result[i] = -result[i];
|
||||
}
|
||||
store_vector4( inst, machine, result );
|
||||
}
|
||||
break;
|
||||
case OPCODE_PRINT:
|
||||
if (inst->SrcReg[0].File) {
|
||||
GLfloat t[4];
|
||||
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, t );
|
||||
_mesa_printf("%s%g, %g, %g, %g\n",
|
||||
(char *) inst->Data, t[0], t[1], t[2], t[3]);
|
||||
}
|
||||
else {
|
||||
_mesa_printf("%s\n", (char *) inst->Data);
|
||||
}
|
||||
break;
|
||||
case OPCODE_END:
|
||||
ctx->_CurrentProgram = 0;
|
||||
return;
|
||||
default:
|
||||
/* bad instruction opcode */
|
||||
_mesa_problem(ctx, "Bad VP Opcode in _mesa_exec_vertex_program");
|
||||
ctx->_CurrentProgram = 0;
|
||||
return;
|
||||
} /* switch */
|
||||
} /* for */
|
||||
|
||||
ctx->_CurrentProgram = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute a vertex state program.
|
||||
* \sa _mesa_ExecuteProgramNV
|
||||
*/
|
||||
void
|
||||
_mesa_exec_vertex_state_program(GLcontext *ctx,
|
||||
struct gl_vertex_program *vprog,
|
||||
const GLfloat *params)
|
||||
{
|
||||
struct vp_machine machine;
|
||||
_mesa_init_vp_per_vertex_registers(ctx, &machine);
|
||||
_mesa_init_vp_per_primitive_registers(ctx);
|
||||
COPY_4V(machine.Inputs[VERT_ATTRIB_POS], params);
|
||||
_mesa_exec_vertex_program(ctx, &machine, vprog);
|
||||
}
|
||||
@@ -39,13 +39,11 @@
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "hash.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "nvprogram.h"
|
||||
#include "nvvertparse.h"
|
||||
#include "program_instruction.h"
|
||||
#include "prog_instruction.h"
|
||||
#include "program.h"
|
||||
|
||||
|
||||
@@ -686,13 +684,13 @@ Parse_SwizzleSrcReg(struct parse_state *parseState, struct prog_src_register *sr
|
||||
if (token[1] == 0) {
|
||||
/* single letter swizzle */
|
||||
if (token[0] == 'x')
|
||||
srcReg->Swizzle = MAKE_SWIZZLE4(0, 0, 0, 0);
|
||||
srcReg->Swizzle = SWIZZLE_XXXX;
|
||||
else if (token[0] == 'y')
|
||||
srcReg->Swizzle = MAKE_SWIZZLE4(1, 1, 1, 1);
|
||||
srcReg->Swizzle = SWIZZLE_YYYY;
|
||||
else if (token[0] == 'z')
|
||||
srcReg->Swizzle = MAKE_SWIZZLE4(2, 2, 2, 2);
|
||||
srcReg->Swizzle = SWIZZLE_ZZZZ;
|
||||
else if (token[0] == 'w')
|
||||
srcReg->Swizzle = MAKE_SWIZZLE4(3, 3, 3, 3);
|
||||
srcReg->Swizzle = SWIZZLE_WWWW;
|
||||
else
|
||||
RETURN_ERROR1("Expected x, y, z, or w");
|
||||
}
|
||||
@@ -1380,8 +1378,7 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
|
||||
_mesa_free(programString);
|
||||
return; /* out of memory */
|
||||
}
|
||||
_mesa_memcpy(newInst, instBuffer,
|
||||
parseState.numInst * sizeof(struct prog_instruction));
|
||||
_mesa_copy_instructions(newInst, instBuffer, parseState.numInst);
|
||||
|
||||
/* install the program */
|
||||
program->Base.Target = target;
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
#include "nvfragparse.h"
|
||||
#include "nvvertparse.h"
|
||||
#include "program.h"
|
||||
#include "prog_debug.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "prog_instruction.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Functions for the experimental GL_MESA_program_debug extension.
|
||||
*/
|
||||
|
||||
|
||||
/* XXX temporary */
|
||||
GLAPI void GLAPIENTRY
|
||||
glProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback,
|
||||
GLvoid *data)
|
||||
{
|
||||
_mesa_ProgramCallbackMESA(target, callback, data);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_ProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback,
|
||||
GLvoid *data)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
switch (target) {
|
||||
case GL_FRAGMENT_PROGRAM_ARB:
|
||||
if (!ctx->Extensions.ARB_fragment_program) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
|
||||
return;
|
||||
}
|
||||
ctx->FragmentProgram.Callback = callback;
|
||||
ctx->FragmentProgram.CallbackData = data;
|
||||
break;
|
||||
case GL_FRAGMENT_PROGRAM_NV:
|
||||
if (!ctx->Extensions.NV_fragment_program) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
|
||||
return;
|
||||
}
|
||||
ctx->FragmentProgram.Callback = callback;
|
||||
ctx->FragmentProgram.CallbackData = data;
|
||||
break;
|
||||
case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
|
||||
if (!ctx->Extensions.ARB_vertex_program &&
|
||||
!ctx->Extensions.NV_vertex_program) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
|
||||
return;
|
||||
}
|
||||
ctx->VertexProgram.Callback = callback;
|
||||
ctx->VertexProgram.CallbackData = data;
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* XXX temporary */
|
||||
GLAPI void GLAPIENTRY
|
||||
glGetProgramRegisterfvMESA(GLenum target,
|
||||
GLsizei len, const GLubyte *registerName,
|
||||
GLfloat *v)
|
||||
{
|
||||
_mesa_GetProgramRegisterfvMESA(target, len, registerName, v);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_GetProgramRegisterfvMESA(GLenum target,
|
||||
GLsizei len, const GLubyte *registerName,
|
||||
GLfloat *v)
|
||||
{
|
||||
char reg[1000];
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
/* We _should_ be inside glBegin/glEnd */
|
||||
#if 0
|
||||
if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramRegisterfvMESA");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* make null-terminated copy of registerName */
|
||||
len = MIN2((unsigned int) len, sizeof(reg) - 1);
|
||||
_mesa_memcpy(reg, registerName, len);
|
||||
reg[len] = 0;
|
||||
|
||||
switch (target) {
|
||||
case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
|
||||
if (!ctx->Extensions.ARB_vertex_program &&
|
||||
!ctx->Extensions.NV_vertex_program) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
"glGetProgramRegisterfvMESA(target)");
|
||||
return;
|
||||
}
|
||||
if (!ctx->VertexProgram._Enabled) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glGetProgramRegisterfvMESA");
|
||||
return;
|
||||
}
|
||||
/* GL_NV_vertex_program */
|
||||
if (reg[0] == 'R') {
|
||||
/* Temp register */
|
||||
GLint i = _mesa_atoi(reg + 1);
|
||||
if (i >= (GLint)ctx->Const.VertexProgram.MaxTemps) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||
"glGetProgramRegisterfvMESA(registerName)");
|
||||
return;
|
||||
}
|
||||
ctx->Driver.GetProgramRegister(ctx, PROGRAM_TEMPORARY, i, v);
|
||||
}
|
||||
else if (reg[0] == 'v' && reg[1] == '[') {
|
||||
/* Vertex Input attribute */
|
||||
GLuint i;
|
||||
for (i = 0; i < ctx->Const.VertexProgram.MaxAttribs; i++) {
|
||||
const char *name = _mesa_nv_vertex_input_register_name(i);
|
||||
char number[10];
|
||||
_mesa_sprintf(number, "%d", i);
|
||||
if (_mesa_strncmp(reg + 2, name, 4) == 0 ||
|
||||
_mesa_strncmp(reg + 2, number, _mesa_strlen(number)) == 0) {
|
||||
ctx->Driver.GetProgramRegister(ctx, PROGRAM_INPUT, i, v);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||
"glGetProgramRegisterfvMESA(registerName)");
|
||||
return;
|
||||
}
|
||||
else if (reg[0] == 'o' && reg[1] == '[') {
|
||||
/* Vertex output attribute */
|
||||
}
|
||||
/* GL_ARB_vertex_program */
|
||||
else if (_mesa_strncmp(reg, "vertex.", 7) == 0) {
|
||||
|
||||
}
|
||||
else {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||
"glGetProgramRegisterfvMESA(registerName)");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case GL_FRAGMENT_PROGRAM_ARB:
|
||||
if (!ctx->Extensions.ARB_fragment_program) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
"glGetProgramRegisterfvMESA(target)");
|
||||
return;
|
||||
}
|
||||
if (!ctx->FragmentProgram._Enabled) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glGetProgramRegisterfvMESA");
|
||||
return;
|
||||
}
|
||||
/* XXX to do */
|
||||
break;
|
||||
case GL_FRAGMENT_PROGRAM_NV:
|
||||
if (!ctx->Extensions.NV_fragment_program) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
"glGetProgramRegisterfvMESA(target)");
|
||||
return;
|
||||
}
|
||||
if (!ctx->FragmentProgram._Enabled) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glGetProgramRegisterfvMESA");
|
||||
return;
|
||||
}
|
||||
if (reg[0] == 'R') {
|
||||
/* Temp register */
|
||||
GLint i = _mesa_atoi(reg + 1);
|
||||
if (i >= (GLint)ctx->Const.FragmentProgram.MaxTemps) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||
"glGetProgramRegisterfvMESA(registerName)");
|
||||
return;
|
||||
}
|
||||
ctx->Driver.GetProgramRegister(ctx, PROGRAM_TEMPORARY,
|
||||
i, v);
|
||||
}
|
||||
else if (reg[0] == 'f' && reg[1] == '[') {
|
||||
/* Fragment input attribute */
|
||||
GLuint i;
|
||||
for (i = 0; i < ctx->Const.FragmentProgram.MaxAttribs; i++) {
|
||||
const char *name = _mesa_nv_fragment_input_register_name(i);
|
||||
if (_mesa_strncmp(reg + 2, name, 4) == 0) {
|
||||
ctx->Driver.GetProgramRegister(ctx, PROGRAM_INPUT, i, v);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||
"glGetProgramRegisterfvMESA(registerName)");
|
||||
return;
|
||||
}
|
||||
else if (_mesa_strcmp(reg, "o[COLR]") == 0) {
|
||||
/* Fragment output color */
|
||||
ctx->Driver.GetProgramRegister(ctx, PROGRAM_OUTPUT,
|
||||
FRAG_RESULT_COLR, v);
|
||||
}
|
||||
else if (_mesa_strcmp(reg, "o[COLH]") == 0) {
|
||||
/* Fragment output color */
|
||||
ctx->Driver.GetProgramRegister(ctx, PROGRAM_OUTPUT,
|
||||
FRAG_RESULT_COLH, v);
|
||||
}
|
||||
else if (_mesa_strcmp(reg, "o[DEPR]") == 0) {
|
||||
/* Fragment output depth */
|
||||
ctx->Driver.GetProgramRegister(ctx, PROGRAM_OUTPUT,
|
||||
FRAG_RESULT_DEPR, v);
|
||||
}
|
||||
else {
|
||||
/* try user-defined identifiers */
|
||||
const GLfloat *value = _mesa_lookup_parameter_value(
|
||||
ctx->FragmentProgram.Current->Base.Parameters, -1, reg);
|
||||
if (value) {
|
||||
COPY_4V(v, value);
|
||||
}
|
||||
else {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||
"glGetProgramRegisterfvMESA(registerName)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
"glGetProgramRegisterfvMESA(target)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
+19
-11
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.3
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 2005 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -22,15 +22,23 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#if defined __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int _mesa_isalnum (char);
|
||||
int _glslang_3dlabs_InitProcess ();
|
||||
int _glslang_3dlabs_ShInitialize ();
|
||||
#ifndef PROG_DEBUG_H
|
||||
#define PROG_DEBUG_H 1
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GL_MESA_program_debug
|
||||
*/
|
||||
|
||||
extern void
|
||||
_mesa_ProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback,
|
||||
GLvoid *data);
|
||||
|
||||
extern void
|
||||
_mesa_GetProgramRegisterfvMESA(GLenum target, GLsizei len,
|
||||
const GLubyte *registerName, GLfloat *v);
|
||||
|
||||
|
||||
|
||||
#endif /* PROG_DEBUG_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PROG_EXECUTE_H
|
||||
#define PROG_EXECUTE_H
|
||||
|
||||
|
||||
typedef void (*FetchTexelLodFunc)(GLcontext *ctx, const GLfloat texcoord[4],
|
||||
GLfloat lambda, GLuint unit, GLfloat color[4]);
|
||||
|
||||
typedef void (*FetchTexelDerivFunc)(GLcontext *ctx, const GLfloat texcoord[4],
|
||||
const GLfloat texdx[4],
|
||||
const GLfloat texdy[4],
|
||||
GLuint unit, GLfloat color[4]);
|
||||
|
||||
|
||||
/** The larger of VERT_RESULT_MAX, FRAG_RESULT_MAX */
|
||||
#define MAX_PROGRAM_OUTPUTS VERT_RESULT_MAX
|
||||
|
||||
|
||||
/**
|
||||
* Virtual machine state used during execution of vertex/fragment programs.
|
||||
*/
|
||||
struct gl_program_machine
|
||||
{
|
||||
const struct gl_program *CurProgram;
|
||||
|
||||
/** Fragment Input attributes */
|
||||
GLfloat (*Attribs)[MAX_WIDTH][4];
|
||||
GLuint CurElement; /**< Index into Attribs arrays */
|
||||
|
||||
/** Vertex Input attribs */
|
||||
GLfloat VertAttribs[VERT_ATTRIB_MAX][4];
|
||||
|
||||
GLfloat Temporaries[MAX_PROGRAM_TEMPS][4];
|
||||
GLfloat Outputs[MAX_PROGRAM_OUTPUTS][4];
|
||||
GLfloat (*EnvParams)[4]; /**< Vertex or Fragment env parameters */
|
||||
GLuint CondCodes[4]; /**< COND_* value for x/y/z/w */
|
||||
GLint AddressReg[MAX_PROGRAM_ADDRESS_REGS][4];
|
||||
|
||||
GLuint CallStack[MAX_PROGRAM_CALL_DEPTH]; /**< For CAL/RET instructions */
|
||||
GLuint StackDepth; /**< Index/ptr to top of CallStack[] */
|
||||
|
||||
/** Texture fetch functions */
|
||||
FetchTexelLodFunc FetchTexelLod;
|
||||
FetchTexelDerivFunc FetchTexelDeriv;
|
||||
};
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_get_program_register(GLcontext *ctx, enum register_file file,
|
||||
GLuint index, GLfloat val[4]);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_execute_program(GLcontext *ctx,
|
||||
const struct gl_program *program,
|
||||
struct gl_program_machine *machine);
|
||||
|
||||
|
||||
#endif /* PROG_EXECUTE_H */
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "imports.h"
|
||||
#include "mtypes.h"
|
||||
#include "prog_instruction.h"
|
||||
|
||||
|
||||
/**
|
||||
* Initialize program instruction fields to defaults.
|
||||
* \param inst first instruction to initialize
|
||||
* \param count number of instructions to initialize
|
||||
*/
|
||||
void
|
||||
_mesa_init_instructions(struct prog_instruction *inst, GLuint count)
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
_mesa_bzero(inst, count * sizeof(struct prog_instruction));
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
inst[i].SrcReg[0].File = PROGRAM_UNDEFINED;
|
||||
inst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP;
|
||||
inst[i].SrcReg[1].File = PROGRAM_UNDEFINED;
|
||||
inst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP;
|
||||
inst[i].SrcReg[2].File = PROGRAM_UNDEFINED;
|
||||
inst[i].SrcReg[2].Swizzle = SWIZZLE_NOOP;
|
||||
|
||||
inst[i].DstReg.File = PROGRAM_UNDEFINED;
|
||||
inst[i].DstReg.WriteMask = WRITEMASK_XYZW;
|
||||
inst[i].DstReg.CondMask = COND_TR;
|
||||
inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP;
|
||||
|
||||
inst[i].SaturateMode = SATURATE_OFF;
|
||||
inst[i].Precision = FLOAT32;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allocate an array of program instructions.
|
||||
* \param numInst number of instructions
|
||||
* \return pointer to instruction memory
|
||||
*/
|
||||
struct prog_instruction *
|
||||
_mesa_alloc_instructions(GLuint numInst)
|
||||
{
|
||||
return (struct prog_instruction *)
|
||||
_mesa_calloc(numInst * sizeof(struct prog_instruction));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reallocate memory storing an array of program instructions.
|
||||
* This is used when we need to append additional instructions onto an
|
||||
* program.
|
||||
* \param oldInst pointer to first of old/src instructions
|
||||
* \param numOldInst number of instructions at <oldInst>
|
||||
* \param numNewInst desired size of new instruction array.
|
||||
* \return pointer to start of new instruction array.
|
||||
*/
|
||||
struct prog_instruction *
|
||||
_mesa_realloc_instructions(struct prog_instruction *oldInst,
|
||||
GLuint numOldInst, GLuint numNewInst)
|
||||
{
|
||||
struct prog_instruction *newInst;
|
||||
|
||||
newInst = (struct prog_instruction *)
|
||||
_mesa_realloc(oldInst,
|
||||
numOldInst * sizeof(struct prog_instruction),
|
||||
numNewInst * sizeof(struct prog_instruction));
|
||||
|
||||
return newInst;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy an array of program instructions.
|
||||
* \param dest pointer to destination.
|
||||
* \param src pointer to source.
|
||||
* \param n number of instructions to copy.
|
||||
* \return pointer to destination.
|
||||
*/
|
||||
struct prog_instruction *
|
||||
_mesa_copy_instructions(struct prog_instruction *dest,
|
||||
const struct prog_instruction *src, GLuint n)
|
||||
{
|
||||
GLuint i;
|
||||
_mesa_memcpy(dest, src, n * sizeof(struct prog_instruction));
|
||||
for (i = 0; i < n; i++) {
|
||||
if (src[i].Comment)
|
||||
dest[i].Comment = _mesa_strdup(src[i].Comment);
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Basic info about each instruction
|
||||
*/
|
||||
struct instruction_info
|
||||
{
|
||||
gl_inst_opcode Opcode;
|
||||
const char *Name;
|
||||
GLuint NumSrcRegs;
|
||||
};
|
||||
|
||||
/**
|
||||
* Instruction info
|
||||
* \note Opcode should equal array index!
|
||||
*/
|
||||
static const struct instruction_info InstInfo[MAX_OPCODE] = {
|
||||
{ OPCODE_NOP, "NOP", 0 },
|
||||
{ OPCODE_ABS, "ABS", 1 },
|
||||
{ OPCODE_ADD, "ADD", 2 },
|
||||
{ OPCODE_ARA, "ARA", 1 },
|
||||
{ OPCODE_ARL, "ARL", 1 },
|
||||
{ OPCODE_ARL_NV, "ARL", 1 },
|
||||
{ OPCODE_ARR, "ARL", 1 },
|
||||
{ OPCODE_BGNLOOP,"BGNLOOP", 0 },
|
||||
{ OPCODE_BGNSUB, "BGNSUB", 0 },
|
||||
{ OPCODE_BRA, "BRA", 0 },
|
||||
{ OPCODE_BRK, "BRK", 0 },
|
||||
{ OPCODE_CAL, "CAL", 0 },
|
||||
{ OPCODE_CMP, "CMP", 3 },
|
||||
{ OPCODE_CONT, "CONT", 0 },
|
||||
{ OPCODE_COS, "COS", 1 },
|
||||
{ OPCODE_DDX, "DDX", 1 },
|
||||
{ OPCODE_DDY, "DDY", 1 },
|
||||
{ OPCODE_DP3, "DP3", 2 },
|
||||
{ OPCODE_DP4, "DP4", 2 },
|
||||
{ OPCODE_DPH, "DPH", 2 },
|
||||
{ OPCODE_DST, "DST", 2 },
|
||||
{ OPCODE_ELSE, "ELSE", 0 },
|
||||
{ OPCODE_END, "END", 0 },
|
||||
{ OPCODE_ENDIF, "ENDIF", 0 },
|
||||
{ OPCODE_ENDLOOP,"ENDLOOP", 0 },
|
||||
{ OPCODE_ENDSUB, "ENDSUB", 0 },
|
||||
{ OPCODE_EX2, "EX2", 1 },
|
||||
{ OPCODE_EXP, "EXP", 1 },
|
||||
{ OPCODE_FLR, "FLR", 1 },
|
||||
{ OPCODE_FRC, "FRC", 1 },
|
||||
{ OPCODE_IF, "IF", 0 },
|
||||
{ OPCODE_INT, "INT", 1 },
|
||||
{ OPCODE_KIL, "KIL", 1 },
|
||||
{ OPCODE_KIL_NV, "KIL", 0 },
|
||||
{ OPCODE_LG2, "LG2", 1 },
|
||||
{ OPCODE_LIT, "LIT", 1 },
|
||||
{ OPCODE_LOG, "LOG", 1 },
|
||||
{ OPCODE_LRP, "LRP", 3 },
|
||||
{ OPCODE_MAD, "MAD", 3 },
|
||||
{ OPCODE_MAX, "MAX", 2 },
|
||||
{ OPCODE_MIN, "MIN", 2 },
|
||||
{ OPCODE_MOV, "MOV", 1 },
|
||||
{ OPCODE_MUL, "MUL", 2 },
|
||||
{ OPCODE_NOISE1, "NOISE1", 1 },
|
||||
{ OPCODE_NOISE2, "NOISE2", 1 },
|
||||
{ OPCODE_NOISE3, "NOISE3", 1 },
|
||||
{ OPCODE_NOISE4, "NOISE4", 1 },
|
||||
{ OPCODE_PK2H, "PK2H", 1 },
|
||||
{ OPCODE_PK2US, "PK2US", 1 },
|
||||
{ OPCODE_PK4B, "PK4B", 1 },
|
||||
{ OPCODE_PK4UB, "PK4UB", 1 },
|
||||
{ OPCODE_POW, "POW", 2 },
|
||||
{ OPCODE_POPA, "POPA", 0 },
|
||||
{ OPCODE_PRINT, "PRINT", 1 },
|
||||
{ OPCODE_PUSHA, "PUSHA", 0 },
|
||||
{ OPCODE_RCC, "RCC", 1 },
|
||||
{ OPCODE_RCP, "RCP", 1 },
|
||||
{ OPCODE_RET, "RET", 0 },
|
||||
{ OPCODE_RFL, "RFL", 1 },
|
||||
{ OPCODE_RSQ, "RSQ", 1 },
|
||||
{ OPCODE_SCS, "SCS", 1 },
|
||||
{ OPCODE_SEQ, "SEQ", 2 },
|
||||
{ OPCODE_SFL, "SFL", 0 },
|
||||
{ OPCODE_SGE, "SGE", 2 },
|
||||
{ OPCODE_SGT, "SGT", 2 },
|
||||
{ OPCODE_SIN, "SIN", 1 },
|
||||
{ OPCODE_SLE, "SLE", 2 },
|
||||
{ OPCODE_SLT, "SLT", 2 },
|
||||
{ OPCODE_SNE, "SNE", 2 },
|
||||
{ OPCODE_SSG, "SSG", 1 },
|
||||
{ OPCODE_STR, "STR", 0 },
|
||||
{ OPCODE_SUB, "SUB", 2 },
|
||||
{ OPCODE_SWZ, "SWZ", 1 },
|
||||
{ OPCODE_TEX, "TEX", 1 },
|
||||
{ OPCODE_TXB, "TXB", 1 },
|
||||
{ OPCODE_TXD, "TXD", 3 },
|
||||
{ OPCODE_TXL, "TXL", 1 },
|
||||
{ OPCODE_TXP, "TXP", 1 },
|
||||
{ OPCODE_TXP_NV, "TXP", 1 },
|
||||
{ OPCODE_UP2H, "UP2H", 1 },
|
||||
{ OPCODE_UP2US, "UP2US", 1 },
|
||||
{ OPCODE_UP4B, "UP4B", 1 },
|
||||
{ OPCODE_UP4UB, "UP4UB", 1 },
|
||||
{ OPCODE_X2D, "X2D", 3 },
|
||||
{ OPCODE_XPD, "XPD", 2 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of src registers for the given instruction/opcode.
|
||||
*/
|
||||
GLuint
|
||||
_mesa_num_inst_src_regs(gl_inst_opcode opcode)
|
||||
{
|
||||
ASSERT(opcode == InstInfo[opcode].Opcode);
|
||||
ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode);
|
||||
return InstInfo[opcode].NumSrcRegs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return string name for given program opcode.
|
||||
*/
|
||||
const char *
|
||||
_mesa_opcode_string(gl_inst_opcode opcode)
|
||||
{
|
||||
ASSERT(opcode < MAX_OPCODE);
|
||||
return InstInfo[opcode].Name;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,447 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file prog_instruction.h
|
||||
*
|
||||
* Vertex/fragment program instruction datatypes and constants.
|
||||
*
|
||||
* \author Brian Paul
|
||||
* \author Keith Whitwell
|
||||
* \author Ian Romanick <idr@us.ibm.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PROG_INSTRUCTION_H
|
||||
#define PROG_INSTRUCTION_H
|
||||
|
||||
|
||||
/**
|
||||
* Swizzle indexes.
|
||||
* Do not change!
|
||||
*/
|
||||
/*@{*/
|
||||
#define SWIZZLE_X 0
|
||||
#define SWIZZLE_Y 1
|
||||
#define SWIZZLE_Z 2
|
||||
#define SWIZZLE_W 3
|
||||
#define SWIZZLE_ZERO 4 /**< For SWZ instruction only */
|
||||
#define SWIZZLE_ONE 5 /**< For SWZ instruction only */
|
||||
#define SWIZZLE_NIL 7 /**< used during shader code gen (undefined value) */
|
||||
/*@}*/
|
||||
|
||||
#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9))
|
||||
#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3)
|
||||
#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7)
|
||||
#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1)
|
||||
|
||||
#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W)
|
||||
#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X)
|
||||
#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y)
|
||||
#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z)
|
||||
#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W)
|
||||
|
||||
|
||||
/**
|
||||
* Writemask values, 1 bit per component.
|
||||
*/
|
||||
/*@{*/
|
||||
#define WRITEMASK_X 0x1
|
||||
#define WRITEMASK_Y 0x2
|
||||
#define WRITEMASK_XY 0x3
|
||||
#define WRITEMASK_Z 0x4
|
||||
#define WRITEMASK_XZ 0x5
|
||||
#define WRITEMASK_YZ 0x6
|
||||
#define WRITEMASK_XYZ 0x7
|
||||
#define WRITEMASK_W 0x8
|
||||
#define WRITEMASK_XW 0x9
|
||||
#define WRITEMASK_YW 0xa
|
||||
#define WRITEMASK_XYW 0xb
|
||||
#define WRITEMASK_ZW 0xc
|
||||
#define WRITEMASK_XZW 0xd
|
||||
#define WRITEMASK_YZW 0xe
|
||||
#define WRITEMASK_XYZW 0xf
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Condition codes
|
||||
*/
|
||||
/*@{*/
|
||||
#define COND_GT 1 /**< greater than zero */
|
||||
#define COND_EQ 2 /**< equal to zero */
|
||||
#define COND_LT 3 /**< less than zero */
|
||||
#define COND_UN 4 /**< unordered (NaN) */
|
||||
#define COND_GE 5 /**< greater then or equal to zero */
|
||||
#define COND_LE 6 /**< less then or equal to zero */
|
||||
#define COND_NE 7 /**< not equal to zero */
|
||||
#define COND_TR 8 /**< always true */
|
||||
#define COND_FL 9 /**< always false */
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Instruction precision for GL_NV_fragment_program
|
||||
*/
|
||||
/*@{*/
|
||||
#define FLOAT32 0x1
|
||||
#define FLOAT16 0x2
|
||||
#define FIXED12 0x4
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Saturation modes when storing values.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SATURATE_OFF 0
|
||||
#define SATURATE_ZERO_ONE 1
|
||||
#define SATURATE_PLUS_MINUS_ONE 2
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Per-component negation masks
|
||||
*/
|
||||
/*@{*/
|
||||
#define NEGATE_X 0x1
|
||||
#define NEGATE_Y 0x2
|
||||
#define NEGATE_Z 0x4
|
||||
#define NEGATE_W 0x8
|
||||
#define NEGATE_XYZW 0xf
|
||||
#define NEGATE_NONE 0x0
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Program instruction opcodes, for both vertex and fragment programs.
|
||||
* \note changes to this opcode list must be reflected in t_vb_arbprogram.c
|
||||
*/
|
||||
typedef enum prog_opcode {
|
||||
/* ARB_vp ARB_fp NV_vp NV_fp GLSL */
|
||||
/*------------------------------------------*/
|
||||
OPCODE_NOP = 0, /* X */
|
||||
OPCODE_ABS, /* X X 1.1 X */
|
||||
OPCODE_ADD, /* X X X X X */
|
||||
OPCODE_ARA, /* 2 */
|
||||
OPCODE_ARL, /* X X */
|
||||
OPCODE_ARL_NV, /* 2 */
|
||||
OPCODE_ARR, /* 2 */
|
||||
OPCODE_BGNLOOP, /* opt */
|
||||
OPCODE_BGNSUB, /* opt */
|
||||
OPCODE_BRA, /* 2 X */
|
||||
OPCODE_BRK, /* 2 opt */
|
||||
OPCODE_CAL, /* 2 2 */
|
||||
OPCODE_CMP, /* X */
|
||||
OPCODE_CONT, /* opt */
|
||||
OPCODE_COS, /* X 2 X X */
|
||||
OPCODE_DDX, /* X X */
|
||||
OPCODE_DDY, /* X X */
|
||||
OPCODE_DP3, /* X X X X X */
|
||||
OPCODE_DP4, /* X X X X X */
|
||||
OPCODE_DPH, /* X X 1.1 */
|
||||
OPCODE_DST, /* X X X X */
|
||||
OPCODE_ELSE, /* X */
|
||||
OPCODE_END, /* X X X X opt */
|
||||
OPCODE_ENDIF, /* opt */
|
||||
OPCODE_ENDLOOP, /* opt */
|
||||
OPCODE_ENDSUB, /* opt */
|
||||
OPCODE_EX2, /* X X 2 X X */
|
||||
OPCODE_EXP, /* X X X */
|
||||
OPCODE_FLR, /* X X 2 X X */
|
||||
OPCODE_FRC, /* X X 2 X X */
|
||||
OPCODE_IF, /* opt */
|
||||
OPCODE_INT, /* X */
|
||||
OPCODE_KIL, /* X */
|
||||
OPCODE_KIL_NV, /* X X */
|
||||
OPCODE_LG2, /* X X 2 X X */
|
||||
OPCODE_LIT, /* X X X X */
|
||||
OPCODE_LOG, /* X X X */
|
||||
OPCODE_LRP, /* X X */
|
||||
OPCODE_MAD, /* X X X X X */
|
||||
OPCODE_MAX, /* X X X X X */
|
||||
OPCODE_MIN, /* X X X X X */
|
||||
OPCODE_MOV, /* X X X X X */
|
||||
OPCODE_MUL, /* X X X X X */
|
||||
OPCODE_NOISE1, /* X */
|
||||
OPCODE_NOISE2, /* X */
|
||||
OPCODE_NOISE3, /* X */
|
||||
OPCODE_NOISE4, /* X */
|
||||
OPCODE_PK2H, /* X */
|
||||
OPCODE_PK2US, /* X */
|
||||
OPCODE_PK4B, /* X */
|
||||
OPCODE_PK4UB, /* X */
|
||||
OPCODE_POW, /* X X X X */
|
||||
OPCODE_POPA, /* 3 */
|
||||
OPCODE_PRINT, /* X X */
|
||||
OPCODE_PUSHA, /* 3 */
|
||||
OPCODE_RCC, /* 1.1 */
|
||||
OPCODE_RCP, /* X X X X X */
|
||||
OPCODE_RET, /* 2 2 */
|
||||
OPCODE_RFL, /* X X */
|
||||
OPCODE_RSQ, /* X X X X X */
|
||||
OPCODE_SCS, /* X */
|
||||
OPCODE_SEQ, /* 2 X X */
|
||||
OPCODE_SFL, /* 2 X */
|
||||
OPCODE_SGE, /* X X X X X */
|
||||
OPCODE_SGT, /* 2 X X */
|
||||
OPCODE_SIN, /* X 2 X X */
|
||||
OPCODE_SLE, /* 2 X X */
|
||||
OPCODE_SLT, /* X X X X X */
|
||||
OPCODE_SNE, /* 2 X X */
|
||||
OPCODE_SSG, /* 2 */
|
||||
OPCODE_STR, /* 2 X */
|
||||
OPCODE_SUB, /* X X 1.1 X X */
|
||||
OPCODE_SWZ, /* X X */
|
||||
OPCODE_TEX, /* X 3 X X */
|
||||
OPCODE_TXB, /* X 3 X */
|
||||
OPCODE_TXD, /* X X */
|
||||
OPCODE_TXL, /* 3 2 X */
|
||||
OPCODE_TXP, /* X X */
|
||||
OPCODE_TXP_NV, /* 3 X */
|
||||
OPCODE_UP2H, /* X */
|
||||
OPCODE_UP2US, /* X */
|
||||
OPCODE_UP4B, /* X */
|
||||
OPCODE_UP4UB, /* X */
|
||||
OPCODE_X2D, /* X */
|
||||
OPCODE_XPD, /* X X X */
|
||||
MAX_OPCODE
|
||||
} gl_inst_opcode;
|
||||
|
||||
|
||||
/**
|
||||
* Instruction source register.
|
||||
*/
|
||||
struct prog_src_register
|
||||
{
|
||||
GLuint File:4; /**< One of the PROGRAM_* register file values. */
|
||||
GLint Index:9; /**< May be negative for relative addressing. */
|
||||
GLuint Swizzle:12;
|
||||
GLuint RelAddr:1;
|
||||
|
||||
/**
|
||||
* \name Source register "sign" control.
|
||||
*
|
||||
* The ARB and NV extensions allow varrying degrees of control over the
|
||||
* sign of the source vector components. These values allow enough control
|
||||
* for all flavors of the extensions.
|
||||
*/
|
||||
/*@{*/
|
||||
/**
|
||||
* Per-component negation for the SWZ instruction. For non-SWZ
|
||||
* instructions the only possible values are NEGATE_XYZW and NEGATE_NONE.
|
||||
*
|
||||
* \since
|
||||
* ARB_vertex_program, ARB_fragment_program
|
||||
*/
|
||||
GLuint NegateBase:4;
|
||||
|
||||
/**
|
||||
* Take the component-wise absolute value.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
|
||||
* NV_vertex_program2_option.
|
||||
*/
|
||||
GLuint Abs:1;
|
||||
|
||||
/**
|
||||
* Post-absolute value negation (all components).
|
||||
*/
|
||||
GLuint NegateAbs:1;
|
||||
/*@}*/
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Instruction destination register.
|
||||
*/
|
||||
struct prog_dst_register
|
||||
{
|
||||
/**
|
||||
* One of the PROGRAM_* register file values.
|
||||
*/
|
||||
GLuint File:4;
|
||||
|
||||
GLuint Index:8;
|
||||
GLuint WriteMask:4;
|
||||
|
||||
/**
|
||||
* \name Conditional destination update control.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
|
||||
* NV_vertex_program2_option.
|
||||
*/
|
||||
/*@{*/
|
||||
/**
|
||||
* Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT,
|
||||
* NE, TR, or UN). Dest reg is only written to if the matching
|
||||
* (swizzled) condition code value passes. When a conditional update mask
|
||||
* is not specified, this will be \c COND_TR.
|
||||
*/
|
||||
GLuint CondMask:4;
|
||||
|
||||
/**
|
||||
* Condition code swizzle value.
|
||||
*/
|
||||
GLuint CondSwizzle:12;
|
||||
|
||||
/**
|
||||
* Selects the condition code register to use for conditional destination
|
||||
* update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only
|
||||
* condition code register 0 is available. In NV_vertex_program3 mode,
|
||||
* condition code registers 0 and 1 are available.
|
||||
*/
|
||||
GLuint CondSrc:1;
|
||||
/*@}*/
|
||||
|
||||
GLuint pad:31;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Vertex/fragment program instruction.
|
||||
*/
|
||||
struct prog_instruction
|
||||
{
|
||||
gl_inst_opcode Opcode;
|
||||
#if FEATURE_MESA_program_debug
|
||||
GLshort StringPos;
|
||||
#endif
|
||||
/**
|
||||
* Arbitrary data. Used for the PRINT, CAL, and BRA instructions.
|
||||
*/
|
||||
void *Data;
|
||||
|
||||
struct prog_src_register SrcReg[3];
|
||||
struct prog_dst_register DstReg;
|
||||
|
||||
/**
|
||||
* Indicates that the instruction should update the condition code
|
||||
* register.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
|
||||
* NV_vertex_program2_option.
|
||||
*/
|
||||
GLuint CondUpdate:1;
|
||||
|
||||
/**
|
||||
* If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the
|
||||
* condition code register that is to be updated.
|
||||
*
|
||||
* In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition
|
||||
* code register 0 is available. In GL_NV_vertex_program3 mode, condition
|
||||
* code registers 0 and 1 are available.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
|
||||
* NV_vertex_program2_option.
|
||||
*/
|
||||
GLuint CondDst:1;
|
||||
|
||||
/**
|
||||
* Saturate each value of the vectored result to the range [0,1] or the
|
||||
* range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is
|
||||
* only available in NV_fragment_program2 mode.
|
||||
* Value is one of the SATURATE_* tokens.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program3.
|
||||
*/
|
||||
GLuint SaturateMode:2;
|
||||
|
||||
/**
|
||||
* Per-instruction selectable precision.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option.
|
||||
*/
|
||||
GLuint Precision:3;
|
||||
|
||||
/**
|
||||
* \name Texture source controls.
|
||||
*
|
||||
* The texture source controls are only used with the \c TEX, \c TXD,
|
||||
* \c TXL, and \c TXP instructions.
|
||||
*
|
||||
* \since
|
||||
* ARB_fragment_program, NV_fragment_program, NV_vertex_program3.
|
||||
*/
|
||||
/*@{*/
|
||||
/**
|
||||
* Source texture unit. OpenGL supports a maximum of 32 texture
|
||||
* units.
|
||||
*/
|
||||
GLuint TexSrcUnit:5;
|
||||
|
||||
/**
|
||||
* Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX.
|
||||
*/
|
||||
GLuint TexSrcTarget:3;
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* For BRA and CAL instructions, the location to jump to.
|
||||
* For BGNLOOP, points to ENDLOOP (and vice-versa).
|
||||
* For BRK, points to BGNLOOP (which points to ENDLOOP).
|
||||
* For IF, points to else or endif.
|
||||
* For ELSE, points to endif.
|
||||
*/
|
||||
GLint BranchTarget;
|
||||
|
||||
/**
|
||||
* For TEX instructions in shaders, the sampler to use for the
|
||||
* texture lookup.
|
||||
*/
|
||||
GLint Sampler;
|
||||
|
||||
const char *Comment;
|
||||
};
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_init_instructions(struct prog_instruction *inst, GLuint count);
|
||||
|
||||
extern struct prog_instruction *
|
||||
_mesa_alloc_instructions(GLuint numInst);
|
||||
|
||||
extern struct prog_instruction *
|
||||
_mesa_realloc_instructions(struct prog_instruction *oldInst,
|
||||
GLuint numOldInst, GLuint numNewInst);
|
||||
|
||||
extern struct prog_instruction *
|
||||
_mesa_copy_instructions(struct prog_instruction *dest,
|
||||
const struct prog_instruction *src, GLuint n);
|
||||
|
||||
extern GLuint
|
||||
_mesa_num_inst_src_regs(gl_inst_opcode opcode);
|
||||
|
||||
extern const char *
|
||||
_mesa_opcode_string(gl_inst_opcode opcode);
|
||||
|
||||
|
||||
#endif /* PROG_INSTRUCTION_H */
|
||||
@@ -0,0 +1,643 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file prog_parameter.c
|
||||
* Program parameter lists and functions.
|
||||
* \author Brian Paul
|
||||
*/
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "prog_instruction.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "prog_statevars.h"
|
||||
|
||||
|
||||
struct gl_program_parameter_list *
|
||||
_mesa_new_parameter_list(void)
|
||||
{
|
||||
return (struct gl_program_parameter_list *)
|
||||
_mesa_calloc(sizeof(struct gl_program_parameter_list));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Free a parameter list and all its parameters
|
||||
*/
|
||||
void
|
||||
_mesa_free_parameter_list(struct gl_program_parameter_list *paramList)
|
||||
{
|
||||
GLuint i;
|
||||
for (i = 0; i < paramList->NumParameters; i++) {
|
||||
if (paramList->Parameters[i].Name)
|
||||
_mesa_free((void *) paramList->Parameters[i].Name);
|
||||
}
|
||||
_mesa_free(paramList->Parameters);
|
||||
if (paramList->ParameterValues)
|
||||
_mesa_align_free(paramList->ParameterValues);
|
||||
_mesa_free(paramList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a new parameter to a parameter list.
|
||||
* Note that parameter values are usually 4-element GLfloat vectors.
|
||||
* When size > 4 we'll allocate a sequential block of parameters to
|
||||
* store all the values (in blocks of 4).
|
||||
*
|
||||
* \param paramList the list to add the parameter to
|
||||
* \param type type of parameter, such as
|
||||
* \param name the parameter name, will be duplicated/copied!
|
||||
* \param size number of elements in 'values' vector (1..4, or more)
|
||||
* \param values initial parameter value, up to 4 GLfloats, or NULL
|
||||
* \param state state indexes, or NULL
|
||||
* \return index of new parameter in the list, or -1 if error (out of mem)
|
||||
*/
|
||||
GLint
|
||||
_mesa_add_parameter(struct gl_program_parameter_list *paramList,
|
||||
enum register_file type, const char *name,
|
||||
GLuint size, GLenum datatype, const GLfloat *values,
|
||||
const gl_state_index state[STATE_LENGTH])
|
||||
{
|
||||
const GLuint oldNum = paramList->NumParameters;
|
||||
const GLuint sz4 = (size + 3) / 4; /* no. of new param slots needed */
|
||||
|
||||
assert(size > 0);
|
||||
|
||||
if (oldNum + sz4 > paramList->Size) {
|
||||
/* Need to grow the parameter list array (alloc some extra) */
|
||||
paramList->Size = paramList->Size + 4 * sz4;
|
||||
|
||||
/* realloc arrays */
|
||||
paramList->Parameters = (struct gl_program_parameter *)
|
||||
_mesa_realloc(paramList->Parameters,
|
||||
oldNum * sizeof(struct gl_program_parameter),
|
||||
paramList->Size * sizeof(struct gl_program_parameter));
|
||||
|
||||
paramList->ParameterValues = (GLfloat (*)[4])
|
||||
_mesa_align_realloc(paramList->ParameterValues, /* old buf */
|
||||
oldNum * 4 * sizeof(GLfloat), /* old size */
|
||||
paramList->Size * 4 *sizeof(GLfloat), /* new sz */
|
||||
16);
|
||||
}
|
||||
|
||||
if (!paramList->Parameters ||
|
||||
!paramList->ParameterValues) {
|
||||
/* out of memory */
|
||||
paramList->NumParameters = 0;
|
||||
paramList->Size = 0;
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
GLuint i;
|
||||
|
||||
paramList->NumParameters = oldNum + sz4;
|
||||
|
||||
_mesa_memset(¶mList->Parameters[oldNum], 0,
|
||||
sz4 * sizeof(struct gl_program_parameter));
|
||||
|
||||
for (i = 0; i < sz4; i++) {
|
||||
struct gl_program_parameter *p = paramList->Parameters + oldNum + i;
|
||||
p->Name = name ? _mesa_strdup(name) : NULL;
|
||||
p->Type = type;
|
||||
p->Size = size;
|
||||
p->DataType = datatype;
|
||||
if (values) {
|
||||
COPY_4V(paramList->ParameterValues[oldNum + i], values);
|
||||
values += 4;
|
||||
}
|
||||
else {
|
||||
/* silence valgrind */
|
||||
ASSIGN_4V(paramList->ParameterValues[oldNum + i], 0, 0, 0, 0);
|
||||
}
|
||||
size -= 4;
|
||||
}
|
||||
|
||||
if (state) {
|
||||
for (i = 0; i < STATE_LENGTH; i++)
|
||||
paramList->Parameters[oldNum].StateIndexes[i] = state[i];
|
||||
}
|
||||
|
||||
return (GLint) oldNum;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new named program parameter (Ex: NV_fragment_program DEFINE statement)
|
||||
* \return index of the new entry in the parameter list
|
||||
*/
|
||||
GLint
|
||||
_mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
|
||||
const char *name, const GLfloat values[4])
|
||||
{
|
||||
return _mesa_add_parameter(paramList, PROGRAM_NAMED_PARAM, name,
|
||||
4, GL_NONE, values, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new named constant to the parameter list.
|
||||
* This will be used when the program contains something like this:
|
||||
* PARAM myVals = { 0, 1, 2, 3 };
|
||||
*
|
||||
* \param paramList the parameter list
|
||||
* \param name the name for the constant
|
||||
* \param values four float values
|
||||
* \return index/position of the new parameter in the parameter list
|
||||
*/
|
||||
GLint
|
||||
_mesa_add_named_constant(struct gl_program_parameter_list *paramList,
|
||||
const char *name, const GLfloat values[4],
|
||||
GLuint size)
|
||||
{
|
||||
#if 0 /* disable this for now -- we need to save the name! */
|
||||
GLint pos;
|
||||
GLuint swizzle;
|
||||
ASSERT(size == 4); /* XXX future feature */
|
||||
/* check if we already have this constant */
|
||||
if (_mesa_lookup_parameter_constant(paramList, values, 4, &pos, &swizzle)) {
|
||||
return pos;
|
||||
}
|
||||
#endif
|
||||
size = 4; /** XXX fix */
|
||||
return _mesa_add_parameter(paramList, PROGRAM_CONSTANT, name,
|
||||
size, GL_NONE, values, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new unnamed constant to the parameter list. This will be used
|
||||
* when a fragment/vertex program contains something like this:
|
||||
* MOV r, { 0, 1, 2, 3 };
|
||||
* We'll search the parameter list for an existing instance of the
|
||||
* constant. If swizzleOut is non-null, we'll try swizzling when
|
||||
* looking for a match.
|
||||
*
|
||||
* \param paramList the parameter list
|
||||
* \param values four float values
|
||||
* \param swizzleOut returns swizzle mask for accessing the constant
|
||||
* \return index/position of the new parameter in the parameter list.
|
||||
*/
|
||||
GLint
|
||||
_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
|
||||
const GLfloat values[4], GLuint size,
|
||||
GLuint *swizzleOut)
|
||||
{
|
||||
GLint pos;
|
||||
ASSERT(size >= 1);
|
||||
ASSERT(size <= 4);
|
||||
|
||||
if (_mesa_lookup_parameter_constant(paramList, values,
|
||||
size, &pos, swizzleOut)) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
/* Look for empty space in an already unnamed constant parameter
|
||||
* to add this constant. This will only work for single-element
|
||||
* constants because we rely on smearing (i.e. .yyyy or .zzzz).
|
||||
*/
|
||||
if (size == 1 && swizzleOut) {
|
||||
for (pos = 0; pos < (GLint) paramList->NumParameters; pos++) {
|
||||
struct gl_program_parameter *p = paramList->Parameters + pos;
|
||||
if (p->Type == PROGRAM_CONSTANT && p->Size + size <= 4) {
|
||||
/* ok, found room */
|
||||
GLfloat *pVal = paramList->ParameterValues[pos];
|
||||
GLuint swz = p->Size; /* 1, 2 or 3 for Y, Z, W */
|
||||
pVal[p->Size] = values[0];
|
||||
p->Size++;
|
||||
*swizzleOut = MAKE_SWIZZLE4(swz, swz, swz, swz);
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* add a new parameter to store this constant */
|
||||
pos = _mesa_add_parameter(paramList, PROGRAM_CONSTANT, NULL,
|
||||
size, GL_NONE, values, NULL);
|
||||
if (pos >= 0 && swizzleOut) {
|
||||
if (size == 1)
|
||||
*swizzleOut = SWIZZLE_XXXX;
|
||||
else
|
||||
*swizzleOut = SWIZZLE_NOOP;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a uniform to the parameter list.
|
||||
* Note that if the uniform is an array, size may be greater than
|
||||
* what's implied by the datatype.
|
||||
* \param name uniform's name
|
||||
* \param size number of floats to allocate
|
||||
* \param datatype GL_FLOAT_VEC3, GL_FLOAT_MAT4, etc.
|
||||
*/
|
||||
GLint
|
||||
_mesa_add_uniform(struct gl_program_parameter_list *paramList,
|
||||
const char *name, GLuint size, GLenum datatype)
|
||||
{
|
||||
GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
|
||||
ASSERT(datatype != GL_NONE);
|
||||
if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_UNIFORM) {
|
||||
ASSERT(paramList->Parameters[i].Size == size);
|
||||
ASSERT(paramList->Parameters[i].DataType == datatype);
|
||||
/* already in list */
|
||||
return i;
|
||||
}
|
||||
else {
|
||||
i = _mesa_add_parameter(paramList, PROGRAM_UNIFORM, name,
|
||||
size, datatype, NULL, NULL);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a sampler to the parameter list.
|
||||
* \param name uniform's name
|
||||
* \param datatype GL_SAMPLER_2D, GL_SAMPLER_2D_RECT_ARB, etc.
|
||||
*/
|
||||
GLint
|
||||
_mesa_add_sampler(struct gl_program_parameter_list *paramList,
|
||||
const char *name, GLenum datatype)
|
||||
{
|
||||
GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
|
||||
if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_SAMPLER) {
|
||||
ASSERT(paramList->Parameters[i].Size == 1);
|
||||
ASSERT(paramList->Parameters[i].DataType == datatype);
|
||||
/* already in list */
|
||||
return i;
|
||||
}
|
||||
else {
|
||||
const GLint size = 1; /* a sampler is basically a texture unit number */
|
||||
i = _mesa_add_parameter(paramList, PROGRAM_SAMPLER, name,
|
||||
size, datatype, NULL, NULL);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add parameter representing a varying variable.
|
||||
*/
|
||||
GLint
|
||||
_mesa_add_varying(struct gl_program_parameter_list *paramList,
|
||||
const char *name, GLuint size)
|
||||
{
|
||||
GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
|
||||
if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_VARYING) {
|
||||
/* already in list */
|
||||
return i;
|
||||
}
|
||||
else {
|
||||
assert(size == 4);
|
||||
i = _mesa_add_parameter(paramList, PROGRAM_VARYING, name,
|
||||
size, GL_NONE, NULL, NULL);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add parameter representing a vertex program attribute.
|
||||
* \param size size of attribute (in floats), may be -1 if unknown
|
||||
* \param attrib the attribute index, or -1 if unknown
|
||||
*/
|
||||
GLint
|
||||
_mesa_add_attribute(struct gl_program_parameter_list *paramList,
|
||||
const char *name, GLint size, GLint attrib)
|
||||
{
|
||||
GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
|
||||
if (i >= 0) {
|
||||
/* replace */
|
||||
if (attrib < 0)
|
||||
attrib = i;
|
||||
paramList->Parameters[i].StateIndexes[0] = attrib;
|
||||
}
|
||||
else {
|
||||
/* add */
|
||||
gl_state_index state[STATE_LENGTH];
|
||||
state[0] = (gl_state_index) attrib;
|
||||
if (size < 0)
|
||||
size = 4;
|
||||
i = _mesa_add_parameter(paramList, PROGRAM_INPUT, name,
|
||||
size, GL_NONE, NULL, state);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0 /* not used yet */
|
||||
/**
|
||||
* Returns the number of 4-component registers needed to store a piece
|
||||
* of GL state. For matrices this may be as many as 4 registers,
|
||||
* everything else needs
|
||||
* just 1 register.
|
||||
*/
|
||||
static GLuint
|
||||
sizeof_state_reference(const GLint *stateTokens)
|
||||
{
|
||||
if (stateTokens[0] == STATE_MATRIX) {
|
||||
GLuint rows = stateTokens[4] - stateTokens[3] + 1;
|
||||
assert(rows >= 1);
|
||||
assert(rows <= 4);
|
||||
return rows;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Add a new state reference to the parameter list.
|
||||
* This will be used when the program contains something like this:
|
||||
* PARAM ambient = state.material.front.ambient;
|
||||
*
|
||||
* \param paramList the parameter list
|
||||
* \param state an array of 6 (STATE_LENGTH) state tokens
|
||||
* \return index of the new parameter.
|
||||
*/
|
||||
GLint
|
||||
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
|
||||
const gl_state_index stateTokens[STATE_LENGTH])
|
||||
{
|
||||
const GLuint size = 4; /* XXX fix */
|
||||
const char *name;
|
||||
GLint index;
|
||||
|
||||
/* Check if the state reference is already in the list */
|
||||
for (index = 0; index < (GLint) paramList->NumParameters; index++) {
|
||||
GLuint i, match = 0;
|
||||
for (i = 0; i < STATE_LENGTH; i++) {
|
||||
if (paramList->Parameters[index].StateIndexes[i] == stateTokens[i]) {
|
||||
match++;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match == STATE_LENGTH) {
|
||||
/* this state reference is already in the parameter list */
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
name = _mesa_program_state_string(stateTokens);
|
||||
index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
|
||||
size, GL_NONE,
|
||||
NULL, (gl_state_index *) stateTokens);
|
||||
paramList->StateFlags |= _mesa_program_state_flags(stateTokens);
|
||||
|
||||
/* free name string here since we duplicated it in add_parameter() */
|
||||
_mesa_free((void *) name);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lookup a parameter value by name in the given parameter list.
|
||||
* \return pointer to the float[4] values.
|
||||
*/
|
||||
GLfloat *
|
||||
_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
|
||||
GLsizei nameLen, const char *name)
|
||||
{
|
||||
GLuint i = _mesa_lookup_parameter_index(paramList, nameLen, name);
|
||||
if (i < 0)
|
||||
return NULL;
|
||||
else
|
||||
return paramList->ParameterValues[i];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given a program parameter name, find its position in the list of parameters.
|
||||
* \param paramList the parameter list to search
|
||||
* \param nameLen length of name (in chars).
|
||||
* If length is negative, assume that name is null-terminated.
|
||||
* \param name the name to search for
|
||||
* \return index of parameter in the list.
|
||||
*/
|
||||
GLint
|
||||
_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
|
||||
GLsizei nameLen, const char *name)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
if (!paramList)
|
||||
return -1;
|
||||
|
||||
if (nameLen == -1) {
|
||||
/* name is null-terminated */
|
||||
for (i = 0; i < (GLint) paramList->NumParameters; i++) {
|
||||
if (paramList->Parameters[i].Name &&
|
||||
_mesa_strcmp(paramList->Parameters[i].Name, name) == 0)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* name is not null-terminated, use nameLen */
|
||||
for (i = 0; i < (GLint) paramList->NumParameters; i++) {
|
||||
if (paramList->Parameters[i].Name &&
|
||||
_mesa_strncmp(paramList->Parameters[i].Name, name, nameLen) == 0
|
||||
&& _mesa_strlen(paramList->Parameters[i].Name) == (size_t)nameLen)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Look for a float vector in the given parameter list. The float vector
|
||||
* may be of length 1, 2, 3 or 4. If swizzleOut is non-null, we'll try
|
||||
* swizzling to find a match.
|
||||
* \param list the parameter list to search
|
||||
* \param v the float vector to search for
|
||||
* \param size number of element in v
|
||||
* \param posOut returns the position of the constant, if found
|
||||
* \param swizzleOut returns a swizzle mask describing location of the
|
||||
* vector elements if found.
|
||||
* \return GL_TRUE if found, GL_FALSE if not found
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
|
||||
const GLfloat v[], GLuint vSize,
|
||||
GLint *posOut, GLuint *swizzleOut)
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
assert(vSize >= 1);
|
||||
assert(vSize <= 4);
|
||||
|
||||
if (!list)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < list->NumParameters; i++) {
|
||||
if (list->Parameters[i].Type == PROGRAM_CONSTANT) {
|
||||
if (!swizzleOut) {
|
||||
/* swizzle not allowed */
|
||||
GLuint j, match = 0;
|
||||
for (j = 0; j < vSize; j++) {
|
||||
if (v[j] == list->ParameterValues[i][j])
|
||||
match++;
|
||||
}
|
||||
if (match == vSize) {
|
||||
*posOut = i;
|
||||
return GL_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* try matching w/ swizzle */
|
||||
if (vSize == 1) {
|
||||
/* look for v[0] anywhere within float[4] value */
|
||||
GLuint j;
|
||||
for (j = 0; j < 4; j++) {
|
||||
if (list->ParameterValues[i][j] == v[0]) {
|
||||
/* found it */
|
||||
*posOut = i;
|
||||
*swizzleOut = MAKE_SWIZZLE4(j, j, j, j);
|
||||
return GL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (vSize <= list->Parameters[i].Size) {
|
||||
/* see if we can match this constant (with a swizzle) */
|
||||
GLuint swz[4];
|
||||
GLuint match = 0, j, k;
|
||||
for (j = 0; j < vSize; j++) {
|
||||
if (v[j] == list->ParameterValues[i][j]) {
|
||||
swz[j] = j;
|
||||
match++;
|
||||
}
|
||||
else {
|
||||
for (k = 0; k < list->Parameters[i].Size; k++) {
|
||||
if (v[j] == list->ParameterValues[i][k]) {
|
||||
swz[j] = k;
|
||||
match++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* smear last value to remaining positions */
|
||||
for (; j < 4; j++)
|
||||
swz[j] = swz[j-1];
|
||||
|
||||
if (match == vSize) {
|
||||
*posOut = i;
|
||||
*swizzleOut = MAKE_SWIZZLE4(swz[0], swz[1], swz[2], swz[3]);
|
||||
return GL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*posOut = -1;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
struct gl_program_parameter_list *
|
||||
_mesa_clone_parameter_list(const struct gl_program_parameter_list *list)
|
||||
{
|
||||
struct gl_program_parameter_list *clone;
|
||||
GLuint i;
|
||||
|
||||
clone = _mesa_new_parameter_list();
|
||||
if (!clone)
|
||||
return NULL;
|
||||
|
||||
/** Not too efficient, but correct */
|
||||
for (i = 0; i < list->NumParameters; i++) {
|
||||
struct gl_program_parameter *p = list->Parameters + i;
|
||||
GLuint size = MIN2(p->Size, 4);
|
||||
GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType,
|
||||
list->ParameterValues[i], NULL);
|
||||
ASSERT(j >= 0);
|
||||
/* copy state indexes */
|
||||
if (p->Type == PROGRAM_STATE_VAR) {
|
||||
GLint k;
|
||||
struct gl_program_parameter *q = clone->Parameters + j;
|
||||
for (k = 0; k < STATE_LENGTH; k++) {
|
||||
q->StateIndexes[k] = p->StateIndexes[k];
|
||||
}
|
||||
}
|
||||
else {
|
||||
clone->Parameters[j].Size = p->Size;
|
||||
}
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find longest name of all uniform parameters in list.
|
||||
*/
|
||||
GLuint
|
||||
_mesa_longest_parameter_name(const struct gl_program_parameter_list *list,
|
||||
enum register_file type)
|
||||
{
|
||||
GLuint i, maxLen = 0;
|
||||
if (!list)
|
||||
return 0;
|
||||
for (i = 0; i < list->NumParameters; i++) {
|
||||
if (list->Parameters[i].Type == type) {
|
||||
GLuint len = _mesa_strlen(list->Parameters[i].Name);
|
||||
if (len > maxLen)
|
||||
maxLen = len;
|
||||
}
|
||||
}
|
||||
return maxLen;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count the number of parameters in the last that match the given type.
|
||||
*/
|
||||
GLuint
|
||||
_mesa_num_parameters_of_type(const struct gl_program_parameter_list *list,
|
||||
enum register_file type)
|
||||
{
|
||||
GLuint i, count = 0;
|
||||
if (list) {
|
||||
for (i = 0; i < list->NumParameters; i++) {
|
||||
if (list->Parameters[i].Type == type)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file prog_parameter.c
|
||||
* Program parameter lists and functions.
|
||||
* \author Brian Paul
|
||||
*/
|
||||
|
||||
#ifndef PROG_PARAMETER_H
|
||||
#define PROG_PARAMETER_H
|
||||
|
||||
#include "mtypes.h"
|
||||
#include "prog_statevars.h"
|
||||
|
||||
|
||||
/**
|
||||
* Program parameter.
|
||||
* Used for NV_fragment_program for "DEFINE"d constants and "DECLARE"d
|
||||
* parameters.
|
||||
* Also used by ARB_vertex/fragment_programs for state variables, etc.
|
||||
* Used by shaders for uniforms, constants, varying vars, etc.
|
||||
*/
|
||||
struct gl_program_parameter
|
||||
{
|
||||
const char *Name; /**< Null-terminated string */
|
||||
enum register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
|
||||
GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */
|
||||
GLuint Size; /**< Number of components (1..4) */
|
||||
/**
|
||||
* A sequence of STATE_* tokens and integers to identify GL state.
|
||||
*/
|
||||
gl_state_index StateIndexes[STATE_LENGTH];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* List of gl_program_parameter instances.
|
||||
*/
|
||||
struct gl_program_parameter_list
|
||||
{
|
||||
GLuint Size; /**< allocated size of Parameters, ParameterValues */
|
||||
GLuint NumParameters; /**< number of parameters in arrays */
|
||||
struct gl_program_parameter *Parameters; /**< Array [Size] */
|
||||
GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */
|
||||
GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes
|
||||
might invalidate ParameterValues[] */
|
||||
};
|
||||
|
||||
|
||||
extern struct gl_program_parameter_list *
|
||||
_mesa_new_parameter_list(void);
|
||||
|
||||
extern void
|
||||
_mesa_free_parameter_list(struct gl_program_parameter_list *paramList);
|
||||
|
||||
extern struct gl_program_parameter_list *
|
||||
_mesa_clone_parameter_list(const struct gl_program_parameter_list *list);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_parameter(struct gl_program_parameter_list *paramList,
|
||||
enum register_file type, const char *name,
|
||||
GLuint size, GLenum datatype, const GLfloat *values,
|
||||
const gl_state_index state[STATE_LENGTH]);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
|
||||
const char *name, const GLfloat values[4]);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_named_constant(struct gl_program_parameter_list *paramList,
|
||||
const char *name, const GLfloat values[4],
|
||||
GLuint size);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
|
||||
const GLfloat values[4], GLuint size,
|
||||
GLuint *swizzleOut);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_uniform(struct gl_program_parameter_list *paramList,
|
||||
const char *name, GLuint size, GLenum datatype);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_sampler(struct gl_program_parameter_list *paramList,
|
||||
const char *name, GLenum datatype);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_varying(struct gl_program_parameter_list *paramList,
|
||||
const char *name, GLuint size);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_attribute(struct gl_program_parameter_list *paramList,
|
||||
const char *name, GLint size, GLint attrib);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
|
||||
const gl_state_index stateTokens[STATE_LENGTH]);
|
||||
|
||||
extern GLfloat *
|
||||
_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
|
||||
GLsizei nameLen, const char *name);
|
||||
|
||||
extern GLint
|
||||
_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
|
||||
GLsizei nameLen, const char *name);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
|
||||
const GLfloat v[], GLuint vSize,
|
||||
GLint *posOut, GLuint *swizzleOut);
|
||||
|
||||
extern GLuint
|
||||
_mesa_longest_parameter_name(const struct gl_program_parameter_list *list,
|
||||
enum register_file type);
|
||||
|
||||
extern GLuint
|
||||
_mesa_num_parameters_of_type(const struct gl_program_parameter_list *list,
|
||||
enum register_file type);
|
||||
|
||||
|
||||
#endif /* PROG_PARAMETER_H */
|
||||
@@ -0,0 +1,758 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file prog_print.c
|
||||
* Print vertex/fragment programs - for debugging.
|
||||
* \author Brian Paul
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "imports.h"
|
||||
#include "prog_instruction.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "prog_print.h"
|
||||
#include "prog_statevars.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return string name for given program/register file.
|
||||
*/
|
||||
static const char *
|
||||
file_string(enum register_file f, gl_prog_print_mode mode)
|
||||
{
|
||||
switch (f) {
|
||||
case PROGRAM_TEMPORARY:
|
||||
return "TEMP";
|
||||
case PROGRAM_LOCAL_PARAM:
|
||||
return "LOCAL";
|
||||
case PROGRAM_ENV_PARAM:
|
||||
return "ENV";
|
||||
case PROGRAM_STATE_VAR:
|
||||
return "STATE";
|
||||
case PROGRAM_INPUT:
|
||||
return "INPUT";
|
||||
case PROGRAM_OUTPUT:
|
||||
return "OUTPUT";
|
||||
case PROGRAM_NAMED_PARAM:
|
||||
return "NAMED";
|
||||
case PROGRAM_CONSTANT:
|
||||
return "CONST";
|
||||
case PROGRAM_UNIFORM:
|
||||
return "UNIFORM";
|
||||
case PROGRAM_VARYING:
|
||||
return "VARYING";
|
||||
case PROGRAM_WRITE_ONLY:
|
||||
return "WRITE_ONLY";
|
||||
case PROGRAM_ADDRESS:
|
||||
return "ADDR";
|
||||
case PROGRAM_SAMPLER:
|
||||
return "SAMPLER";
|
||||
default:
|
||||
return "Unknown program file!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return ARB_v/f_prog-style input attrib string.
|
||||
*/
|
||||
static const char *
|
||||
arb_input_attrib_string(GLint index, GLenum progType)
|
||||
{
|
||||
const char *vertAttribs[] = {
|
||||
"vertex.position",
|
||||
"vertex.weight",
|
||||
"vertex.normal",
|
||||
"vertex.color.primary",
|
||||
"vertex.color.secondary",
|
||||
"vertex.fogcoord",
|
||||
"vertex.(six)",
|
||||
"vertex.(seven)",
|
||||
"vertex.texcoord[0]",
|
||||
"vertex.texcoord[1]",
|
||||
"vertex.texcoord[2]",
|
||||
"vertex.texcoord[3]",
|
||||
"vertex.texcoord[4]",
|
||||
"vertex.texcoord[5]",
|
||||
"vertex.texcoord[6]",
|
||||
"vertex.texcoord[7]"
|
||||
};
|
||||
const char *fragAttribs[] = {
|
||||
"fragment.position",
|
||||
"fragment.color.primary",
|
||||
"fragment.color.secondary",
|
||||
"fragment.fogcoord",
|
||||
"fragment.texcoord[0]",
|
||||
"fragment.texcoord[1]",
|
||||
"fragment.texcoord[2]",
|
||||
"fragment.texcoord[3]",
|
||||
"fragment.texcoord[4]",
|
||||
"fragment.texcoord[5]",
|
||||
"fragment.texcoord[6]",
|
||||
"fragment.texcoord[7]",
|
||||
"fragment.varying[0]",
|
||||
"fragment.varying[1]",
|
||||
"fragment.varying[2]",
|
||||
"fragment.varying[3]",
|
||||
"fragment.varying[4]",
|
||||
"fragment.varying[5]",
|
||||
"fragment.varying[6]",
|
||||
"fragment.varying[7]"
|
||||
};
|
||||
|
||||
if (progType == GL_VERTEX_PROGRAM_ARB) {
|
||||
assert(index < sizeof(vertAttribs) / sizeof(vertAttribs[0]));
|
||||
return vertAttribs[index];
|
||||
}
|
||||
else {
|
||||
assert(index < sizeof(fragAttribs) / sizeof(fragAttribs[0]));
|
||||
return fragAttribs[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return ARB_v/f_prog-style output attrib string.
|
||||
*/
|
||||
static const char *
|
||||
arb_output_attrib_string(GLint index, GLenum progType)
|
||||
{
|
||||
const char *vertResults[] = {
|
||||
"result.position",
|
||||
"result.color.primary",
|
||||
"result.color.secondary",
|
||||
"result.fogcoord",
|
||||
"result.texcoord[0]",
|
||||
"result.texcoord[1]",
|
||||
"result.texcoord[2]",
|
||||
"result.texcoord[3]",
|
||||
"result.texcoord[4]",
|
||||
"result.texcoord[5]",
|
||||
"result.texcoord[6]",
|
||||
"result.texcoord[7]",
|
||||
"result.varying[0]",
|
||||
"result.varying[1]",
|
||||
"result.varying[2]",
|
||||
"result.varying[3]",
|
||||
"result.varying[4]",
|
||||
"result.varying[5]",
|
||||
"result.varying[6]",
|
||||
"result.varying[7]"
|
||||
};
|
||||
const char *fragResults[] = {
|
||||
"result.color",
|
||||
"result.depth"
|
||||
};
|
||||
|
||||
if (progType == GL_VERTEX_PROGRAM_ARB) {
|
||||
assert(index < sizeof(vertResults) / sizeof(vertResults[0]));
|
||||
return vertResults[index];
|
||||
}
|
||||
else {
|
||||
assert(index < sizeof(fragResults) / sizeof(fragResults[0]));
|
||||
return fragResults[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return string representation of the given register.
|
||||
* Note that some types of registers (like PROGRAM_UNIFORM) aren't defined
|
||||
* by the ARB/NV program languages so we've taken some liberties here.
|
||||
* \param file the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc)
|
||||
* \param index number of the register in the register file
|
||||
* \param mode the output format/mode/style
|
||||
* \param prog pointer to containing program
|
||||
*/
|
||||
static const char *
|
||||
reg_string(enum register_file f, GLint index, gl_prog_print_mode mode,
|
||||
const struct gl_program *prog)
|
||||
{
|
||||
static char str[100];
|
||||
|
||||
str[0] = 0;
|
||||
|
||||
switch (mode) {
|
||||
case PROG_PRINT_DEBUG:
|
||||
sprintf(str, "%s[%d]", file_string(f, mode), index);
|
||||
break;
|
||||
|
||||
case PROG_PRINT_ARB:
|
||||
switch (f) {
|
||||
case PROGRAM_INPUT:
|
||||
sprintf(str, "%s", arb_input_attrib_string(index, prog->Target));
|
||||
break;
|
||||
case PROGRAM_OUTPUT:
|
||||
sprintf(str, "%s", arb_output_attrib_string(index, prog->Target));
|
||||
break;
|
||||
case PROGRAM_TEMPORARY:
|
||||
sprintf(str, "temp%d", index);
|
||||
break;
|
||||
case PROGRAM_ENV_PARAM:
|
||||
sprintf(str, "program.env[%d]", index);
|
||||
break;
|
||||
case PROGRAM_LOCAL_PARAM:
|
||||
sprintf(str, "program.local[%d]", index);
|
||||
break;
|
||||
case PROGRAM_VARYING: /* extension */
|
||||
sprintf(str, "varying[%d]", index);
|
||||
break;
|
||||
case PROGRAM_CONSTANT: /* extension */
|
||||
sprintf(str, "constant[%d]", index);
|
||||
break;
|
||||
case PROGRAM_UNIFORM: /* extension */
|
||||
sprintf(str, "uniform[%d]", index);
|
||||
break;
|
||||
case PROGRAM_STATE_VAR:
|
||||
{
|
||||
struct gl_program_parameter *param
|
||||
= prog->Parameters->Parameters + index;
|
||||
sprintf(str, _mesa_program_state_string(param->StateIndexes));
|
||||
}
|
||||
break;
|
||||
case PROGRAM_ADDRESS:
|
||||
sprintf(str, "A%d", index);
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(NULL, "bad file in reg_string()");
|
||||
}
|
||||
break;
|
||||
|
||||
case PROG_PRINT_NV:
|
||||
switch (f) {
|
||||
case PROGRAM_INPUT:
|
||||
if (prog->Target == GL_VERTEX_PROGRAM_ARB)
|
||||
sprintf(str, "v[%d]", index);
|
||||
else
|
||||
sprintf(str, "f[%d]", index);
|
||||
break;
|
||||
case PROGRAM_OUTPUT:
|
||||
sprintf(str, "o[%d]", index);
|
||||
break;
|
||||
case PROGRAM_TEMPORARY:
|
||||
sprintf(str, "R%d", index);
|
||||
break;
|
||||
case PROGRAM_ENV_PARAM:
|
||||
sprintf(str, "c[%d]", index);
|
||||
break;
|
||||
case PROGRAM_VARYING: /* extension */
|
||||
sprintf(str, "varying[%d]", index);
|
||||
break;
|
||||
case PROGRAM_UNIFORM: /* extension */
|
||||
sprintf(str, "uniform[%d]", index);
|
||||
break;
|
||||
case PROGRAM_CONSTANT: /* extension */
|
||||
sprintf(str, "constant[%d]", index);
|
||||
break;
|
||||
case PROGRAM_STATE_VAR: /* extension */
|
||||
sprintf(str, "state[%d]", index);
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(NULL, "bad file in reg_string()");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
_mesa_problem(NULL, "bad mode in reg_string()");
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a string representation of the given swizzle word.
|
||||
* If extended is true, use extended (comma-separated) format.
|
||||
* \param swizzle the swizzle field
|
||||
* \param negateBase 4-bit negation vector
|
||||
* \param extended if true, also allow 0, 1 values
|
||||
*/
|
||||
const char *
|
||||
_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended)
|
||||
{
|
||||
static const char swz[] = "xyzw01?!";
|
||||
static char s[20];
|
||||
GLuint i = 0;
|
||||
|
||||
if (!extended && swizzle == SWIZZLE_NOOP && negateBase == 0)
|
||||
return ""; /* no swizzle/negation */
|
||||
|
||||
if (!extended)
|
||||
s[i++] = '.';
|
||||
|
||||
if (negateBase & 0x1)
|
||||
s[i++] = '-';
|
||||
s[i++] = swz[GET_SWZ(swizzle, 0)];
|
||||
|
||||
if (extended) {
|
||||
s[i++] = ',';
|
||||
}
|
||||
|
||||
if (negateBase & 0x2)
|
||||
s[i++] = '-';
|
||||
s[i++] = swz[GET_SWZ(swizzle, 1)];
|
||||
|
||||
if (extended) {
|
||||
s[i++] = ',';
|
||||
}
|
||||
|
||||
if (negateBase & 0x4)
|
||||
s[i++] = '-';
|
||||
s[i++] = swz[GET_SWZ(swizzle, 2)];
|
||||
|
||||
if (extended) {
|
||||
s[i++] = ',';
|
||||
}
|
||||
|
||||
if (negateBase & 0x8)
|
||||
s[i++] = '-';
|
||||
s[i++] = swz[GET_SWZ(swizzle, 3)];
|
||||
|
||||
s[i] = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
writemask_string(GLuint writeMask)
|
||||
{
|
||||
static char s[10];
|
||||
GLuint i = 0;
|
||||
|
||||
if (writeMask == WRITEMASK_XYZW)
|
||||
return "";
|
||||
|
||||
s[i++] = '.';
|
||||
if (writeMask & WRITEMASK_X)
|
||||
s[i++] = 'x';
|
||||
if (writeMask & WRITEMASK_Y)
|
||||
s[i++] = 'y';
|
||||
if (writeMask & WRITEMASK_Z)
|
||||
s[i++] = 'z';
|
||||
if (writeMask & WRITEMASK_W)
|
||||
s[i++] = 'w';
|
||||
|
||||
s[i] = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
_mesa_condcode_string(GLuint condcode)
|
||||
{
|
||||
switch (condcode) {
|
||||
case COND_GT: return "GT";
|
||||
case COND_EQ: return "EQ";
|
||||
case COND_LT: return "LT";
|
||||
case COND_UN: return "UN";
|
||||
case COND_GE: return "GE";
|
||||
case COND_LE: return "LE";
|
||||
case COND_NE: return "NE";
|
||||
case COND_TR: return "TR";
|
||||
case COND_FL: return "FL";
|
||||
default: return "cond???";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_dst_reg(const struct prog_dst_register *dstReg, gl_prog_print_mode mode,
|
||||
const struct gl_program *prog)
|
||||
{
|
||||
_mesa_printf("%s%s",
|
||||
reg_string((enum register_file) dstReg->File,
|
||||
dstReg->Index, mode, prog),
|
||||
writemask_string(dstReg->WriteMask));
|
||||
|
||||
if (dstReg->CondMask != COND_TR) {
|
||||
_mesa_printf(" (%s.%s)",
|
||||
_mesa_condcode_string(dstReg->CondMask),
|
||||
_mesa_swizzle_string(dstReg->CondSwizzle, GL_FALSE, GL_FALSE));
|
||||
}
|
||||
|
||||
#if 0
|
||||
_mesa_printf("%s[%d]%s",
|
||||
file_string((enum register_file) dstReg->File, mode),
|
||||
dstReg->Index,
|
||||
writemask_string(dstReg->WriteMask));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
print_src_reg(const struct prog_src_register *srcReg, gl_prog_print_mode mode,
|
||||
const struct gl_program *prog)
|
||||
{
|
||||
_mesa_printf("%s%s",
|
||||
reg_string((enum register_file) srcReg->File,
|
||||
srcReg->Index, mode, prog),
|
||||
_mesa_swizzle_string(srcReg->Swizzle,
|
||||
srcReg->NegateBase, GL_FALSE));
|
||||
#if 0
|
||||
_mesa_printf("%s[%d]%s",
|
||||
file_string((enum register_file) srcReg->File, mode),
|
||||
srcReg->Index,
|
||||
_mesa_swizzle_string(srcReg->Swizzle,
|
||||
srcReg->NegateBase, GL_FALSE));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
print_comment(const struct prog_instruction *inst)
|
||||
{
|
||||
if (inst->Comment)
|
||||
_mesa_printf("; # %s\n", inst->Comment);
|
||||
else
|
||||
_mesa_printf(";\n");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_alu_instruction(const struct prog_instruction *inst,
|
||||
const char *opcode_string, GLuint numRegs,
|
||||
gl_prog_print_mode mode,
|
||||
const struct gl_program *prog)
|
||||
{
|
||||
GLuint j;
|
||||
|
||||
_mesa_printf("%s", opcode_string);
|
||||
if (inst->CondUpdate)
|
||||
_mesa_printf(".C");
|
||||
|
||||
/* frag prog only */
|
||||
if (inst->SaturateMode == SATURATE_ZERO_ONE)
|
||||
_mesa_printf("_SAT");
|
||||
|
||||
_mesa_printf(" ");
|
||||
if (inst->DstReg.File != PROGRAM_UNDEFINED) {
|
||||
print_dst_reg(&inst->DstReg, mode, prog);
|
||||
}
|
||||
else {
|
||||
_mesa_printf(" ???");
|
||||
}
|
||||
|
||||
if (numRegs > 0)
|
||||
_mesa_printf(", ");
|
||||
|
||||
for (j = 0; j < numRegs; j++) {
|
||||
print_src_reg(inst->SrcReg + j, mode, prog);
|
||||
if (j + 1 < numRegs)
|
||||
_mesa_printf(", ");
|
||||
}
|
||||
|
||||
print_comment(inst);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_print_alu_instruction(const struct prog_instruction *inst,
|
||||
const char *opcode_string, GLuint numRegs)
|
||||
{
|
||||
print_alu_instruction(inst, opcode_string, numRegs, PROG_PRINT_DEBUG, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_print_instruction(const struct prog_instruction *inst)
|
||||
{
|
||||
/* note: 4th param should be ignored for PROG_PRINT_DEBUG */
|
||||
_mesa_print_instruction_opt(inst, 0, PROG_PRINT_DEBUG, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a single vertex/fragment program instruction.
|
||||
*/
|
||||
GLint
|
||||
_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent,
|
||||
gl_prog_print_mode mode,
|
||||
const struct gl_program *prog)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
if (inst->Opcode == OPCODE_ELSE ||
|
||||
inst->Opcode == OPCODE_ENDIF ||
|
||||
inst->Opcode == OPCODE_ENDLOOP ||
|
||||
inst->Opcode == OPCODE_ENDSUB) {
|
||||
indent -= 3;
|
||||
}
|
||||
for (i = 0; i < indent; i++) {
|
||||
_mesa_printf(" ");
|
||||
}
|
||||
|
||||
switch (inst->Opcode) {
|
||||
case OPCODE_PRINT:
|
||||
_mesa_printf("PRINT '%s'", inst->Data);
|
||||
if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) {
|
||||
_mesa_printf(", ");
|
||||
_mesa_printf("%s[%d]%s",
|
||||
file_string((enum register_file) inst->SrcReg[0].File,
|
||||
mode),
|
||||
inst->SrcReg[0].Index,
|
||||
_mesa_swizzle_string(inst->SrcReg[0].Swizzle,
|
||||
inst->SrcReg[0].NegateBase, GL_FALSE));
|
||||
}
|
||||
if (inst->Comment)
|
||||
_mesa_printf(" # %s", inst->Comment);
|
||||
print_comment(inst);
|
||||
break;
|
||||
case OPCODE_SWZ:
|
||||
_mesa_printf("SWZ");
|
||||
if (inst->SaturateMode == SATURATE_ZERO_ONE)
|
||||
_mesa_printf("_SAT");
|
||||
_mesa_printf(" ");
|
||||
print_dst_reg(&inst->DstReg, mode, prog);
|
||||
_mesa_printf("%s[%d], %s",
|
||||
file_string((enum register_file) inst->SrcReg[0].File,
|
||||
mode),
|
||||
inst->SrcReg[0].Index,
|
||||
_mesa_swizzle_string(inst->SrcReg[0].Swizzle,
|
||||
inst->SrcReg[0].NegateBase, GL_TRUE));
|
||||
print_comment(inst);
|
||||
break;
|
||||
case OPCODE_TEX:
|
||||
case OPCODE_TXP:
|
||||
case OPCODE_TXB:
|
||||
_mesa_printf("%s", _mesa_opcode_string(inst->Opcode));
|
||||
if (inst->SaturateMode == SATURATE_ZERO_ONE)
|
||||
_mesa_printf("_SAT");
|
||||
_mesa_printf(" ");
|
||||
print_dst_reg(&inst->DstReg, mode, prog);
|
||||
_mesa_printf(", ");
|
||||
print_src_reg(&inst->SrcReg[0], mode, prog);
|
||||
_mesa_printf(", texture[%d], ", inst->TexSrcUnit);
|
||||
switch (inst->TexSrcTarget) {
|
||||
case TEXTURE_1D_INDEX: _mesa_printf("1D"); break;
|
||||
case TEXTURE_2D_INDEX: _mesa_printf("2D"); break;
|
||||
case TEXTURE_3D_INDEX: _mesa_printf("3D"); break;
|
||||
case TEXTURE_CUBE_INDEX: _mesa_printf("CUBE"); break;
|
||||
case TEXTURE_RECT_INDEX: _mesa_printf("RECT"); break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
print_comment(inst);
|
||||
break;
|
||||
case OPCODE_ARL:
|
||||
_mesa_printf("ARL addr.x, ");
|
||||
print_src_reg(&inst->SrcReg[0], mode, prog);
|
||||
print_comment(inst);
|
||||
break;
|
||||
case OPCODE_BRA:
|
||||
_mesa_printf("BRA %d (%s%s)",
|
||||
inst->BranchTarget,
|
||||
_mesa_condcode_string(inst->DstReg.CondMask),
|
||||
_mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE));
|
||||
print_comment(inst);
|
||||
break;
|
||||
case OPCODE_IF:
|
||||
if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) {
|
||||
/* Use ordinary register */
|
||||
_mesa_printf("IF ");
|
||||
print_src_reg(&inst->SrcReg[0], mode, prog);
|
||||
_mesa_printf("; ");
|
||||
}
|
||||
else {
|
||||
/* Use cond codes */
|
||||
_mesa_printf("IF (%s%s);",
|
||||
_mesa_condcode_string(inst->DstReg.CondMask),
|
||||
_mesa_swizzle_string(inst->DstReg.CondSwizzle,
|
||||
0, GL_FALSE));
|
||||
}
|
||||
_mesa_printf(" # (if false, goto %d)", inst->BranchTarget);
|
||||
print_comment(inst);
|
||||
return indent + 3;
|
||||
case OPCODE_ELSE:
|
||||
_mesa_printf("ELSE; # (goto %d)\n", inst->BranchTarget);
|
||||
return indent + 3;
|
||||
case OPCODE_ENDIF:
|
||||
_mesa_printf("ENDIF;\n");
|
||||
break;
|
||||
case OPCODE_BGNLOOP:
|
||||
_mesa_printf("BGNLOOP; # (end at %d)\n", inst->BranchTarget);
|
||||
return indent + 3;
|
||||
case OPCODE_ENDLOOP:
|
||||
_mesa_printf("ENDLOOP; # (goto %d)\n", inst->BranchTarget);
|
||||
break;
|
||||
case OPCODE_BRK:
|
||||
case OPCODE_CONT:
|
||||
_mesa_printf("%s (%s%s); # (goto %d)",
|
||||
_mesa_opcode_string(inst->Opcode),
|
||||
_mesa_condcode_string(inst->DstReg.CondMask),
|
||||
_mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE),
|
||||
inst->BranchTarget);
|
||||
print_comment(inst);
|
||||
break;
|
||||
|
||||
case OPCODE_BGNSUB:
|
||||
if (mode == PROG_PRINT_NV) {
|
||||
_mesa_printf("%s:\n", inst->Comment); /* comment is label */
|
||||
return indent;
|
||||
}
|
||||
else {
|
||||
_mesa_printf("BGNSUB");
|
||||
print_comment(inst);
|
||||
return indent + 3;
|
||||
}
|
||||
case OPCODE_ENDSUB:
|
||||
if (mode == PROG_PRINT_DEBUG) {
|
||||
_mesa_printf("ENDSUB");
|
||||
print_comment(inst);
|
||||
}
|
||||
break;
|
||||
case OPCODE_CAL:
|
||||
if (mode == PROG_PRINT_NV) {
|
||||
_mesa_printf("CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget);
|
||||
}
|
||||
else {
|
||||
_mesa_printf("CAL %u", inst->BranchTarget);
|
||||
print_comment(inst);
|
||||
}
|
||||
break;
|
||||
case OPCODE_RET:
|
||||
_mesa_printf("RET (%s%s)",
|
||||
_mesa_condcode_string(inst->DstReg.CondMask),
|
||||
_mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE));
|
||||
print_comment(inst);
|
||||
break;
|
||||
|
||||
case OPCODE_END:
|
||||
_mesa_printf("END\n");
|
||||
break;
|
||||
case OPCODE_NOP:
|
||||
if (mode == PROG_PRINT_DEBUG) {
|
||||
_mesa_printf("NOP");
|
||||
print_comment(inst);
|
||||
}
|
||||
else if (inst->Comment) {
|
||||
/* ARB/NV extensions don't have NOP instruction */
|
||||
_mesa_printf("# %s\n", inst->Comment);
|
||||
}
|
||||
break;
|
||||
/* XXX may need other special-case instructions */
|
||||
default:
|
||||
/* typical alu instruction */
|
||||
print_alu_instruction(inst,
|
||||
_mesa_opcode_string(inst->Opcode),
|
||||
_mesa_num_inst_src_regs(inst->Opcode),
|
||||
mode, prog);
|
||||
break;
|
||||
}
|
||||
return indent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print program to stdout, default options.
|
||||
*/
|
||||
void
|
||||
_mesa_print_program(const struct gl_program *prog)
|
||||
{
|
||||
_mesa_print_program_opt(prog, PROG_PRINT_DEBUG, GL_TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print program, with options.
|
||||
*/
|
||||
void
|
||||
_mesa_print_program_opt(const struct gl_program *prog,
|
||||
gl_prog_print_mode mode,
|
||||
GLboolean lineNumbers)
|
||||
{
|
||||
GLuint i, indent = 0;
|
||||
|
||||
switch (prog->Target) {
|
||||
case GL_VERTEX_PROGRAM_ARB:
|
||||
if (mode == PROG_PRINT_ARB)
|
||||
_mesa_printf("!!ARBvp1.0\n");
|
||||
else if (mode == PROG_PRINT_NV)
|
||||
_mesa_printf("!!VP1.0\n");
|
||||
else
|
||||
_mesa_printf("# Vertex Program/Shader\n");
|
||||
break;
|
||||
case GL_FRAGMENT_PROGRAM_ARB:
|
||||
case GL_FRAGMENT_PROGRAM_NV:
|
||||
if (mode == PROG_PRINT_ARB)
|
||||
_mesa_printf("!!ARBfp1.0\n");
|
||||
else if (mode == PROG_PRINT_NV)
|
||||
_mesa_printf("!!FP1.0\n");
|
||||
else
|
||||
_mesa_printf("# Fragment Program/Shader\n");
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < prog->NumInstructions; i++) {
|
||||
if (lineNumbers)
|
||||
_mesa_printf("%3d: ", i);
|
||||
indent = _mesa_print_instruction_opt(prog->Instructions + i,
|
||||
indent, mode, prog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print all of a program's parameters.
|
||||
*/
|
||||
void
|
||||
_mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog)
|
||||
{
|
||||
_mesa_printf("InputsRead: 0x%x\n", prog->InputsRead);
|
||||
_mesa_printf("OutputsWritten: 0x%x\n", prog->OutputsWritten);
|
||||
_mesa_printf("NumInstructions=%d\n", prog->NumInstructions);
|
||||
_mesa_printf("NumTemporaries=%d\n", prog->NumTemporaries);
|
||||
_mesa_printf("NumParameters=%d\n", prog->NumParameters);
|
||||
_mesa_printf("NumAttributes=%d\n", prog->NumAttributes);
|
||||
_mesa_printf("NumAddressRegs=%d\n", prog->NumAddressRegs);
|
||||
|
||||
_mesa_load_state_parameters(ctx, prog->Parameters);
|
||||
|
||||
#if 0
|
||||
_mesa_printf("Local Params:\n");
|
||||
for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){
|
||||
const GLfloat *p = prog->LocalParams[i];
|
||||
_mesa_printf("%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]);
|
||||
}
|
||||
#endif
|
||||
_mesa_print_parameter_list(prog->Parameters);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_print_parameter_list(const struct gl_program_parameter_list *list)
|
||||
{
|
||||
const gl_prog_print_mode mode = PROG_PRINT_DEBUG;
|
||||
GLuint i;
|
||||
|
||||
_mesa_printf("param list %p\n", (void *) list);
|
||||
for (i = 0; i < list->NumParameters; i++){
|
||||
struct gl_program_parameter *param = list->Parameters + i;
|
||||
const GLfloat *v = list->ParameterValues[i];
|
||||
_mesa_printf("param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g};\n",
|
||||
i, param->Size,
|
||||
file_string(list->Parameters[i].Type, mode),
|
||||
param->Name, v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
}
|
||||
+33
-28
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -20,48 +20,53 @@
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Brian Paul
|
||||
*/
|
||||
|
||||
#ifndef NVVERTEXEC_H
|
||||
#define NVVERTEXEC_H
|
||||
|
||||
#ifndef PROG_PRINT_H
|
||||
#define PROG_PRINT_H
|
||||
|
||||
|
||||
/**
|
||||
* Virtual vertex program machine state.
|
||||
* Only used during program execution.
|
||||
* The output style to use when printing programs.
|
||||
*/
|
||||
struct vp_machine
|
||||
{
|
||||
GLfloat Temporaries[MAX_NV_VERTEX_PROGRAM_TEMPS][4];
|
||||
GLfloat Inputs[MAX_NV_VERTEX_PROGRAM_INPUTS][4];
|
||||
GLuint InputsSize[MAX_NV_VERTEX_PROGRAM_INPUTS];
|
||||
GLfloat Outputs[MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
|
||||
GLint AddressReg[4];
|
||||
};
|
||||
typedef enum {
|
||||
PROG_PRINT_ARB,
|
||||
PROG_PRINT_NV,
|
||||
PROG_PRINT_DEBUG
|
||||
} gl_prog_print_mode;
|
||||
|
||||
|
||||
extern const char *
|
||||
_mesa_condcode_string(GLuint condcode);
|
||||
|
||||
extern const char *
|
||||
_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended);
|
||||
|
||||
extern void
|
||||
_mesa_init_vp_per_vertex_registers(GLcontext *ctx, struct vp_machine *machine);
|
||||
_mesa_print_alu_instruction(const struct prog_instruction *inst,
|
||||
const char *opcode_string, GLuint numRegs);
|
||||
|
||||
extern void
|
||||
_mesa_init_vp_per_primitive_registers(GLcontext *ctx);
|
||||
_mesa_print_instruction(const struct prog_instruction *inst);
|
||||
|
||||
extern GLint
|
||||
_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent,
|
||||
gl_prog_print_mode mode,
|
||||
const struct gl_program *prog);
|
||||
|
||||
extern void
|
||||
_mesa_exec_vertex_program(GLcontext *ctx,
|
||||
struct vp_machine *machine,
|
||||
const struct gl_vertex_program *program);
|
||||
_mesa_print_program(const struct gl_program *prog);
|
||||
|
||||
extern void
|
||||
_mesa_exec_vertex_state_program(GLcontext *ctx,
|
||||
struct gl_vertex_program *vprog,
|
||||
const GLfloat *params);
|
||||
_mesa_print_program_opt(const struct gl_program *prog, gl_prog_print_mode mode,
|
||||
GLboolean lineNumbers);
|
||||
|
||||
extern void
|
||||
_mesa_dump_vp_state( const struct gl_vertex_program_state *state,
|
||||
const struct vp_machine *machine);
|
||||
_mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog);
|
||||
|
||||
#endif
|
||||
extern void
|
||||
_mesa_print_parameter_list(const struct gl_program_parameter_list *list);
|
||||
|
||||
|
||||
#endif /* PROG_PRINT_H */
|
||||
@@ -0,0 +1,824 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file prog_statevars.c
|
||||
* Program state variable management.
|
||||
* \author Brian Paul
|
||||
*/
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "hash.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "prog_statevars.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "nvvertparse.h"
|
||||
|
||||
|
||||
/**
|
||||
* Use the list of tokens in the state[] array to find global GL state
|
||||
* and return it in <value>. Usually, four values are returned in <value>
|
||||
* but matrix queries may return as many as 16 values.
|
||||
* This function is used for ARB vertex/fragment programs.
|
||||
* The program parser will produce the state[] values.
|
||||
*/
|
||||
static void
|
||||
_mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
|
||||
GLfloat *value)
|
||||
{
|
||||
switch (state[0]) {
|
||||
case STATE_MATERIAL:
|
||||
{
|
||||
/* state[1] is either 0=front or 1=back side */
|
||||
const GLuint face = (GLuint) state[1];
|
||||
const struct gl_material *mat = &ctx->Light.Material;
|
||||
ASSERT(face == 0 || face == 1);
|
||||
/* we rely on tokens numbered so that _BACK_ == _FRONT_+ 1 */
|
||||
ASSERT(MAT_ATTRIB_FRONT_AMBIENT + 1 == MAT_ATTRIB_BACK_AMBIENT);
|
||||
/* XXX we could get rid of this switch entirely with a little
|
||||
* work in arbprogparse.c's parse_state_single_item().
|
||||
*/
|
||||
/* state[2] is the material attribute */
|
||||
switch (state[2]) {
|
||||
case STATE_AMBIENT:
|
||||
COPY_4V(value, mat->Attrib[MAT_ATTRIB_FRONT_AMBIENT + face]);
|
||||
return;
|
||||
case STATE_DIFFUSE:
|
||||
COPY_4V(value, mat->Attrib[MAT_ATTRIB_FRONT_DIFFUSE + face]);
|
||||
return;
|
||||
case STATE_SPECULAR:
|
||||
COPY_4V(value, mat->Attrib[MAT_ATTRIB_FRONT_SPECULAR + face]);
|
||||
return;
|
||||
case STATE_EMISSION:
|
||||
COPY_4V(value, mat->Attrib[MAT_ATTRIB_FRONT_EMISSION + face]);
|
||||
return;
|
||||
case STATE_SHININESS:
|
||||
value[0] = mat->Attrib[MAT_ATTRIB_FRONT_SHININESS + face][0];
|
||||
value[1] = 0.0F;
|
||||
value[2] = 0.0F;
|
||||
value[3] = 1.0F;
|
||||
return;
|
||||
default:
|
||||
_mesa_problem(ctx, "Invalid material state in fetch_state");
|
||||
return;
|
||||
}
|
||||
}
|
||||
case STATE_LIGHT:
|
||||
{
|
||||
/* state[1] is the light number */
|
||||
const GLuint ln = (GLuint) state[1];
|
||||
/* state[2] is the light attribute */
|
||||
switch (state[2]) {
|
||||
case STATE_AMBIENT:
|
||||
COPY_4V(value, ctx->Light.Light[ln].Ambient);
|
||||
return;
|
||||
case STATE_DIFFUSE:
|
||||
COPY_4V(value, ctx->Light.Light[ln].Diffuse);
|
||||
return;
|
||||
case STATE_SPECULAR:
|
||||
COPY_4V(value, ctx->Light.Light[ln].Specular);
|
||||
return;
|
||||
case STATE_POSITION:
|
||||
COPY_4V(value, ctx->Light.Light[ln].EyePosition);
|
||||
return;
|
||||
case STATE_ATTENUATION:
|
||||
value[0] = ctx->Light.Light[ln].ConstantAttenuation;
|
||||
value[1] = ctx->Light.Light[ln].LinearAttenuation;
|
||||
value[2] = ctx->Light.Light[ln].QuadraticAttenuation;
|
||||
value[3] = ctx->Light.Light[ln].SpotExponent;
|
||||
return;
|
||||
case STATE_SPOT_DIRECTION:
|
||||
COPY_3V(value, ctx->Light.Light[ln].EyeDirection);
|
||||
value[3] = ctx->Light.Light[ln]._CosCutoff;
|
||||
return;
|
||||
case STATE_SPOT_CUTOFF:
|
||||
value[0] = ctx->Light.Light[ln].SpotCutoff;
|
||||
return;
|
||||
case STATE_HALF_VECTOR:
|
||||
{
|
||||
GLfloat eye_z[] = {0, 0, 1};
|
||||
|
||||
/* Compute infinite half angle vector:
|
||||
* half-vector = light_position + (0, 0, 1)
|
||||
* and then normalize. w = 0
|
||||
*
|
||||
* light.EyePosition.w should be 0 for infinite lights.
|
||||
*/
|
||||
ADD_3V(value, eye_z, ctx->Light.Light[ln].EyePosition);
|
||||
NORMALIZE_3FV(value);
|
||||
value[3] = 0;
|
||||
}
|
||||
return;
|
||||
case STATE_POSITION_NORMALIZED:
|
||||
COPY_4V(value, ctx->Light.Light[ln].EyePosition);
|
||||
NORMALIZE_3FV( value );
|
||||
return;
|
||||
default:
|
||||
_mesa_problem(ctx, "Invalid light state in fetch_state");
|
||||
return;
|
||||
}
|
||||
}
|
||||
case STATE_LIGHTMODEL_AMBIENT:
|
||||
COPY_4V(value, ctx->Light.Model.Ambient);
|
||||
return;
|
||||
case STATE_LIGHTMODEL_SCENECOLOR:
|
||||
if (state[1] == 0) {
|
||||
/* front */
|
||||
GLint i;
|
||||
for (i = 0; i < 3; i++) {
|
||||
value[i] = ctx->Light.Model.Ambient[i]
|
||||
* ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT][i]
|
||||
+ ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_EMISSION][i];
|
||||
}
|
||||
value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
|
||||
}
|
||||
else {
|
||||
/* back */
|
||||
GLint i;
|
||||
for (i = 0; i < 3; i++) {
|
||||
value[i] = ctx->Light.Model.Ambient[i]
|
||||
* ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_AMBIENT][i]
|
||||
+ ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_EMISSION][i];
|
||||
}
|
||||
value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
|
||||
}
|
||||
return;
|
||||
case STATE_LIGHTPROD:
|
||||
{
|
||||
const GLuint ln = (GLuint) state[1];
|
||||
const GLuint face = (GLuint) state[2];
|
||||
GLint i;
|
||||
ASSERT(face == 0 || face == 1);
|
||||
switch (state[3]) {
|
||||
case STATE_AMBIENT:
|
||||
for (i = 0; i < 3; i++) {
|
||||
value[i] = ctx->Light.Light[ln].Ambient[i] *
|
||||
ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT+face][i];
|
||||
}
|
||||
/* [3] = material alpha */
|
||||
value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][3];
|
||||
return;
|
||||
case STATE_DIFFUSE:
|
||||
for (i = 0; i < 3; i++) {
|
||||
value[i] = ctx->Light.Light[ln].Diffuse[i] *
|
||||
ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][i];
|
||||
}
|
||||
/* [3] = material alpha */
|
||||
value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][3];
|
||||
return;
|
||||
case STATE_SPECULAR:
|
||||
for (i = 0; i < 3; i++) {
|
||||
value[i] = ctx->Light.Light[ln].Specular[i] *
|
||||
ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SPECULAR+face][i];
|
||||
}
|
||||
/* [3] = material alpha */
|
||||
value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][3];
|
||||
return;
|
||||
default:
|
||||
_mesa_problem(ctx, "Invalid lightprod state in fetch_state");
|
||||
return;
|
||||
}
|
||||
}
|
||||
case STATE_TEXGEN:
|
||||
{
|
||||
/* state[1] is the texture unit */
|
||||
const GLuint unit = (GLuint) state[1];
|
||||
/* state[2] is the texgen attribute */
|
||||
switch (state[2]) {
|
||||
case STATE_TEXGEN_EYE_S:
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneS);
|
||||
return;
|
||||
case STATE_TEXGEN_EYE_T:
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneT);
|
||||
return;
|
||||
case STATE_TEXGEN_EYE_R:
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneR);
|
||||
return;
|
||||
case STATE_TEXGEN_EYE_Q:
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneQ);
|
||||
return;
|
||||
case STATE_TEXGEN_OBJECT_S:
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneS);
|
||||
return;
|
||||
case STATE_TEXGEN_OBJECT_T:
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneT);
|
||||
return;
|
||||
case STATE_TEXGEN_OBJECT_R:
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneR);
|
||||
return;
|
||||
case STATE_TEXGEN_OBJECT_Q:
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneQ);
|
||||
return;
|
||||
default:
|
||||
_mesa_problem(ctx, "Invalid texgen state in fetch_state");
|
||||
return;
|
||||
}
|
||||
}
|
||||
case STATE_TEXENV_COLOR:
|
||||
{
|
||||
/* state[1] is the texture unit */
|
||||
const GLuint unit = (GLuint) state[1];
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].EnvColor);
|
||||
}
|
||||
return;
|
||||
case STATE_FOG_COLOR:
|
||||
COPY_4V(value, ctx->Fog.Color);
|
||||
return;
|
||||
case STATE_FOG_PARAMS:
|
||||
value[0] = ctx->Fog.Density;
|
||||
value[1] = ctx->Fog.Start;
|
||||
value[2] = ctx->Fog.End;
|
||||
value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
|
||||
return;
|
||||
case STATE_CLIPPLANE:
|
||||
{
|
||||
const GLuint plane = (GLuint) state[1];
|
||||
COPY_4V(value, ctx->Transform.EyeUserPlane[plane]);
|
||||
}
|
||||
return;
|
||||
case STATE_POINT_SIZE:
|
||||
value[0] = ctx->Point.Size;
|
||||
value[1] = ctx->Point.MinSize;
|
||||
value[2] = ctx->Point.MaxSize;
|
||||
value[3] = ctx->Point.Threshold;
|
||||
return;
|
||||
case STATE_POINT_ATTENUATION:
|
||||
value[0] = ctx->Point.Params[0];
|
||||
value[1] = ctx->Point.Params[1];
|
||||
value[2] = ctx->Point.Params[2];
|
||||
value[3] = 1.0F;
|
||||
return;
|
||||
case STATE_MODELVIEW_MATRIX:
|
||||
case STATE_PROJECTION_MATRIX:
|
||||
case STATE_MVP_MATRIX:
|
||||
case STATE_TEXTURE_MATRIX:
|
||||
case STATE_PROGRAM_MATRIX:
|
||||
{
|
||||
/* state[0] = modelview, projection, texture, etc. */
|
||||
/* state[1] = which texture matrix or program matrix */
|
||||
/* state[2] = first row to fetch */
|
||||
/* state[3] = last row to fetch */
|
||||
/* state[4] = transpose, inverse or invtrans */
|
||||
const GLmatrix *matrix;
|
||||
const gl_state_index mat = state[0];
|
||||
const GLuint index = (GLuint) state[1];
|
||||
const GLuint firstRow = (GLuint) state[2];
|
||||
const GLuint lastRow = (GLuint) state[3];
|
||||
const gl_state_index modifier = state[4];
|
||||
const GLfloat *m;
|
||||
GLuint row, i;
|
||||
ASSERT(firstRow >= 0);
|
||||
ASSERT(firstRow < 4);
|
||||
ASSERT(lastRow >= 0);
|
||||
ASSERT(lastRow < 4);
|
||||
if (mat == STATE_MODELVIEW_MATRIX) {
|
||||
matrix = ctx->ModelviewMatrixStack.Top;
|
||||
}
|
||||
else if (mat == STATE_PROJECTION_MATRIX) {
|
||||
matrix = ctx->ProjectionMatrixStack.Top;
|
||||
}
|
||||
else if (mat == STATE_MVP_MATRIX) {
|
||||
matrix = &ctx->_ModelProjectMatrix;
|
||||
}
|
||||
else if (mat == STATE_TEXTURE_MATRIX) {
|
||||
matrix = ctx->TextureMatrixStack[index].Top;
|
||||
}
|
||||
else if (mat == STATE_PROGRAM_MATRIX) {
|
||||
matrix = ctx->ProgramMatrixStack[index].Top;
|
||||
}
|
||||
else {
|
||||
_mesa_problem(ctx, "Bad matrix name in _mesa_fetch_state()");
|
||||
return;
|
||||
}
|
||||
if (modifier == STATE_MATRIX_INVERSE ||
|
||||
modifier == STATE_MATRIX_INVTRANS) {
|
||||
/* Be sure inverse is up to date:
|
||||
*/
|
||||
_math_matrix_alloc_inv( (GLmatrix *) matrix );
|
||||
_math_matrix_analyse( (GLmatrix*) matrix );
|
||||
m = matrix->inv;
|
||||
}
|
||||
else {
|
||||
m = matrix->m;
|
||||
}
|
||||
if (modifier == STATE_MATRIX_TRANSPOSE ||
|
||||
modifier == STATE_MATRIX_INVTRANS) {
|
||||
for (i = 0, row = firstRow; row <= lastRow; row++) {
|
||||
value[i++] = m[row * 4 + 0];
|
||||
value[i++] = m[row * 4 + 1];
|
||||
value[i++] = m[row * 4 + 2];
|
||||
value[i++] = m[row * 4 + 3];
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0, row = firstRow; row <= lastRow; row++) {
|
||||
value[i++] = m[row + 0];
|
||||
value[i++] = m[row + 4];
|
||||
value[i++] = m[row + 8];
|
||||
value[i++] = m[row + 12];
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
case STATE_DEPTH_RANGE:
|
||||
value[0] = ctx->Viewport.Near; /* near */
|
||||
value[1] = ctx->Viewport.Far; /* far */
|
||||
value[2] = ctx->Viewport.Far - ctx->Viewport.Near; /* far - near */
|
||||
value[3] = 0;
|
||||
return;
|
||||
case STATE_FRAGMENT_PROGRAM:
|
||||
{
|
||||
/* state[1] = {STATE_ENV, STATE_LOCAL} */
|
||||
/* state[2] = parameter index */
|
||||
const int idx = (int) state[2];
|
||||
switch (state[1]) {
|
||||
case STATE_ENV:
|
||||
COPY_4V(value, ctx->FragmentProgram.Parameters[idx]);
|
||||
break;
|
||||
case STATE_LOCAL:
|
||||
COPY_4V(value, ctx->FragmentProgram.Current->Base.LocalParams[idx]);
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
case STATE_VERTEX_PROGRAM:
|
||||
{
|
||||
/* state[1] = {STATE_ENV, STATE_LOCAL} */
|
||||
/* state[2] = parameter index */
|
||||
const int idx = (int) state[2];
|
||||
switch (state[1]) {
|
||||
case STATE_ENV:
|
||||
COPY_4V(value, ctx->VertexProgram.Parameters[idx]);
|
||||
break;
|
||||
case STATE_LOCAL:
|
||||
COPY_4V(value, ctx->VertexProgram.Current->Base.LocalParams[idx]);
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
case STATE_NORMAL_SCALE:
|
||||
ASSIGN_4V(value, ctx->_ModelViewInvScale, 0, 0, 1);
|
||||
return;
|
||||
|
||||
case STATE_INTERNAL:
|
||||
switch (state[1]) {
|
||||
case STATE_NORMAL_SCALE:
|
||||
ASSIGN_4V(value, ctx->_ModelViewInvScale, 0, 0, 1);
|
||||
return;
|
||||
case STATE_TEXRECT_SCALE:
|
||||
{
|
||||
const int unit = (int) state[2];
|
||||
const struct gl_texture_object *texObj
|
||||
= ctx->Texture.Unit[unit]._Current;
|
||||
if (texObj) {
|
||||
struct gl_texture_image *texImage = texObj->Image[0][0];
|
||||
ASSIGN_4V(value, 1.0 / texImage->Width,
|
||||
1.0 / texImage->Height,
|
||||
0.0, 1.0);
|
||||
}
|
||||
}
|
||||
return;
|
||||
case STATE_FOG_PARAMS_OPTIMIZED:
|
||||
/* for simpler per-vertex/pixel fog calcs. POW (for EXP/EXP2 fog)
|
||||
* might be more expensive than EX2 on some hw, plus it needs
|
||||
* another constant (e) anyway. Linear fog can now be done with a
|
||||
* single MAD.
|
||||
* linear: fogcoord * -1/(end-start) + end/(end-start)
|
||||
* exp: 2^-(density/ln(2) * fogcoord)
|
||||
* exp2: 2^-((density/(ln(2)^2) * fogcoord)^2)
|
||||
*/
|
||||
value[0] = -1.0F / (ctx->Fog.End - ctx->Fog.Start);
|
||||
value[1] = ctx->Fog.End / (ctx->Fog.End - ctx->Fog.Start);
|
||||
value[2] = ctx->Fog.Density * ONE_DIV_LN2;
|
||||
value[3] = ctx->Fog.Density * ONE_DIV_SQRT_LN2;
|
||||
return;
|
||||
case STATE_SPOT_DIR_NORMALIZED: {
|
||||
/* here, state[2] is the light number */
|
||||
/* pre-normalize spot dir */
|
||||
const GLuint ln = (GLuint) state[2];
|
||||
COPY_3V(value, ctx->Light.Light[ln].EyeDirection);
|
||||
NORMALIZE_3FV(value);
|
||||
value[3] = ctx->Light.Light[ln]._CosCutoff;
|
||||
return;
|
||||
}
|
||||
default:
|
||||
/* unknown state indexes are silently ignored
|
||||
* should be handled by the driver.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
_mesa_problem(ctx, "Invalid state in _mesa_fetch_state");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a bitmask of the Mesa state flags (_NEW_* values) which would
|
||||
* indicate that the given context state may have changed.
|
||||
* The bitmask is used during validation to determine if we need to update
|
||||
* vertex/fragment program parameters (like "state.material.color") when
|
||||
* some GL state has changed.
|
||||
*/
|
||||
GLbitfield
|
||||
_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
|
||||
{
|
||||
switch (state[0]) {
|
||||
case STATE_MATERIAL:
|
||||
case STATE_LIGHT:
|
||||
case STATE_LIGHTMODEL_AMBIENT:
|
||||
case STATE_LIGHTMODEL_SCENECOLOR:
|
||||
case STATE_LIGHTPROD:
|
||||
return _NEW_LIGHT;
|
||||
|
||||
case STATE_TEXGEN:
|
||||
case STATE_TEXENV_COLOR:
|
||||
return _NEW_TEXTURE;
|
||||
|
||||
case STATE_FOG_COLOR:
|
||||
case STATE_FOG_PARAMS:
|
||||
return _NEW_FOG;
|
||||
|
||||
case STATE_CLIPPLANE:
|
||||
return _NEW_TRANSFORM;
|
||||
|
||||
case STATE_POINT_SIZE:
|
||||
case STATE_POINT_ATTENUATION:
|
||||
return _NEW_POINT;
|
||||
|
||||
case STATE_MODELVIEW_MATRIX:
|
||||
return _NEW_MODELVIEW;
|
||||
case STATE_PROJECTION_MATRIX:
|
||||
return _NEW_PROJECTION;
|
||||
case STATE_MVP_MATRIX:
|
||||
return _NEW_MODELVIEW | _NEW_PROJECTION;
|
||||
case STATE_TEXTURE_MATRIX:
|
||||
return _NEW_TEXTURE_MATRIX;
|
||||
case STATE_PROGRAM_MATRIX:
|
||||
return _NEW_TRACK_MATRIX;
|
||||
|
||||
case STATE_DEPTH_RANGE:
|
||||
return _NEW_VIEWPORT;
|
||||
|
||||
case STATE_FRAGMENT_PROGRAM:
|
||||
case STATE_VERTEX_PROGRAM:
|
||||
return _NEW_PROGRAM;
|
||||
|
||||
case STATE_NORMAL_SCALE:
|
||||
return _NEW_MODELVIEW;
|
||||
|
||||
case STATE_INTERNAL:
|
||||
switch (state[1]) {
|
||||
case STATE_TEXRECT_SCALE:
|
||||
return _NEW_TEXTURE;
|
||||
default:
|
||||
/* unknown state indexes are silently ignored and
|
||||
* no flag set, since it is handled by the driver.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
default:
|
||||
_mesa_problem(NULL, "unexpected state[0] in make_state_flags()");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
append(char *dst, const char *src)
|
||||
{
|
||||
while (*dst)
|
||||
dst++;
|
||||
while (*src)
|
||||
*dst++ = *src++;
|
||||
*dst = 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
append_token(char *dst, gl_state_index k)
|
||||
{
|
||||
switch (k) {
|
||||
case STATE_MATERIAL:
|
||||
append(dst, "material");
|
||||
break;
|
||||
case STATE_LIGHT:
|
||||
append(dst, "light");
|
||||
break;
|
||||
case STATE_LIGHTMODEL_AMBIENT:
|
||||
append(dst, "lightmodel.ambient");
|
||||
break;
|
||||
case STATE_LIGHTMODEL_SCENECOLOR:
|
||||
break;
|
||||
case STATE_LIGHTPROD:
|
||||
append(dst, "lightprod");
|
||||
break;
|
||||
case STATE_TEXGEN:
|
||||
append(dst, "texgen");
|
||||
break;
|
||||
case STATE_FOG_COLOR:
|
||||
append(dst, "fog.color");
|
||||
break;
|
||||
case STATE_FOG_PARAMS:
|
||||
append(dst, "fog.params");
|
||||
break;
|
||||
case STATE_CLIPPLANE:
|
||||
append(dst, "clip");
|
||||
break;
|
||||
case STATE_POINT_SIZE:
|
||||
append(dst, "point.size");
|
||||
break;
|
||||
case STATE_POINT_ATTENUATION:
|
||||
append(dst, "point.attenuation");
|
||||
break;
|
||||
case STATE_MODELVIEW_MATRIX:
|
||||
append(dst, "matrix.modelview");
|
||||
break;
|
||||
case STATE_PROJECTION_MATRIX:
|
||||
append(dst, "matrix.projection");
|
||||
break;
|
||||
case STATE_MVP_MATRIX:
|
||||
append(dst, "matrix.mvp");
|
||||
break;
|
||||
case STATE_TEXTURE_MATRIX:
|
||||
append(dst, "matrix.texture");
|
||||
break;
|
||||
case STATE_PROGRAM_MATRIX:
|
||||
append(dst, "matrix.program");
|
||||
break;
|
||||
case STATE_MATRIX_INVERSE:
|
||||
append(dst, ".inverse");
|
||||
break;
|
||||
case STATE_MATRIX_TRANSPOSE:
|
||||
append(dst, ".transpose");
|
||||
break;
|
||||
case STATE_MATRIX_INVTRANS:
|
||||
append(dst, ".invtrans");
|
||||
break;
|
||||
case STATE_AMBIENT:
|
||||
append(dst, ".ambient");
|
||||
break;
|
||||
case STATE_DIFFUSE:
|
||||
append(dst, ".diffuse");
|
||||
break;
|
||||
case STATE_SPECULAR:
|
||||
append(dst, ".specular");
|
||||
break;
|
||||
case STATE_EMISSION:
|
||||
append(dst, ".emission");
|
||||
break;
|
||||
case STATE_SHININESS:
|
||||
append(dst, "lshininess");
|
||||
break;
|
||||
case STATE_HALF_VECTOR:
|
||||
append(dst, ".half");
|
||||
break;
|
||||
case STATE_POSITION:
|
||||
append(dst, ".position");
|
||||
break;
|
||||
case STATE_ATTENUATION:
|
||||
append(dst, ".attenuation");
|
||||
break;
|
||||
case STATE_SPOT_DIRECTION:
|
||||
append(dst, ".spot.direction");
|
||||
break;
|
||||
case STATE_SPOT_CUTOFF:
|
||||
append(dst, ".spot.cutoff");
|
||||
break;
|
||||
case STATE_TEXGEN_EYE_S:
|
||||
append(dst, "eye.s");
|
||||
break;
|
||||
case STATE_TEXGEN_EYE_T:
|
||||
append(dst, "eye.t");
|
||||
break;
|
||||
case STATE_TEXGEN_EYE_R:
|
||||
append(dst, "eye.r");
|
||||
break;
|
||||
case STATE_TEXGEN_EYE_Q:
|
||||
append(dst, "eye.q");
|
||||
break;
|
||||
case STATE_TEXGEN_OBJECT_S:
|
||||
append(dst, "object.s");
|
||||
break;
|
||||
case STATE_TEXGEN_OBJECT_T:
|
||||
append(dst, "object.t");
|
||||
break;
|
||||
case STATE_TEXGEN_OBJECT_R:
|
||||
append(dst, "object.r");
|
||||
break;
|
||||
case STATE_TEXGEN_OBJECT_Q:
|
||||
append(dst, "object.q");
|
||||
break;
|
||||
case STATE_TEXENV_COLOR:
|
||||
append(dst, "texenv");
|
||||
break;
|
||||
case STATE_DEPTH_RANGE:
|
||||
append(dst, "depth.range");
|
||||
break;
|
||||
case STATE_VERTEX_PROGRAM:
|
||||
case STATE_FRAGMENT_PROGRAM:
|
||||
break;
|
||||
case STATE_ENV:
|
||||
append(dst, "env");
|
||||
break;
|
||||
case STATE_LOCAL:
|
||||
append(dst, "local");
|
||||
break;
|
||||
case STATE_NORMAL_SCALE:
|
||||
append(dst, "normalScale");
|
||||
break;
|
||||
case STATE_INTERNAL:
|
||||
case STATE_POSITION_NORMALIZED:
|
||||
append(dst, "(internal)");
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
append_face(char *dst, GLint face)
|
||||
{
|
||||
if (face == 0)
|
||||
append(dst, "front.");
|
||||
else
|
||||
append(dst, "back.");
|
||||
}
|
||||
|
||||
static void
|
||||
append_index(char *dst, GLint index)
|
||||
{
|
||||
char s[20];
|
||||
_mesa_sprintf(s, "[%d]", index);
|
||||
append(dst, s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string from the given state vector.
|
||||
* For example, return "state.matrix.texture[2].inverse".
|
||||
* Use _mesa_free() to deallocate the string.
|
||||
*/
|
||||
const char *
|
||||
_mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
|
||||
{
|
||||
char str[1000] = "";
|
||||
char tmp[30];
|
||||
|
||||
append(str, "state.");
|
||||
append_token(str, (gl_state_index) state[0]);
|
||||
|
||||
switch (state[0]) {
|
||||
case STATE_MATERIAL:
|
||||
append_face(str, state[1]);
|
||||
append_token(str, (gl_state_index) state[2]);
|
||||
break;
|
||||
case STATE_LIGHT:
|
||||
append_index(str, state[1]); /* light number [i]. */
|
||||
append_token(str, (gl_state_index) state[2]); /* coefficients */
|
||||
break;
|
||||
case STATE_LIGHTMODEL_AMBIENT:
|
||||
append(str, "lightmodel.ambient");
|
||||
break;
|
||||
case STATE_LIGHTMODEL_SCENECOLOR:
|
||||
if (state[1] == 0) {
|
||||
append(str, "lightmodel.front.scenecolor");
|
||||
}
|
||||
else {
|
||||
append(str, "lightmodel.back.scenecolor");
|
||||
}
|
||||
break;
|
||||
case STATE_LIGHTPROD:
|
||||
append_index(str, state[1]); /* light number [i]. */
|
||||
append_face(str, state[2]);
|
||||
append_token(str, (gl_state_index) state[3]);
|
||||
break;
|
||||
case STATE_TEXGEN:
|
||||
append_index(str, state[1]); /* tex unit [i] */
|
||||
append_token(str, (gl_state_index) state[2]); /* plane coef */
|
||||
break;
|
||||
case STATE_TEXENV_COLOR:
|
||||
append_index(str, state[1]); /* tex unit [i] */
|
||||
append(str, "color");
|
||||
break;
|
||||
case STATE_CLIPPLANE:
|
||||
append_index(str, state[1]); /* plane [i] */
|
||||
append(str, ".plane");
|
||||
break;
|
||||
case STATE_MODELVIEW_MATRIX:
|
||||
case STATE_PROJECTION_MATRIX:
|
||||
case STATE_MVP_MATRIX:
|
||||
case STATE_TEXTURE_MATRIX:
|
||||
case STATE_PROGRAM_MATRIX:
|
||||
{
|
||||
/* state[0] = modelview, projection, texture, etc. */
|
||||
/* state[1] = which texture matrix or program matrix */
|
||||
/* state[2] = first row to fetch */
|
||||
/* state[3] = last row to fetch */
|
||||
/* state[4] = transpose, inverse or invtrans */
|
||||
const gl_state_index mat = (gl_state_index) state[0];
|
||||
const GLuint index = (GLuint) state[1];
|
||||
const GLuint firstRow = (GLuint) state[2];
|
||||
const GLuint lastRow = (GLuint) state[3];
|
||||
const gl_state_index modifier = (gl_state_index) state[4];
|
||||
if (index ||
|
||||
mat == STATE_TEXTURE_MATRIX ||
|
||||
mat == STATE_PROGRAM_MATRIX)
|
||||
append_index(str, index);
|
||||
if (modifier)
|
||||
append_token(str, modifier);
|
||||
if (firstRow == lastRow)
|
||||
_mesa_sprintf(tmp, ".row[%d]", firstRow);
|
||||
else
|
||||
_mesa_sprintf(tmp, ".row[%d..%d]", firstRow, lastRow);
|
||||
append(str, tmp);
|
||||
}
|
||||
break;
|
||||
case STATE_POINT_SIZE:
|
||||
break;
|
||||
case STATE_POINT_ATTENUATION:
|
||||
break;
|
||||
case STATE_FOG_PARAMS:
|
||||
break;
|
||||
case STATE_FOG_COLOR:
|
||||
break;
|
||||
case STATE_DEPTH_RANGE:
|
||||
break;
|
||||
case STATE_FRAGMENT_PROGRAM:
|
||||
case STATE_VERTEX_PROGRAM:
|
||||
/* state[1] = {STATE_ENV, STATE_LOCAL} */
|
||||
/* state[2] = parameter index */
|
||||
append_token(str, (gl_state_index) state[1]);
|
||||
append_index(str, state[2]);
|
||||
break;
|
||||
case STATE_INTERNAL:
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(NULL, "Invalid state in _mesa_program_state_string");
|
||||
break;
|
||||
}
|
||||
|
||||
return _mesa_strdup(str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loop over all the parameters in a parameter list. If the parameter
|
||||
* is a GL state reference, look up the current value of that state
|
||||
* variable and put it into the parameter's Value[4] array.
|
||||
* This would be called at glBegin time when using a fragment program.
|
||||
*/
|
||||
void
|
||||
_mesa_load_state_parameters(GLcontext *ctx,
|
||||
struct gl_program_parameter_list *paramList)
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
if (!paramList)
|
||||
return;
|
||||
|
||||
for (i = 0; i < paramList->NumParameters; i++) {
|
||||
if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) {
|
||||
_mesa_fetch_state(ctx,
|
||||
(gl_state_index *) paramList->Parameters[i].StateIndexes,
|
||||
paramList->ParameterValues[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PROG_STATEVARS_H
|
||||
#define PROG_STATEVARS_H
|
||||
|
||||
#include "mtypes.h"
|
||||
|
||||
|
||||
/**
|
||||
* Number of STATE_* values we need to address any GL state.
|
||||
* Used to dimension arrays.
|
||||
*/
|
||||
#define STATE_LENGTH 5
|
||||
|
||||
|
||||
/**
|
||||
* Used for describing GL state referenced from inside ARB vertex and
|
||||
* fragment programs.
|
||||
* A string such as "state.light[0].ambient" gets translated into a
|
||||
* sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
|
||||
*
|
||||
* For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should
|
||||
* always be the array index.
|
||||
*/
|
||||
typedef enum gl_state_index_ {
|
||||
STATE_MATERIAL = 100, /* start at 100 so small ints are seen as ints */
|
||||
|
||||
STATE_LIGHT,
|
||||
STATE_LIGHTMODEL_AMBIENT,
|
||||
STATE_LIGHTMODEL_SCENECOLOR,
|
||||
STATE_LIGHTPROD,
|
||||
|
||||
STATE_TEXGEN,
|
||||
|
||||
STATE_FOG_COLOR,
|
||||
STATE_FOG_PARAMS,
|
||||
|
||||
STATE_CLIPPLANE,
|
||||
|
||||
STATE_POINT_SIZE,
|
||||
STATE_POINT_ATTENUATION,
|
||||
|
||||
STATE_MODELVIEW_MATRIX,
|
||||
STATE_PROJECTION_MATRIX,
|
||||
STATE_MVP_MATRIX,
|
||||
STATE_TEXTURE_MATRIX,
|
||||
STATE_PROGRAM_MATRIX,
|
||||
STATE_MATRIX_INVERSE,
|
||||
STATE_MATRIX_TRANSPOSE,
|
||||
STATE_MATRIX_INVTRANS,
|
||||
|
||||
STATE_AMBIENT,
|
||||
STATE_DIFFUSE,
|
||||
STATE_SPECULAR,
|
||||
STATE_EMISSION,
|
||||
STATE_SHININESS,
|
||||
STATE_HALF_VECTOR,
|
||||
|
||||
STATE_POSITION,
|
||||
STATE_ATTENUATION,
|
||||
STATE_SPOT_DIRECTION,
|
||||
STATE_SPOT_CUTOFF,
|
||||
|
||||
STATE_TEXGEN_EYE_S,
|
||||
STATE_TEXGEN_EYE_T,
|
||||
STATE_TEXGEN_EYE_R,
|
||||
STATE_TEXGEN_EYE_Q,
|
||||
STATE_TEXGEN_OBJECT_S,
|
||||
STATE_TEXGEN_OBJECT_T,
|
||||
STATE_TEXGEN_OBJECT_R,
|
||||
STATE_TEXGEN_OBJECT_Q,
|
||||
|
||||
STATE_TEXENV_COLOR,
|
||||
|
||||
STATE_DEPTH_RANGE,
|
||||
|
||||
STATE_VERTEX_PROGRAM,
|
||||
STATE_FRAGMENT_PROGRAM,
|
||||
|
||||
STATE_ENV,
|
||||
STATE_LOCAL,
|
||||
|
||||
STATE_INTERNAL, /* Mesa additions */
|
||||
STATE_NORMAL_SCALE,
|
||||
STATE_TEXRECT_SCALE,
|
||||
STATE_POSITION_NORMALIZED, /* normalized light position */
|
||||
STATE_FOG_PARAMS_OPTIMIZED, /* for faster fog calc */
|
||||
STATE_SPOT_DIR_NORMALIZED, /* pre-normalized spot dir */
|
||||
STATE_INTERNAL_DRIVER /* first available state index for drivers (must be last) */
|
||||
} gl_state_index;
|
||||
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_load_state_parameters(GLcontext *ctx,
|
||||
struct gl_program_parameter_list *paramList);
|
||||
|
||||
|
||||
extern GLbitfield
|
||||
_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]);
|
||||
|
||||
|
||||
extern const char *
|
||||
_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]);
|
||||
|
||||
|
||||
#endif /* PROG_STATEVARS_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -43,37 +43,6 @@
|
||||
#include "mtypes.h"
|
||||
|
||||
|
||||
/* for GL_ARB_v_p and GL_ARB_f_p SWZ instruction */
|
||||
#define SWIZZLE_X 0
|
||||
#define SWIZZLE_Y 1
|
||||
#define SWIZZLE_Z 2
|
||||
#define SWIZZLE_W 3
|
||||
#define SWIZZLE_ZERO 4 /* keep these values together: KW */
|
||||
#define SWIZZLE_ONE 5 /* keep these values together: KW */
|
||||
|
||||
#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9))
|
||||
#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3)
|
||||
#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7)
|
||||
#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1)
|
||||
|
||||
|
||||
#define WRITEMASK_X 0x1
|
||||
#define WRITEMASK_Y 0x2
|
||||
#define WRITEMASK_XY 0x3
|
||||
#define WRITEMASK_Z 0x4
|
||||
#define WRITEMASK_XZ 0x5
|
||||
#define WRITEMASK_YZ 0x6
|
||||
#define WRITEMASK_XYZ 0x7
|
||||
#define WRITEMASK_W 0x8
|
||||
#define WRITEMASK_XW 0x9
|
||||
#define WRITEMASK_YW 0xa
|
||||
#define WRITEMASK_XYW 0xb
|
||||
#define WRITEMASK_ZW 0xc
|
||||
#define WRITEMASK_XZW 0xd
|
||||
#define WRITEMASK_YZW 0xe
|
||||
#define WRITEMASK_XYZW 0xf
|
||||
|
||||
|
||||
extern struct gl_program _mesa_DummyProgram;
|
||||
|
||||
|
||||
@@ -114,172 +83,9 @@ _mesa_delete_program(GLcontext *ctx, struct gl_program *prog);
|
||||
extern struct gl_program *
|
||||
_mesa_lookup_program(GLcontext *ctx, GLuint id);
|
||||
|
||||
extern struct prog_instruction *
|
||||
_mesa_alloc_instructions(GLuint numInst);
|
||||
|
||||
extern struct prog_instruction *
|
||||
_mesa_realloc_instructions(struct prog_instruction *oldInst,
|
||||
GLuint numOldInst, GLuint numNewInst);
|
||||
|
||||
|
||||
/**
|
||||
* Used for describing GL state referenced from inside ARB vertex and
|
||||
* fragment programs.
|
||||
* A string such as "state.light[0].ambient" gets translated into a
|
||||
* sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
|
||||
*/
|
||||
enum state_index {
|
||||
STATE_MATERIAL,
|
||||
|
||||
STATE_LIGHT,
|
||||
STATE_LIGHTMODEL_AMBIENT,
|
||||
STATE_LIGHTMODEL_SCENECOLOR,
|
||||
STATE_LIGHTPROD,
|
||||
|
||||
STATE_TEXGEN,
|
||||
|
||||
STATE_FOG_COLOR,
|
||||
STATE_FOG_PARAMS,
|
||||
|
||||
STATE_CLIPPLANE,
|
||||
|
||||
STATE_POINT_SIZE,
|
||||
STATE_POINT_ATTENUATION,
|
||||
|
||||
STATE_MATRIX,
|
||||
STATE_MODELVIEW,
|
||||
STATE_PROJECTION,
|
||||
STATE_MVP,
|
||||
STATE_TEXTURE,
|
||||
STATE_PROGRAM,
|
||||
STATE_MATRIX_INVERSE,
|
||||
STATE_MATRIX_TRANSPOSE,
|
||||
STATE_MATRIX_INVTRANS,
|
||||
|
||||
STATE_AMBIENT,
|
||||
STATE_DIFFUSE,
|
||||
STATE_SPECULAR,
|
||||
STATE_EMISSION,
|
||||
STATE_SHININESS,
|
||||
STATE_HALF,
|
||||
|
||||
STATE_POSITION,
|
||||
STATE_ATTENUATION,
|
||||
STATE_SPOT_DIRECTION,
|
||||
|
||||
STATE_TEXGEN_EYE_S,
|
||||
STATE_TEXGEN_EYE_T,
|
||||
STATE_TEXGEN_EYE_R,
|
||||
STATE_TEXGEN_EYE_Q,
|
||||
STATE_TEXGEN_OBJECT_S,
|
||||
STATE_TEXGEN_OBJECT_T,
|
||||
STATE_TEXGEN_OBJECT_R,
|
||||
STATE_TEXGEN_OBJECT_Q,
|
||||
|
||||
STATE_TEXENV_COLOR,
|
||||
|
||||
STATE_DEPTH_RANGE,
|
||||
|
||||
STATE_VERTEX_PROGRAM,
|
||||
STATE_FRAGMENT_PROGRAM,
|
||||
|
||||
STATE_ENV,
|
||||
STATE_LOCAL,
|
||||
|
||||
STATE_INTERNAL, /* Mesa additions */
|
||||
STATE_NORMAL_SCALE,
|
||||
STATE_TEXRECT_SCALE,
|
||||
STATE_POSITION_NORMALIZED, /* normalized light position */
|
||||
STATE_INTERNAL_DRIVER /* first available state index for drivers (must be last) */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Named program parameters
|
||||
* Used for NV_fragment_program "DEFINE"d constants and "DECLARE"d parameters,
|
||||
* and ARB_fragment_program global state references. For the later, Name
|
||||
* might be "state.light[0].diffuse", for example.
|
||||
*/
|
||||
struct gl_program_parameter
|
||||
{
|
||||
const char *Name; /**< Null-terminated string */
|
||||
enum register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
|
||||
enum state_index StateIndexes[6]; /**< Global state reference */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A list of the above program_parameter instances.
|
||||
*/
|
||||
struct gl_program_parameter_list
|
||||
{
|
||||
GLuint Size; /**< allocated size of Parameters, ParameterValues */
|
||||
GLuint NumParameters; /**< number of parameters in arrays */
|
||||
struct gl_program_parameter *Parameters; /**< Array [Size] */
|
||||
GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */
|
||||
GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes
|
||||
might invalidate ParameterValues[] */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Program parameter functions
|
||||
*/
|
||||
|
||||
extern struct gl_program_parameter_list *
|
||||
_mesa_new_parameter_list(void);
|
||||
|
||||
extern void
|
||||
_mesa_free_parameter_list(struct gl_program_parameter_list *paramList);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
|
||||
const char *name, const GLfloat values[4]);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_named_constant(struct gl_program_parameter_list *paramList,
|
||||
const char *name, const GLfloat values[4],
|
||||
GLuint size);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
|
||||
const GLfloat values[4], GLuint size);
|
||||
|
||||
extern GLint
|
||||
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
|
||||
const GLint *stateTokens);
|
||||
|
||||
extern GLfloat *
|
||||
_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
|
||||
GLsizei nameLen, const char *name);
|
||||
|
||||
extern GLint
|
||||
_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
|
||||
GLsizei nameLen, const char *name);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *paramList,
|
||||
const GLfloat v[], GLsizei vSize,
|
||||
GLuint *posOut, GLuint *swizzleOut);
|
||||
|
||||
extern void
|
||||
_mesa_load_state_parameters(GLcontext *ctx,
|
||||
struct gl_program_parameter_list *paramList);
|
||||
|
||||
extern void
|
||||
_mesa_print_instruction(const struct prog_instruction *inst);
|
||||
|
||||
void
|
||||
_mesa_print_alu_instruction(const struct prog_instruction *inst,
|
||||
const char *opcode_string,
|
||||
GLuint numRegs);
|
||||
|
||||
extern void
|
||||
_mesa_print_program(const struct gl_program *prog);
|
||||
|
||||
extern void
|
||||
_mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog);
|
||||
extern struct gl_program *
|
||||
_mesa_clone_program(GLcontext *ctx, const struct gl_program *prog);
|
||||
|
||||
|
||||
/*
|
||||
@@ -297,17 +103,4 @@ _mesa_GenPrograms(GLsizei n, GLuint *ids);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* GL_MESA_program_debug
|
||||
*/
|
||||
|
||||
extern void
|
||||
_mesa_ProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback,
|
||||
GLvoid *data);
|
||||
|
||||
extern void
|
||||
_mesa_GetProgramRegisterfvMESA(GLenum target, GLsizei len,
|
||||
const GLubyte *registerName, GLfloat *v);
|
||||
|
||||
|
||||
#endif /* PROGRAM_H */
|
||||
|
||||
@@ -1,360 +0,0 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file prog_instruction.h
|
||||
*
|
||||
* Private vertex program types and constants only used by files
|
||||
* related to vertex programs.
|
||||
*
|
||||
* \author Brian Paul
|
||||
* \author Keith Whitwell
|
||||
* \author Ian Romanick <idr@us.ibm.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PROG_INSTRUCTION_H
|
||||
#define PROG_INSTRUCTION_H
|
||||
|
||||
/**
|
||||
* Condition codes for GL_NV_fragment_program
|
||||
*/
|
||||
/*@{*/
|
||||
#define COND_GT 1 /* greater than zero */
|
||||
#define COND_EQ 2 /* equal to zero */
|
||||
#define COND_LT 3 /* less than zero */
|
||||
#define COND_UN 4 /* unordered (NaN) */
|
||||
#define COND_GE 5 /* greater then or equal to zero */
|
||||
#define COND_LE 6 /* less then or equal to zero */
|
||||
#define COND_NE 7 /* not equal to zero */
|
||||
#define COND_TR 8 /* always true */
|
||||
#define COND_FL 9 /* always false */
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Instruction precision for GL_NV_fragment_program
|
||||
*/
|
||||
/*@{*/
|
||||
#define FLOAT32 0x1
|
||||
#define FLOAT16 0x2
|
||||
#define FIXED12 0x4
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Saturation modes when storing values.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SATURATE_OFF 0
|
||||
#define SATURATE_ZERO_ONE 1
|
||||
#define SATURATE_PLUS_MINUS_ONE 2
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Per-component negation masks
|
||||
*/
|
||||
/*@{*/
|
||||
#define NEGATE_X 0x1
|
||||
#define NEGATE_Y 0x2
|
||||
#define NEGATE_Z 0x4
|
||||
#define NEGATE_W 0x8
|
||||
#define NEGATE_XYZW 0xf
|
||||
#define NEGATE_NONE 0x0
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Program instruction opcodes, for both vertex and fragment programs.
|
||||
* \note changes to this opcode list must be reflected in t_vb_arbprogram.c
|
||||
*/
|
||||
/* ARB_vp ARB_fp NV_vp NV_fp */
|
||||
enum prog_opcode { /*---------------------------------*/
|
||||
OPCODE_ABS, /* X X 1.1 */
|
||||
OPCODE_ADD, /* X X X X */
|
||||
OPCODE_ARA, /* 2 */
|
||||
OPCODE_ARL, /* X X */
|
||||
OPCODE_ARL_NV, /* 2 */
|
||||
OPCODE_ARR, /* 2 */
|
||||
OPCODE_BRA, /* 2 */
|
||||
OPCODE_CAL, /* 2 2 */
|
||||
OPCODE_CMP, /* X */
|
||||
OPCODE_COS, /* X 2 X */
|
||||
OPCODE_DDX, /* X */
|
||||
OPCODE_DDY, /* X */
|
||||
OPCODE_DP3, /* X X X X */
|
||||
OPCODE_DP4, /* X X X X */
|
||||
OPCODE_DPH, /* X X 1.1 */
|
||||
OPCODE_DST, /* X X X X */
|
||||
OPCODE_END, /* X X X X */
|
||||
OPCODE_EX2, /* X X 2 X */
|
||||
OPCODE_EXP, /* X X */
|
||||
OPCODE_FLR, /* X X 2 X */
|
||||
OPCODE_FRC, /* X X 2 X */
|
||||
OPCODE_KIL, /* X */
|
||||
OPCODE_KIL_NV, /* X */
|
||||
OPCODE_LG2, /* X X 2 X */
|
||||
OPCODE_LIT, /* X X X X */
|
||||
OPCODE_LOG, /* X X */
|
||||
OPCODE_LRP, /* X X */
|
||||
OPCODE_MAD, /* X X X X */
|
||||
OPCODE_MAX, /* X X X X */
|
||||
OPCODE_MIN, /* X X X X */
|
||||
OPCODE_MOV, /* X X X X */
|
||||
OPCODE_MUL, /* X X X X */
|
||||
OPCODE_PK2H, /* X */
|
||||
OPCODE_PK2US, /* X */
|
||||
OPCODE_PK4B, /* X */
|
||||
OPCODE_PK4UB, /* X */
|
||||
OPCODE_POW, /* X X X */
|
||||
OPCODE_POPA, /* 3 */
|
||||
OPCODE_PRINT, /* X X */
|
||||
OPCODE_PUSHA, /* 3 */
|
||||
OPCODE_RCC, /* 1.1 */
|
||||
OPCODE_RCP, /* X X X X */
|
||||
OPCODE_RET, /* 2 2 */
|
||||
OPCODE_RFL, /* X X */
|
||||
OPCODE_RSQ, /* X X X X */
|
||||
OPCODE_SCS, /* X */
|
||||
OPCODE_SEQ, /* 2 X */
|
||||
OPCODE_SFL, /* 2 X */
|
||||
OPCODE_SGE, /* X X X X */
|
||||
OPCODE_SGT, /* 2 X */
|
||||
OPCODE_SIN, /* X 2 X */
|
||||
OPCODE_SLE, /* 2 X */
|
||||
OPCODE_SLT, /* X X X X */
|
||||
OPCODE_SNE, /* 2 X */
|
||||
OPCODE_SSG, /* 2 */
|
||||
OPCODE_STR, /* 2 X */
|
||||
OPCODE_SUB, /* X X 1.1 X */
|
||||
OPCODE_SWZ, /* X X */
|
||||
OPCODE_TEX, /* X 3 X */
|
||||
OPCODE_TXB, /* X 3 */
|
||||
OPCODE_TXD, /* X */
|
||||
OPCODE_TXL, /* 3 2 */
|
||||
OPCODE_TXP, /* X */
|
||||
OPCODE_TXP_NV, /* 3 X */
|
||||
OPCODE_UP2H, /* X */
|
||||
OPCODE_UP2US, /* X */
|
||||
OPCODE_UP4B, /* X */
|
||||
OPCODE_UP4UB, /* X */
|
||||
OPCODE_X2D, /* X */
|
||||
OPCODE_XPD, /* X X */
|
||||
MAX_OPCODE
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Instruction source register.
|
||||
*/
|
||||
struct prog_src_register
|
||||
{
|
||||
GLuint File:4; /**< One of the PROGRAM_* register file values. */
|
||||
GLint Index:9; /**< May be negative for relative addressing. */
|
||||
GLuint Swizzle:12;
|
||||
GLuint RelAddr:1;
|
||||
|
||||
/**
|
||||
* \name Source register "sign" control.
|
||||
*
|
||||
* The ARB and NV extensions allow varrying degrees of control over the
|
||||
* sign of the source vector components. These values allow enough control
|
||||
* for all flavors of the extensions.
|
||||
*/
|
||||
/*@{*/
|
||||
/**
|
||||
* Per-component negation for the SWZ instruction. For non-SWZ
|
||||
* instructions the only possible values are NEGATE_XYZW and NEGATE_NONE.
|
||||
*
|
||||
* \since
|
||||
* ARB_vertex_program, ARB_fragment_program
|
||||
*/
|
||||
GLuint NegateBase:4;
|
||||
|
||||
/**
|
||||
* Take the component-wise absolute value.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
|
||||
* NV_vertex_program2_option.
|
||||
*/
|
||||
GLuint Abs:1;
|
||||
|
||||
/**
|
||||
* Post-absolute value negation (all components).
|
||||
*/
|
||||
GLuint NegateAbs:1;
|
||||
/*@}*/
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Instruction destination register.
|
||||
*/
|
||||
struct prog_dst_register
|
||||
{
|
||||
/**
|
||||
* One of the PROGRAM_* register file values.
|
||||
*/
|
||||
GLuint File:4;
|
||||
|
||||
GLuint Index:8;
|
||||
GLuint WriteMask:4;
|
||||
|
||||
/**
|
||||
* \name Conditional destination update control.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
|
||||
* NV_vertex_program2_option.
|
||||
*/
|
||||
/*@{*/
|
||||
/**
|
||||
* Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT,
|
||||
* NE, TR, or UN). Destination update is enabled if the matching
|
||||
* (swizzled) condition code value passes. When a conditional update mask
|
||||
* is not specified, this will be \c COND_TR.
|
||||
*/
|
||||
GLuint CondMask:4;
|
||||
|
||||
/**
|
||||
* Condition code swizzle value.
|
||||
*/
|
||||
GLuint CondSwizzle:12;
|
||||
|
||||
/**
|
||||
* Selects the condition code register to use for conditional destination
|
||||
* update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only
|
||||
* condition code register 0 is available. In NV_vertex_program3 mode,
|
||||
* condition code registers 0 and 1 are available.
|
||||
*/
|
||||
GLuint CondSrc:1;
|
||||
/*@}*/
|
||||
|
||||
GLuint pad:31;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Vertex/fragment program instruction.
|
||||
*/
|
||||
struct prog_instruction
|
||||
{
|
||||
enum prog_opcode Opcode;
|
||||
#if FEATURE_MESA_program_debug
|
||||
GLshort StringPos;
|
||||
#endif
|
||||
/**
|
||||
* Arbitrary data. Used for the PRINT, CAL, and BRA instructions.
|
||||
*/
|
||||
void *Data;
|
||||
|
||||
struct prog_src_register SrcReg[3];
|
||||
struct prog_dst_register DstReg;
|
||||
|
||||
/**
|
||||
* Indicates that the instruction should update the condition code
|
||||
* register.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
|
||||
* NV_vertex_program2_option.
|
||||
*/
|
||||
GLuint CondUpdate:1;
|
||||
|
||||
/**
|
||||
* If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the
|
||||
* condition code register that is to be updated.
|
||||
*
|
||||
* In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition
|
||||
* code register 0 is available. In GL_NV_vertex_program3 mode, condition
|
||||
* code registers 0 and 1 are available.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
|
||||
* NV_vertex_program2_option.
|
||||
*/
|
||||
GLuint CondDst:1;
|
||||
|
||||
/**
|
||||
* Saturate each value of the vectored result to the range [0,1] or the
|
||||
* range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is
|
||||
* only available in NV_fragment_program2 mode.
|
||||
* Value is one of the SATURATE_* tokens.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option, NV_vertex_program3.
|
||||
*/
|
||||
GLuint SaturateMode:2;
|
||||
|
||||
/**
|
||||
* Per-instruction selectable precision.
|
||||
*
|
||||
* \since
|
||||
* NV_fragment_program, NV_fragment_program_option.
|
||||
*/
|
||||
GLuint Precision:3;
|
||||
|
||||
/**
|
||||
* \name Texture source controls.
|
||||
*
|
||||
* The texture source controls are only used with the \c TEX, \c TXD,
|
||||
* \c TXL, and \c TXP instructions.
|
||||
*
|
||||
* \since
|
||||
* ARB_fragment_program, NV_fragment_program, NV_vertex_program3.
|
||||
*/
|
||||
/*@{*/
|
||||
/**
|
||||
* Source texture unit. OpenGL supports a maximum of 32 texture
|
||||
* units.
|
||||
*/
|
||||
GLuint TexSrcUnit:5;
|
||||
|
||||
/**
|
||||
* Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX.
|
||||
*/
|
||||
GLuint TexSrcTarget:3;
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* For BRA and CAL instructions, the location to jump to.
|
||||
*/
|
||||
GLuint BranchTarget;
|
||||
};
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_init_instructions(struct prog_instruction *inst, GLuint count);
|
||||
|
||||
extern GLuint
|
||||
_mesa_num_inst_src_regs(enum prog_opcode opcode);
|
||||
|
||||
extern const char *
|
||||
_mesa_opcode_string(enum prog_opcode opcode);
|
||||
|
||||
|
||||
#endif /* PROG_INSTRUCTION_H */
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -33,11 +33,10 @@
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "imports.h"
|
||||
#include "mtypes.h"
|
||||
#include "program.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "prog_statevars.h"
|
||||
#include "programopt.h"
|
||||
#include "program_instruction.h"
|
||||
#include "prog_instruction.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,11 +56,11 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog)
|
||||
* Setup state references for the modelview/projection matrix.
|
||||
* XXX we should check if these state vars are already declared.
|
||||
*/
|
||||
static const GLint mvpState[4][5] = {
|
||||
{ STATE_MATRIX, STATE_MVP, 0, 0, 0 }, /* state.matrix.mvp.row[0] */
|
||||
{ STATE_MATRIX, STATE_MVP, 0, 1, 1 }, /* state.matrix.mvp.row[1] */
|
||||
{ STATE_MATRIX, STATE_MVP, 0, 2, 2 }, /* state.matrix.mvp.row[2] */
|
||||
{ STATE_MATRIX, STATE_MVP, 0, 3, 3 }, /* state.matrix.mvp.row[3] */
|
||||
static const gl_state_index mvpState[4][STATE_LENGTH] = {
|
||||
{ STATE_MVP_MATRIX, 0, 0, 0, 0 }, /* state.matrix.mvp.row[0] */
|
||||
{ STATE_MVP_MATRIX, 0, 1, 1, 0 }, /* state.matrix.mvp.row[1] */
|
||||
{ STATE_MVP_MATRIX, 0, 2, 2, 0 }, /* state.matrix.mvp.row[2] */
|
||||
{ STATE_MVP_MATRIX, 0, 3, 3, 0 }, /* state.matrix.mvp.row[3] */
|
||||
};
|
||||
GLint mvpRef[4];
|
||||
|
||||
@@ -100,8 +99,7 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog)
|
||||
}
|
||||
|
||||
/* Append original instructions after new instructions */
|
||||
_mesa_memcpy(newInst + 4, vprog->Base.Instructions,
|
||||
origLen * sizeof(struct prog_instruction));
|
||||
_mesa_copy_instructions (newInst + 4, vprog->Base.Instructions, origLen);
|
||||
|
||||
/* free old instructions */
|
||||
_mesa_free(vprog->Base.Instructions);
|
||||
@@ -126,16 +124,16 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog)
|
||||
void
|
||||
_mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
{
|
||||
static const GLint fogParamsState[] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
|
||||
static const GLint fogColorState[] = { STATE_FOG_COLOR, 0, 0, 0, 0 };
|
||||
static const gl_state_index fogPStateOpt[STATE_LENGTH]
|
||||
= { STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 };
|
||||
static const gl_state_index fogColorState[STATE_LENGTH]
|
||||
= { STATE_FOG_COLOR, 0, 0, 0, 0};
|
||||
struct prog_instruction *newInst, *inst;
|
||||
const GLuint origLen = fprog->Base.NumInstructions;
|
||||
const GLuint newLen = origLen + 6;
|
||||
const GLuint newLen = origLen + 5;
|
||||
GLuint i;
|
||||
GLint fogParamsRef, fogColorRef; /* state references */
|
||||
GLint fogPRefOpt, fogColorRef; /* state references */
|
||||
GLuint colorTemp, fogFactorTemp; /* temporary registerss */
|
||||
GLfloat fogVals[4];
|
||||
GLuint fogConsts; /* constant values for EXP, EXP2 mode */
|
||||
|
||||
if (fprog->FogOption == GL_NONE) {
|
||||
_mesa_problem(ctx, "_mesa_append_fog_code() called for fragment program"
|
||||
@@ -152,12 +150,11 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
}
|
||||
|
||||
/* Copy orig instructions into new instruction buffer */
|
||||
_mesa_memcpy(newInst, fprog->Base.Instructions,
|
||||
origLen * sizeof(struct prog_instruction));
|
||||
_mesa_copy_instructions(newInst, fprog->Base.Instructions, origLen);
|
||||
|
||||
/* PARAM fogParamsRef = state.fog.params; */
|
||||
fogParamsRef
|
||||
= _mesa_add_state_reference(fprog->Base.Parameters, fogParamsState);
|
||||
/* PARAM fogParamsRefOpt = internal optimized fog params; */
|
||||
fogPRefOpt
|
||||
= _mesa_add_state_reference(fprog->Base.Parameters, fogPStateOpt);
|
||||
/* PARAM fogColorRef = state.fog.color; */
|
||||
fogColorRef
|
||||
= _mesa_add_state_reference(fprog->Base.Parameters, fogColorState);
|
||||
@@ -167,13 +164,6 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
/* TEMP fogFactorTemp; */
|
||||
fogFactorTemp = fprog->Base.NumTemporaries++;
|
||||
|
||||
/* PARAM fogVals = { 1/ln(2), 1/sqrt(ln(2), 0, 0 }; */
|
||||
fogVals[0] = 1.0 / log(2.0);
|
||||
fogVals[1] = 1.0 / SQRTF(log(2.0));
|
||||
fogVals[2] = 0.0;
|
||||
fogVals[3] = 0.0;
|
||||
fogConsts = _mesa_add_unnamed_constant(fprog->Base.Parameters, fogVals, 4);
|
||||
|
||||
/* Scan program to find where result.color is written */
|
||||
inst = newInst;
|
||||
for (i = 0; i < fprog->Base.NumInstructions; i++) {
|
||||
@@ -191,43 +181,40 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
}
|
||||
assert(inst->Opcode == OPCODE_END); /* we'll overwrite this inst */
|
||||
|
||||
_mesa_init_instructions(inst, 6);
|
||||
_mesa_init_instructions(inst, 5);
|
||||
|
||||
/* emit instructions to compute fog blending factor */
|
||||
if (fprog->FogOption == GL_LINEAR) {
|
||||
/* SUB fogFactorTemp.x, fogParamsRef.z, fragment.fogcoord.x; */
|
||||
inst->Opcode = OPCODE_SUB;
|
||||
/* MAD fogFactorTemp.x, fragment.fogcoord.x, fogPRefOpt.x, fogPRefOpt.y; */
|
||||
inst->Opcode = OPCODE_MAD;
|
||||
inst->DstReg.File = PROGRAM_TEMPORARY;
|
||||
inst->DstReg.Index = fogFactorTemp;
|
||||
inst->DstReg.WriteMask = WRITEMASK_X;
|
||||
inst->SrcReg[0].File = PROGRAM_STATE_VAR;
|
||||
inst->SrcReg[0].Index = fogParamsRef;
|
||||
inst->SrcReg[0].Swizzle = SWIZZLE_Z;
|
||||
inst->SrcReg[1].File = PROGRAM_INPUT;
|
||||
inst->SrcReg[1].Index = FRAG_ATTRIB_FOGC;
|
||||
inst++;
|
||||
/* MUL fogFactorTemp.x, fogFactorTemp, fogParamsRef.w; */
|
||||
inst->Opcode = OPCODE_MUL;
|
||||
inst->DstReg.File = PROGRAM_TEMPORARY;
|
||||
inst->DstReg.Index = fogFactorTemp;
|
||||
inst->DstReg.WriteMask = WRITEMASK_X;
|
||||
inst->SrcReg[0].File = PROGRAM_TEMPORARY;
|
||||
inst->SrcReg[0].Index = fogFactorTemp;
|
||||
inst->SrcReg[0].File = PROGRAM_INPUT;
|
||||
inst->SrcReg[0].Index = FRAG_ATTRIB_FOGC;
|
||||
inst->SrcReg[0].Swizzle = SWIZZLE_X;
|
||||
inst->SrcReg[1].File = PROGRAM_STATE_VAR;
|
||||
inst->SrcReg[1].Index = fogParamsRef;
|
||||
inst->SrcReg[1].Swizzle = SWIZZLE_W;
|
||||
inst->SrcReg[1].Index = fogPRefOpt;
|
||||
inst->SrcReg[1].Swizzle = SWIZZLE_X;
|
||||
inst->SrcReg[2].File = PROGRAM_STATE_VAR;
|
||||
inst->SrcReg[2].Index = fogPRefOpt;
|
||||
inst->SrcReg[2].Swizzle = SWIZZLE_Y;
|
||||
inst->SaturateMode = SATURATE_ZERO_ONE;
|
||||
inst++;
|
||||
}
|
||||
else {
|
||||
ASSERT(fprog->FogOption == GL_EXP || fprog->FogOption == GL_EXP2);
|
||||
/* MUL fogFactorTemp.x, fogParamsRef.x, fragment.fogcoord; */
|
||||
/* fogPRefOpt.z = d/ln(2), fogPRefOpt.w = d/sqrt(ln(2) */
|
||||
/* EXP: MUL fogFactorTemp.x, fogPRefOpt.z, fragment.fogcoord.x; */
|
||||
/* EXP2: MUL fogFactorTemp.x, fogPRefOpt.w, fragment.fogcoord.x; */
|
||||
inst->Opcode = OPCODE_MUL;
|
||||
inst->DstReg.File = PROGRAM_TEMPORARY;
|
||||
inst->DstReg.Index = fogFactorTemp;
|
||||
inst->DstReg.WriteMask = WRITEMASK_X;
|
||||
inst->SrcReg[0].File = PROGRAM_STATE_VAR;
|
||||
inst->SrcReg[0].Index = fogParamsRef;
|
||||
inst->SrcReg[0].Swizzle = SWIZZLE_X; /* X=density */
|
||||
inst->SrcReg[0].Index = fogPRefOpt;
|
||||
inst->SrcReg[0].Swizzle
|
||||
= (fprog->FogOption == GL_EXP) ? SWIZZLE_Z : SWIZZLE_W;
|
||||
inst->SrcReg[1].File = PROGRAM_INPUT;
|
||||
inst->SrcReg[1].Index = FRAG_ATTRIB_FOGC;
|
||||
inst->SrcReg[1].Swizzle = SWIZZLE_X;
|
||||
@@ -240,23 +227,12 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
inst->DstReg.WriteMask = WRITEMASK_X;
|
||||
inst->SrcReg[0].File = PROGRAM_TEMPORARY;
|
||||
inst->SrcReg[0].Index = fogFactorTemp;
|
||||
inst->SrcReg[0].Swizzle = SWIZZLE_X;
|
||||
inst->SrcReg[1].File = PROGRAM_TEMPORARY;
|
||||
inst->SrcReg[1].Index = fogFactorTemp;
|
||||
inst->SrcReg[1].Swizzle = SWIZZLE_X;
|
||||
inst++;
|
||||
}
|
||||
/* EXP: MUL fogFactorTemp.x, fogFactorTemp.x, {1/ln(2)}; */
|
||||
/* EXP2: MUL fogFactorTemp.x, fogFactorTemp.x, {1/sqrt(ln(2))}; */
|
||||
inst->Opcode = OPCODE_MUL;
|
||||
inst->DstReg.File = PROGRAM_TEMPORARY;
|
||||
inst->DstReg.Index = fogFactorTemp;
|
||||
inst->DstReg.WriteMask = WRITEMASK_X;
|
||||
inst->SrcReg[0].File = PROGRAM_TEMPORARY;
|
||||
inst->SrcReg[0].Index = fogFactorTemp;
|
||||
inst->SrcReg[1].File = PROGRAM_CONSTANT;
|
||||
inst->SrcReg[1].Index = fogConsts;
|
||||
inst->SrcReg[1].Swizzle
|
||||
= (fprog->FogOption == GL_EXP) ? SWIZZLE_X : SWIZZLE_Y;
|
||||
inst++;
|
||||
/* EX2_SAT fogFactorTemp.x, -fogFactorTemp.x; */
|
||||
inst->Opcode = OPCODE_EX2;
|
||||
inst->DstReg.File = PROGRAM_TEMPORARY;
|
||||
@@ -265,6 +241,7 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
inst->SrcReg[0].File = PROGRAM_TEMPORARY;
|
||||
inst->SrcReg[0].Index = fogFactorTemp;
|
||||
inst->SrcReg[0].NegateBase = GL_TRUE;
|
||||
inst->SrcReg[0].Swizzle = SWIZZLE_X;
|
||||
inst->SaturateMode = SATURATE_ZERO_ONE;
|
||||
inst++;
|
||||
}
|
||||
@@ -279,8 +256,10 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
= MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X);
|
||||
inst->SrcReg[1].File = PROGRAM_TEMPORARY;
|
||||
inst->SrcReg[1].Index = colorTemp;
|
||||
inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
|
||||
inst->SrcReg[2].File = PROGRAM_STATE_VAR;
|
||||
inst->SrcReg[2].Index = fogColorRef;
|
||||
inst->SrcReg[2].Swizzle = SWIZZLE_NOOP;
|
||||
inst++;
|
||||
/* MOV result.color.w, colorTemp.x; # copy alpha */
|
||||
inst->Opcode = OPCODE_MOV;
|
||||
@@ -289,6 +268,7 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
inst->DstReg.WriteMask = WRITEMASK_W;
|
||||
inst->SrcReg[0].File = PROGRAM_TEMPORARY;
|
||||
inst->SrcReg[0].Index = colorTemp;
|
||||
inst->SrcReg[0].Swizzle = SWIZZLE_NOOP;
|
||||
inst++;
|
||||
/* END; */
|
||||
inst->Opcode = OPCODE_END;
|
||||
@@ -303,3 +283,85 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
fprog->Base.InputsRead |= FRAG_BIT_FOGC;
|
||||
/* XXX do this? fprog->FogOption = GL_NONE; */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static GLboolean
|
||||
is_texture_instruction(const struct prog_instruction *inst)
|
||||
{
|
||||
switch (inst->Opcode) {
|
||||
case OPCODE_TEX:
|
||||
case OPCODE_TXB:
|
||||
case OPCODE_TXD:
|
||||
case OPCODE_TXL:
|
||||
case OPCODE_TXP:
|
||||
case OPCODE_TXP_NV:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count the number of texure indirections in the given program.
|
||||
* The program's NumTexIndirections field will be updated.
|
||||
* See the GL_ARB_fragment_program spec (issue 24) for details.
|
||||
* XXX we count texture indirections in texenvprogram.c (maybe use this code
|
||||
* instead and elsewhere).
|
||||
*/
|
||||
void
|
||||
_mesa_count_texture_indirections(struct gl_program *prog)
|
||||
{
|
||||
GLuint indirections = 1;
|
||||
GLbitfield tempsOutput = 0x0;
|
||||
GLbitfield aluTemps = 0x0;
|
||||
GLuint i;
|
||||
|
||||
for (i = 0; i < prog->NumInstructions; i++) {
|
||||
const struct prog_instruction *inst = prog->Instructions + i;
|
||||
|
||||
if (is_texture_instruction(inst)) {
|
||||
if (((inst->SrcReg[0].File == PROGRAM_TEMPORARY) &&
|
||||
(tempsOutput & (1 << inst->SrcReg[0].Index))) ||
|
||||
((inst->Opcode != OPCODE_KIL) &&
|
||||
(inst->DstReg.File == PROGRAM_TEMPORARY) &&
|
||||
(aluTemps & (1 << inst->DstReg.Index))))
|
||||
{
|
||||
indirections++;
|
||||
tempsOutput = 0x0;
|
||||
aluTemps = 0x0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
GLuint j;
|
||||
for (j = 0; j < 3; j++) {
|
||||
if (inst->SrcReg[j].File == PROGRAM_TEMPORARY)
|
||||
aluTemps |= (1 << inst->SrcReg[j].Index);
|
||||
}
|
||||
if (inst->DstReg.File == PROGRAM_TEMPORARY)
|
||||
aluTemps |= (1 << inst->DstReg.Index);
|
||||
}
|
||||
|
||||
if ((inst->Opcode != OPCODE_KIL) && (inst->DstReg.File == PROGRAM_TEMPORARY))
|
||||
tempsOutput |= (1 << inst->DstReg.Index);
|
||||
}
|
||||
|
||||
prog->NumTexIndirections = indirections;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count number of texture instructions in given program and update the
|
||||
* program's NumTexInstructions field.
|
||||
*/
|
||||
void
|
||||
_mesa_count_texture_instructions(struct gl_program *prog)
|
||||
{
|
||||
GLuint i;
|
||||
prog->NumTexInstructions = 0;
|
||||
for (i = 0; i < prog->NumInstructions; i++) {
|
||||
prog->NumTexInstructions += is_texture_instruction(prog->Instructions + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -33,5 +33,11 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog);
|
||||
extern void
|
||||
_mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog);
|
||||
|
||||
extern void
|
||||
_mesa_count_texture_indirections(struct gl_program *prog);
|
||||
|
||||
extern void
|
||||
_mesa_count_texture_instructions(struct gl_program *prog);
|
||||
|
||||
|
||||
#endif /* PROGRAMOPT_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
*
|
||||
* Copyright (C) 2004-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SHADER_API_H
|
||||
#define SHADER_API_H
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
|
||||
/**
|
||||
* Internal functions
|
||||
*/
|
||||
|
||||
extern void
|
||||
_mesa_init_shader_state(GLcontext * ctx);
|
||||
|
||||
extern void
|
||||
_mesa_free_shader_state(GLcontext *ctx);
|
||||
|
||||
extern struct gl_shader_program *
|
||||
_mesa_new_shader_program(GLcontext *ctx, GLuint name);
|
||||
|
||||
extern void
|
||||
_mesa_clear_shader_program_data(GLcontext *ctx,
|
||||
struct gl_shader_program *shProg);
|
||||
|
||||
extern void
|
||||
_mesa_free_shader_program_data(GLcontext *ctx,
|
||||
struct gl_shader_program *shProg);
|
||||
|
||||
extern void
|
||||
_mesa_free_shader_program(GLcontext *ctx, struct gl_shader_program *shProg);
|
||||
|
||||
extern void
|
||||
_mesa_reference_shader_program(GLcontext *ctx,
|
||||
struct gl_shader_program **ptr,
|
||||
struct gl_shader_program *shProg);
|
||||
|
||||
extern struct gl_shader_program *
|
||||
_mesa_lookup_shader_program(GLcontext *ctx, GLuint name);
|
||||
|
||||
|
||||
extern struct gl_shader *
|
||||
_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type);
|
||||
|
||||
extern void
|
||||
_mesa_free_shader(GLcontext *ctx, struct gl_shader *sh);
|
||||
|
||||
extern void
|
||||
_mesa_reference_shader(GLcontext *ctx, struct gl_shader **ptr,
|
||||
struct gl_shader *sh);
|
||||
|
||||
extern struct gl_shader *
|
||||
_mesa_lookup_shader(GLcontext *ctx, GLuint name);
|
||||
|
||||
|
||||
/**
|
||||
* API/Driver functions
|
||||
*/
|
||||
|
||||
extern void
|
||||
_mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader);
|
||||
|
||||
extern void
|
||||
_mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index,
|
||||
const GLchar *name);
|
||||
|
||||
extern void
|
||||
_mesa_compile_shader(GLcontext *ctx, GLuint shaderObj);
|
||||
|
||||
extern GLuint
|
||||
_mesa_create_shader(GLcontext *ctx, GLenum type);
|
||||
|
||||
extern GLuint
|
||||
_mesa_create_program(GLcontext *ctx);
|
||||
|
||||
extern void
|
||||
_mesa_delete_program2(GLcontext *ctx, GLuint name);
|
||||
|
||||
extern void
|
||||
_mesa_delete_shader(GLcontext *ctx, GLuint shader);
|
||||
|
||||
extern void
|
||||
_mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader);
|
||||
|
||||
extern void
|
||||
_mesa_get_active_attrib(GLcontext *ctx, GLuint program, GLuint index,
|
||||
GLsizei maxLength, GLsizei *length, GLint *size,
|
||||
GLenum *type, GLchar *name);
|
||||
|
||||
extern void
|
||||
_mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index,
|
||||
GLsizei maxLength, GLsizei *length, GLint *size,
|
||||
GLenum *type, GLchar *name);
|
||||
|
||||
extern void
|
||||
_mesa_get_attached_shaders(GLcontext *ctx, GLuint program, GLsizei maxCount,
|
||||
GLsizei *count, GLuint *obj);
|
||||
|
||||
extern GLint
|
||||
_mesa_get_attrib_location(GLcontext *ctx, GLuint program,
|
||||
const GLchar *name);
|
||||
|
||||
extern GLuint
|
||||
_mesa_get_handle(GLcontext *ctx, GLenum pname);
|
||||
|
||||
extern void
|
||||
_mesa_get_programiv(GLcontext *ctx, GLuint program,
|
||||
GLenum pname, GLint *params);
|
||||
|
||||
extern void
|
||||
_mesa_get_program_info_log(GLcontext *ctx, GLuint program, GLsizei bufSize,
|
||||
GLsizei *length, GLchar *infoLog);
|
||||
|
||||
extern void
|
||||
_mesa_get_shaderiv(GLcontext *ctx, GLuint shader, GLenum pname, GLint *params);
|
||||
|
||||
extern void
|
||||
_mesa_get_shader_info_log(GLcontext *ctx, GLuint shader, GLsizei bufSize,
|
||||
GLsizei *length, GLchar *infoLog);
|
||||
|
||||
extern void
|
||||
_mesa_get_shader_source(GLcontext *ctx, GLuint shader, GLsizei maxLength,
|
||||
GLsizei *length, GLchar *sourceOut);
|
||||
|
||||
extern void
|
||||
_mesa_get_uniformfv(GLcontext *ctx, GLuint program, GLint location,
|
||||
GLfloat *params);
|
||||
|
||||
extern GLint
|
||||
_mesa_get_uniform_location(GLcontext *ctx, GLuint program, const GLchar *name);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_program(GLcontext *ctx, GLuint name);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_shader(GLcontext *ctx, GLuint name);
|
||||
|
||||
extern void
|
||||
_mesa_link_program(GLcontext *ctx, GLuint program);
|
||||
|
||||
extern void
|
||||
_mesa_shader_source(GLcontext *ctx, GLuint shader, const GLchar *source);
|
||||
|
||||
extern void
|
||||
_mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
|
||||
const GLvoid *values, GLenum type);
|
||||
|
||||
void
|
||||
_mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
|
||||
GLenum matrixType, GLint location, GLsizei count,
|
||||
GLboolean transpose, const GLfloat *values);
|
||||
|
||||
extern void
|
||||
_mesa_use_program(GLcontext *ctx, GLuint program);
|
||||
|
||||
extern void
|
||||
_mesa_validate_program(GLcontext *ctx, GLuint program);
|
||||
|
||||
|
||||
#endif /* SHADER_API_H */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user