Compare commits

...

6 Commits

Author SHA1 Message Date
Brian Paul
6d9b25e522 mesa: don't check for GLSL 1.2 to advertise GL 2.1
The GLSL 1.2 features are minor...
2008-08-26 15:50:11 -06:00
Corbin Simpson
31bad23f0f note ATI R500 series support 2008-08-26 12:39:27 -06:00
Timo Jyrinki
29b9b25e72 asst. html doc updates 2008-08-26 12:36:23 -06:00
Brian Paul
e794f496c6 mesa: assorted updates/prep for 7.1 release 2008-08-25 14:09:14 -06:00
Brian Paul
68067c66d3 mesa: glsl: regenerated file 2008-08-25 09:16:21 -06:00
Brian Paul
ad5474e995 mesa: glsl: grab latest fixes from gallium-0.1 branch
Includes:
1. Fixes failed asserting about bad swizzles in src reg emit.
2. Tracks uniform var usage.
3. Emit exp() in terms of EXP2 instruction.
2008-08-25 09:15:16 -06:00
17 changed files with 795 additions and 665 deletions

View File

@@ -174,10 +174,10 @@ ultrix-gcc:
# Rules for making release tarballs # Rules for making release tarballs
DIRECTORY = Mesa-7.1-rc4 DIRECTORY = Mesa-7.1
LIB_NAME = MesaLib-7.1-rc4 LIB_NAME = MesaLib-7.1
DEMO_NAME = MesaDemos-7.1-rc4 DEMO_NAME = MesaDemos-7.1
GLUT_NAME = MesaGLUT-7.1-rc4 GLUT_NAME = MesaGLUT-7.1
MAIN_FILES = \ MAIN_FILES = \
$(DIRECTORY)/Makefile* \ $(DIRECTORY)/Makefile* \

View File

@@ -48,6 +48,7 @@ a:visited {
<li><a href="lists.html" target="MainFrame">Mailing Lists</a> <li><a href="lists.html" target="MainFrame">Mailing Lists</a>
<li><a href="bugs.html" target="MainFrame">Bug Database</a> <li><a href="bugs.html" target="MainFrame">Bug Database</a>
<li><a href="webmaster.html" target="MainFrame">Webmaster</a> <li><a href="webmaster.html" target="MainFrame">Webmaster</a>
<li><a href="http://dri.freedesktop.org/" target="MainFrame">Wiki</a>
</ul> </ul>
<b>User Topics</b> <b>User Topics</b>

View File

@@ -9,6 +9,8 @@
<H1>Downloading</H1> <H1>Downloading</H1>
<p> <p>
Current development release: <b>7.1</b>
<br>
Last stable release: <b>7.0.4</b> Last stable release: <b>7.0.4</b>
</p> </p>

View File

@@ -22,9 +22,10 @@ for modern GPUs.
<p> <p>
Mesa ties into several other open-source projects: the Mesa ties into several other open-source projects: the
<a href="http://dri.sf.net/" target="_parent">Direct Rendering Infrastructure</a> <a href="http://dri.freedesktop.org/" target="_parent">Direct Rendering
and <a href="http://x.org" target="_parent">X.org</a> to provide OpenGL Infrastructure</a> and <a href="http://x.org" target="_parent">X.org</a> to
support to users of X on Linux, FreeBSD and other operating systems. provide OpenGL support to users of X on Linux, FreeBSD and other operating
systems.
</p> </p>

View File

@@ -9,7 +9,7 @@
<H1>Mailing Lists</H1> <H1>Mailing Lists</H1>
<p>There are four Mesa mailing lists: <p>There are four Mesa 3D / DRI mailing lists:
</p> </p>
<ul> <ul>
@@ -19,14 +19,14 @@ versions are sent to this list.
</li> </li>
<br> <br>
<li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-users" <li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-users"
target="_parent">mesa3d-users</a> - intended for users of the Mesa library. target="_parent">mesa3d-users</a> - intended for users of the Mesa and DRI.
Newbie questions are appropriate, but please try the general OpenGL Newbie questions are appropriate, but please try the general OpenGL
resources and Mesa documentation first. resources and Mesa/DRI documentation first.
</li> </li>
<br> <br>
<li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-dev" <li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-dev"
target="_parent">mesa3d-dev</a> - for discussion of Mesa development. target="_parent">mesa3d-dev</a> - for discussion of Mesa and Direct Rendering
Not for beginners. Infrastructure development. Not for beginners.
</li> </li>
<br> <br>
<li><a href="http://lists.freedesktop.org/mailman/listinfo/mesa-commit" <li><a href="http://lists.freedesktop.org/mailman/listinfo/mesa-commit"
@@ -37,6 +37,9 @@ Note: the old mesa3d-cvs list is no longer in use.
</li> </li>
</ul> </ul>
<p>For mailing lists about Direct Rendering Modules (drm) in Linux/BSD
kernels, see <a href="http://dri.freedesktop.org/wiki/MailingLists">wiki</a>.
<p> <p>
<b>Notice</b>: non-member posts to any of these lists will be automatically <b>Notice</b>: non-member posts to any of these lists will be automatically
rejected. rejected.

View File

@@ -11,6 +11,16 @@
<H1>News</H1> <H1>News</H1>
<h2>August 26, 2008</h2>
<p>
<a href="relnotes-7.1.html">Mesa 7.1</a> is released.
This is a new development release.
It should be relatively stable, but those especially concerned about
stability should wait for the 7.2 release or use Mesa 7.0.4 (the
previous stable release).
</p>
<h2>August 16, 2008</h2> <h2>August 16, 2008</h2>
<p> <p>
<a href="relnotes-7.0.4.html">Mesa 7.0.4</a> is released. <a href="relnotes-7.0.4.html">Mesa 7.0.4</a> is released.

View File

@@ -8,13 +8,21 @@
<body bgcolor="#eeeeee"> <body bgcolor="#eeeeee">
<H1>Mesa 7.1 Release Notes / May XX, 2008</H1> <H1>Mesa 7.1 Release Notes / August 26, 2008</H1>
<p> <p>
Mesa 7.1 is a new development release. Mesa 7.1 is a new development release.
There have been many internal code changes since Mesa 7.0.x. There have been many internal code changes since Mesa 7.0.x.
It should be relatively stable, but those who are especially concerned about It should be relatively stable, but those who are especially concerned about
stability should wait for Mesa 7.2. stability should wait for Mesa 7.2 or use Mesa 7.0.4 (the previous stable
release).
</p>
</>
Note that this version of Mesa does not use the GEM memory manager.
The master branch of git uses GEM.
</p>
<p>
DRM version 2.3.1 should be used with Mesa 7.1
</p> </p>
@@ -27,9 +35,11 @@ TBD
<h2>New features</h2> <h2>New features</h2>
<ul> <ul>
<li>autoconf-based configuration (and clean-up of Makefiles) <li>autoconf-based configuration (and clean-up of Makefiles)
<li>Assorted DRI driver enhancements
<li>Reduced dependencies between X server and Mesa <li>Reduced dependencies between X server and Mesa
<li>GL_EXT_texture_from_pixmap extension for Xlib driver <li>GL_EXT_texture_from_pixmap extension for Xlib driver
<li>Support for the GL shading language with i965 driver (implemented by Intel) <li>Support for the GL shading language with i965 driver (implemented by Intel)
<li>ATI R500 series support (Radeon X1300&#8211;X1950) in r300 DRI driver
</ul> </ul>
@@ -37,6 +47,7 @@ TBD
<ul> <ul>
<li>Numerous GLSL fixes <li>Numerous GLSL fixes
<li>Fixed some error code/detection bugs in the GLSL-related API functions <li>Fixed some error code/detection bugs in the GLSL-related API functions
<li>Lots of DRI driver fixes.
</ul> </ul>

View File

@@ -1,8 +1,8 @@
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 6.5.1 * Version: 7.1
* *
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),

View File

@@ -85,7 +85,7 @@ compute_version(const GLcontext *ctx)
ctx->Extensions.ARB_texture_non_power_of_two && ctx->Extensions.ARB_texture_non_power_of_two &&
ctx->Extensions.EXT_blend_equation_separate); ctx->Extensions.EXT_blend_equation_separate);
const GLboolean ver_2_1 = (ver_2_0 && const GLboolean ver_2_1 = (ver_2_0 &&
ctx->Extensions.ARB_shading_language_120 && /*ctx->Extensions.ARB_shading_language_120 &&*/
ctx->Extensions.EXT_pixel_buffer_object && ctx->Extensions.EXT_pixel_buffer_object &&
ctx->Extensions.EXT_texture_sRGB); ctx->Extensions.EXT_texture_sRGB);
if (ver_2_1) if (ver_2_1)
@@ -121,12 +121,6 @@ _mesa_GetString( GLenum name )
static const char *vendor = "Brian Paul"; static const char *vendor = "Brian Paul";
static const char *renderer = "Mesa"; static const char *renderer = "Mesa";
#if FEATURE_ARB_shading_language_120_foo /* support not complete! */
static const char *sl_version = "1.20";
#elif FEATURE_ARB_shading_language_100
static const char *sl_version = "1.10";
#endif
if (!ctx) if (!ctx)
return NULL; return NULL;
@@ -154,8 +148,10 @@ _mesa_GetString( GLenum name )
return (const GLubyte *) ctx->Extensions.String; return (const GLubyte *) ctx->Extensions.String;
#if FEATURE_ARB_shading_language_100 #if FEATURE_ARB_shading_language_100
case GL_SHADING_LANGUAGE_VERSION_ARB: case GL_SHADING_LANGUAGE_VERSION_ARB:
if (ctx->Extensions.ARB_shading_language_100) if (ctx->Extensions.ARB_shading_language_120)
return (const GLubyte *) sl_version; return (const GLubyte *) "1.20";
else if (ctx->Extensions.ARB_shading_language_100)
return (const GLubyte *) "1.10";
goto error; goto error;
#endif #endif
#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \ #if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \

View File

@@ -2,7 +2,7 @@
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 7.1 * Version: 7.1
* *
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -31,7 +31,7 @@
#define MESA_MAJOR 7 #define MESA_MAJOR 7
#define MESA_MINOR 1 #define MESA_MINOR 1
#define MESA_PATCH 0 #define MESA_PATCH 0
#define MESA_VERSION_STRING "7.1 rc4" #define MESA_VERSION_STRING "7.1"
/* To make version comparison easy */ /* To make version comparison easy */
#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

View File

@@ -29,9 +29,9 @@
*/ */
#include "glheader.h" #include "main/glheader.h"
#include "imports.h" #include "main/imports.h"
#include "macros.h" #include "main/macros.h"
#include "prog_instruction.h" #include "prog_instruction.h"
#include "prog_parameter.h" #include "prog_parameter.h"
#include "prog_statevars.h" #include "prog_statevars.h"
@@ -277,6 +277,26 @@ _mesa_add_uniform(struct gl_program_parameter_list *paramList,
} }
/**
* Mark the named uniform as 'used'.
*/
void
_mesa_use_uniform(struct gl_program_parameter_list *paramList,
const char *name)
{
GLuint i;
for (i = 0; i < paramList->NumParameters; i++) {
struct gl_program_parameter *p = paramList->Parameters + i;
if (p->Type == PROGRAM_UNIFORM && _mesa_strcmp(p->Name, name) == 0) {
p->Used = GL_TRUE;
/* Note that large uniforms may occupy several slots so we're
* not done searching yet.
*/
}
}
}
/** /**
* Add a sampler to the parameter list. * Add a sampler to the parameter list.
* \param name uniform's name * \param name uniform's name
@@ -591,21 +611,24 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list)
/** Not too efficient, but correct */ /** Not too efficient, but correct */
for (i = 0; i < list->NumParameters; i++) { for (i = 0; i < list->NumParameters; i++) {
struct gl_program_parameter *p = list->Parameters + i; struct gl_program_parameter *p = list->Parameters + i;
struct gl_program_parameter *pCopy;
GLuint size = MIN2(p->Size, 4); GLuint size = MIN2(p->Size, 4);
GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType, GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType,
list->ParameterValues[i], NULL); list->ParameterValues[i], NULL);
ASSERT(j >= 0); ASSERT(j >= 0);
pCopy = clone->Parameters + j;
pCopy->Used = p->Used;
/* copy state indexes */ /* copy state indexes */
if (p->Type == PROGRAM_STATE_VAR) { if (p->Type == PROGRAM_STATE_VAR) {
GLint k; GLint k;
struct gl_program_parameter *q = clone->Parameters + j;
for (k = 0; k < STATE_LENGTH; k++) { for (k = 0; k < STATE_LENGTH; k++) {
q->StateIndexes[k] = p->StateIndexes[k]; pCopy->StateIndexes[k] = p->StateIndexes[k];
} }
} }
else { else {
clone->Parameters[j].Size = p->Size; clone->Parameters[j].Size = p->Size;
} }
} }
clone->StateFlags = list->StateFlags; clone->StateFlags = list->StateFlags;

View File

@@ -31,7 +31,7 @@
#ifndef PROG_PARAMETER_H #ifndef PROG_PARAMETER_H
#define PROG_PARAMETER_H #define PROG_PARAMETER_H
#include "mtypes.h" #include "main/mtypes.h"
#include "prog_statevars.h" #include "prog_statevars.h"
@@ -48,6 +48,7 @@ struct gl_program_parameter
enum register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ enum register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */
GLuint Size; /**< Number of components (1..4) */ GLuint Size; /**< Number of components (1..4) */
GLboolean Used; /**< Helper flag for GLSL uniform tracking */
/** /**
* A sequence of STATE_* tokens and integers to identify GL state. * A sequence of STATE_* tokens and integers to identify GL state.
*/ */
@@ -112,6 +113,10 @@ extern GLint
_mesa_add_uniform(struct gl_program_parameter_list *paramList, _mesa_add_uniform(struct gl_program_parameter_list *paramList,
const char *name, GLuint size, GLenum datatype); const char *name, GLuint size, GLenum datatype);
extern void
_mesa_use_uniform(struct gl_program_parameter_list *paramList,
const char *name);
extern GLint extern GLint
_mesa_add_sampler(struct gl_program_parameter_list *paramList, _mesa_add_sampler(struct gl_program_parameter_list *paramList,
const char *name, GLenum datatype); const char *name, GLenum datatype);

View File

@@ -473,32 +473,33 @@ vec4 pow(const vec4 a, const vec4 b)
float exp(const float a) float exp(const float a)
{ {
const float e = 2.71828; // NOTE: log2(e) = 1.44269502
__asm float_power __retVal, e, a; float t = a * 1.44269502;
__asm float_exp2 __retVal, t;
} }
vec2 exp(const vec2 a) vec2 exp(const vec2 a)
{ {
const float e = 2.71828; vec2 t = a * 1.44269502;
__asm float_power __retVal.x, e, a.x; __asm float_exp2 __retVal.x, t.x;
__asm float_power __retVal.y, e, a.y; __asm float_exp2 __retVal.y, t.y;
} }
vec3 exp(const vec3 a) vec3 exp(const vec3 a)
{ {
const float e = 2.71828; vec3 t = a * 1.44269502;
__asm float_power __retVal.x, e, a.x; __asm float_exp2 __retVal.x, t.x;
__asm float_power __retVal.y, e, a.y; __asm float_exp2 __retVal.y, t.y;
__asm float_power __retVal.z, e, a.z; __asm float_exp2 __retVal.z, t.z;
} }
vec4 exp(const vec4 a) vec4 exp(const vec4 a)
{ {
const float e = 2.71828; vec4 t = a * 1.44269502;
__asm float_power __retVal.x, e, a.x; __asm float_exp2 __retVal.x, t.x;
__asm float_power __retVal.y, e, a.y; __asm float_exp2 __retVal.y, t.y;
__asm float_power __retVal.z, e, a.z; __asm float_exp2 __retVal.z, t.z;
__asm float_power __retVal.w, e, a.w; __asm float_exp2 __retVal.w, t.w;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1481,7 +1481,7 @@ _slang_simple_writemask(GLuint writemask, GLuint swizzle)
* \return GL_FALSE for simple writemasks, GL_TRUE for non-simple * \return GL_FALSE for simple writemasks, GL_TRUE for non-simple
*/ */
static GLboolean static GLboolean
swizzle_to_writemask(GLuint swizzle, swizzle_to_writemask(slang_assemble_ctx *A, GLuint swizzle,
GLuint *writemaskOut, GLuint *swizzleOut) GLuint *writemaskOut, GLuint *swizzleOut)
{ {
GLuint mask = 0x0, newSwizzle[4]; GLuint mask = 0x0, newSwizzle[4];
@@ -1495,6 +1495,18 @@ swizzle_to_writemask(GLuint swizzle,
break; break;
} }
assert(swz >= 0 && swz <= 3); assert(swz >= 0 && swz <= 3);
if (swizzle != SWIZZLE_XXXX &&
swizzle != SWIZZLE_YYYY &&
swizzle != SWIZZLE_ZZZZ &&
swizzle != SWIZZLE_WWWW &&
(mask & (1 << swz))) {
/* a channel can't be specified twice (ex: ".xyyz") */
slang_info_log_error(A->log, "Invalid writemask '%s'",
_mesa_swizzle_string(swizzle, 0, 0));
return GL_FALSE;
}
mask |= (1 << swz); mask |= (1 << swz);
} }
assert(mask <= 0xf); assert(mask <= 0xf);
@@ -1590,11 +1602,11 @@ resolve_swizzle(const slang_operation *oper)
* As above, but produce a writemask. * As above, but produce a writemask.
*/ */
static GLuint static GLuint
resolve_writemask(const slang_operation *oper) resolve_writemask(slang_assemble_ctx *A, const slang_operation *oper)
{ {
GLuint swizzle = resolve_swizzle(oper); GLuint swizzle = resolve_swizzle(oper);
GLuint writemask, swizzleOut; GLuint writemask, swizzleOut;
swizzle_to_writemask(swizzle, &writemask, &swizzleOut); swizzle_to_writemask(A, swizzle, &writemask, &swizzleOut);
return writemask; return writemask;
} }
@@ -1668,7 +1680,7 @@ _slang_gen_asm(slang_assemble_ctx *A, slang_operation *oper,
dest_oper = &oper->children[0]; dest_oper = &oper->children[0];
writemask = resolve_writemask(dest_oper); writemask = resolve_writemask(A, dest_oper);
n0 = _slang_gen_operation(A, dest_oper); n0 = _slang_gen_operation(A, dest_oper);
if (!n0) if (!n0)
@@ -1980,6 +1992,12 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
fun = _slang_locate_struct_constructor(A, name); fun = _slang_locate_struct_constructor(A, name);
} }
/*
* At this point, some heuristics are used to try to find a function
* that matches the calling signature by means of casting or "unrolling"
* of constructors.
*/
if (!fun && _slang_is_vec_mat_type(name)) { if (!fun && _slang_is_vec_mat_type(name)) {
/* Next, if this call looks like a vec() or mat() constructor call, /* Next, if this call looks like a vec() or mat() constructor call,
* try "unwinding" the args to satisfy a constructor. * try "unwinding" the args to satisfy a constructor.
@@ -1995,7 +2013,7 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
} }
} }
if (!fun) { if (!fun && _slang_is_vec_mat_type(name)) {
/* Next, try casting args to the types of the formal parameters */ /* Next, try casting args to the types of the formal parameters */
int numArgs = oper->num_children; int numArgs = oper->num_children;
fun = _slang_find_function_by_argc(A->space.funcs, name, numArgs); fun = _slang_find_function_by_argc(A->space.funcs, name, numArgs);
@@ -2008,6 +2026,13 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
assert(fun); assert(fun);
} }
if (!fun) {
slang_info_log_error(A->log,
"Function '%s' not found (check argument types)",
name);
return NULL;
}
n = _slang_gen_function_call(A, fun, oper, dest); n = _slang_gen_function_call(A, fun, oper, dest);
if (n && !n->Store && !dest if (n && !n->Store && !dest
@@ -2716,7 +2741,11 @@ _slang_assignment_compatible(slang_assemble_ctx *A,
slang_typeinfo t0, t1; slang_typeinfo t0, t1;
GLuint sz0, sz1; GLuint sz0, sz1;
if (op0->type == SLANG_OPER_POSTINCREMENT ||
op0->type == SLANG_OPER_POSTDECREMENT) {
return GL_FALSE;
}
slang_typeinfo_construct(&t0); slang_typeinfo_construct(&t0);
_slang_typeof_operation(A, op0, &t0); _slang_typeof_operation(A, op0, &t0);
@@ -3020,7 +3049,7 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
if (lhs && rhs) { if (lhs && rhs) {
/* convert lhs swizzle into writemask */ /* convert lhs swizzle into writemask */
GLuint writemask, newSwizzle; GLuint writemask, newSwizzle;
if (!swizzle_to_writemask(lhs->Store->Swizzle, if (!swizzle_to_writemask(A, lhs->Store->Swizzle,
&writemask, &newSwizzle)) { &writemask, &newSwizzle)) {
/* Non-simple writemask, need to swizzle right hand side in /* Non-simple writemask, need to swizzle right hand side in
* order to put components into the right place. * order to put components into the right place.

View File

@@ -108,7 +108,9 @@ writemask_to_swizzle(GLuint writemask)
/** /**
* Swizzle a swizzle. That is, return swz2(swz1) * Swizzle a swizzle (function composition).
* That is, return swz2(swz1), or said another way: swz1.szw2
* Example: swizzle_swizzle(".zwxx", ".xxyw") yields ".zzwx"
*/ */
GLuint GLuint
_slang_swizzle_swizzle(GLuint swz1, GLuint swz2) _slang_swizzle_swizzle(GLuint swz1, GLuint swz2)
@@ -279,7 +281,7 @@ storage_to_src_reg(struct prog_src_register *src, const slang_ir_storage *st)
while (st->Parent) { while (st->Parent) {
st = st->Parent; st = st->Parent;
index += st->Index; index += st->Index;
swizzle = _slang_swizzle_swizzle(st->Swizzle, swizzle); swizzle = _slang_swizzle_swizzle(fix_swizzle(st->Swizzle), swizzle);
} }
assert(st->File >= 0); assert(st->File >= 0);
@@ -1636,6 +1638,88 @@ emit_struct_field(slang_emit_info *emitInfo, slang_ir_node *n)
} }
/**
* Emit code for a variable declaration.
* This usually doesn't result in any code generation, but just
* memory allocation.
*/
static struct prog_instruction *
emit_var_decl(slang_emit_info *emitInfo, slang_ir_node *n)
{
struct prog_instruction *inst;
assert(n->Store);
assert(n->Store->File != PROGRAM_UNDEFINED);
assert(n->Store->Size > 0);
/*assert(n->Store->Index < 0);*/
if (!n->Var || n->Var->isTemp) {
/* a nameless/temporary variable, will be freed after first use */
/*NEW*/
if (n->Store->Index < 0 && !_slang_alloc_temp(emitInfo->vt, n->Store)) {
slang_info_log_error(emitInfo->log,
"Ran out of registers, too many temporaries");
return NULL;
}
}
else {
/* a regular variable */
_slang_add_variable(emitInfo->vt, n->Var);
if (!_slang_alloc_var(emitInfo->vt, n->Store)) {
slang_info_log_error(emitInfo->log,
"Ran out of registers, too many variables");
return NULL;
}
/*
printf("IR_VAR_DECL %s %d store %p\n",
(char*) n->Var->a_name, n->Store->Index, (void*) n->Store);
*/
assert(n->Var->aux == n->Store);
}
if (emitInfo->EmitComments) {
/* emit NOP with comment describing the variable's storage location */
char s[1000];
sprintf(s, "TEMP[%d]%s = variable %s (size %d)",
n->Store->Index,
_mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
(n->Var ? (char *) n->Var->a_name : "anonymous"),
n->Store->Size);
inst = emit_comment(emitInfo, s);
return inst;
}
return NULL;
}
/**
* Emit code for a reference to a variable.
* Actually, no code is generated but we may do some memory alloation.
* In particular, state vars (uniforms) are allocated on an as-needed basis.
*/
static struct prog_instruction *
emit_var_ref(slang_emit_info *emitInfo, slang_ir_node *n)
{
assert(n->Store);
assert(n->Store->File != PROGRAM_UNDEFINED);
if (n->Store->File == PROGRAM_STATE_VAR && n->Store->Index < 0) {
n->Store->Index = _slang_alloc_statevar(n, emitInfo->prog->Parameters);
}
else if (n->Store->File == PROGRAM_UNIFORM) {
/* mark var as used */
_mesa_use_uniform(emitInfo->prog->Parameters, (char *) n->Var->a_name);
}
if (n->Store->Index < 0) {
/* probably ran out of registers */
return NULL;
}
assert(n->Store->Size > 0);
return NULL;
}
static struct prog_instruction * static struct prog_instruction *
emit(slang_emit_info *emitInfo, slang_ir_node *n) emit(slang_emit_info *emitInfo, slang_ir_node *n)
{ {
@@ -1671,64 +1755,14 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
case IR_VAR_DECL: case IR_VAR_DECL:
/* Variable declaration - allocate a register for it */ /* Variable declaration - allocate a register for it */
assert(n->Store); inst = emit_var_decl(emitInfo, n);
assert(n->Store->File != PROGRAM_UNDEFINED); return inst;
assert(n->Store->Size > 0);
/*assert(n->Store->Index < 0);*/
if (!n->Var || n->Var->isTemp) {
/* a nameless/temporary variable, will be freed after first use */
/*NEW*/
if (n->Store->Index < 0 && !_slang_alloc_temp(emitInfo->vt, n->Store)) {
slang_info_log_error(emitInfo->log,
"Ran out of registers, too many temporaries");
return NULL;
}
}
else {
/* a regular variable */
_slang_add_variable(emitInfo->vt, n->Var);
if (!_slang_alloc_var(emitInfo->vt, n->Store)) {
slang_info_log_error(emitInfo->log,
"Ran out of registers, too many variables");
return NULL;
}
/*
printf("IR_VAR_DECL %s %d store %p\n",
(char*) n->Var->a_name, n->Store->Index, (void*) n->Store);
*/
assert(n->Var->aux == n->Store);
}
if (emitInfo->EmitComments) {
/* emit NOP with comment describing the variable's storage location */
char s[1000];
sprintf(s, "TEMP[%d]%s = variable %s (size %d)",
n->Store->Index,
_mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
(n->Var ? (char *) n->Var->a_name : "anonymous"),
n->Store->Size);
inst = emit_comment(emitInfo, s);
return inst;
}
return NULL;
case IR_VAR: case IR_VAR:
/* Reference to a variable /* Reference to a variable
* Storage should have already been resolved/allocated. * Storage should have already been resolved/allocated.
*/ */
assert(n->Store); return emit_var_ref(emitInfo, n);
assert(n->Store->File != PROGRAM_UNDEFINED);
if (n->Store->File == PROGRAM_STATE_VAR &&
n->Store->Index < 0) {
n->Store->Index = _slang_alloc_statevar(n, emitInfo->prog->Parameters);
}
if (n->Store->Index < 0) {
/* probably ran out of registers */
return NULL;
}
assert(n->Store->Size > 0);
break;
case IR_ELEMENT: case IR_ELEMENT:
return emit_array_element(emitInfo, n); return emit_array_element(emitInfo, n);
@@ -1939,6 +1973,7 @@ _slang_emit_code(slang_ir_node *n, slang_var_table *vt,
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
GLboolean success; GLboolean success;
slang_emit_info emitInfo; slang_emit_info emitInfo;
GLuint maxUniforms;
emitInfo.log = log; emitInfo.log = log;
emitInfo.vt = vt; emitInfo.vt = vt;
@@ -1955,6 +1990,19 @@ _slang_emit_code(slang_ir_node *n, slang_var_table *vt,
emitInfo.EmitHighLevelInstructions = GL_TRUE; emitInfo.EmitHighLevelInstructions = GL_TRUE;
} }
/* Check uniform/constant limits */
if (prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
maxUniforms = ctx->Const.FragmentProgram.MaxUniformComponents / 4;
}
else {
assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
maxUniforms = ctx->Const.VertexProgram.MaxUniformComponents / 4;
}
if (prog->Parameters->NumParameters > maxUniforms) {
slang_info_log_error(log, "Constant/uniform register limit exceeded");
return GL_FALSE;
}
(void) emit(&emitInfo, n); (void) emit(&emitInfo, n);
/* finish up by adding the END opcode to program */ /* finish up by adding the END opcode to program */

View File

@@ -173,7 +173,7 @@ link_uniform_vars(struct gl_shader_program *shProg,
* Furthermore, we'll need to fix the state-var's size/datatype info. * Furthermore, we'll need to fix the state-var's size/datatype info.
*/ */
if (p->Type == PROGRAM_UNIFORM || if ((p->Type == PROGRAM_UNIFORM && p->Used) ||
p->Type == PROGRAM_SAMPLER) { p->Type == PROGRAM_SAMPLER) {
_mesa_append_uniform(shProg->Uniforms, p->Name, prog->Target, i); _mesa_append_uniform(shProg->Uniforms, p->Name, prog->Target, i);
} }