Merge git://proxy01.pd.intel.com:9419/git/mesa/mesa into crestline

This commit is contained in:
Nian Wu 2007-03-20 13:10:46 +08:00
commit 76444d042c
10 changed files with 913 additions and 466 deletions

View file

@ -581,11 +581,7 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
}
/* set GLframebuffer size to match window, if needed */
if (intel_fb->Base.Width != driDrawPriv->w) {
_mesa_resize_framebuffer(&intel->ctx, &intel_fb->Base,
driDrawPriv->w, driDrawPriv->h);
}
if (readFb->Width != driReadPriv->w) {
if (driReadPriv != driDrawPriv && readFb->Width != driReadPriv->w) {
_mesa_resize_framebuffer(&intel->ctx, readFb,
driReadPriv->w, driReadPriv->h);
}

View file

@ -48,6 +48,7 @@
static void
nouveauBindProgram(GLcontext *ctx, GLenum target, struct gl_program *prog)
{
NVSDBG("target=%s, prog=%p\n", _mesa_lookup_enum_by_nr(target), prog);
}
static struct gl_program *
@ -55,7 +56,10 @@ nouveauNewProgram(GLcontext *ctx, GLenum target, GLuint id)
{
nouveauShader *nvs;
NVSDBG("target=%s, id=%d\n", _mesa_lookup_enum_by_nr(target), id);
nvs = CALLOC_STRUCT(_nouveauShader);
NVSDBG("prog=%p\n", nvs);
switch (target) {
case GL_VERTEX_PROGRAM_ARB:
return _mesa_init_vertex_program(ctx, &nvs->mesa.vp, target, id);
@ -75,6 +79,8 @@ nouveauDeleteProgram(GLcontext *ctx, struct gl_program *prog)
{
nouveauShader *nvs = (nouveauShader *)prog;
NVSDBG("prog=%p\n", prog);
if (nvs->translated)
FREE(nvs->program);
_mesa_delete_program(ctx, prog);
@ -86,9 +92,13 @@ nouveauProgramStringNotify(GLcontext *ctx, GLenum target,
{
nouveauShader *nvs = (nouveauShader *)prog;
NVSDBG("target=%s, prog=%p\n", _mesa_lookup_enum_by_nr(target), prog);
if (nvs->translated)
FREE(nvs->program);
nvs->translated = 0;
nvs->error = GL_FALSE;
nvs->translated = GL_FALSE;
_tnl_program_string(ctx, target, prog);
}
@ -98,6 +108,8 @@ nouveauIsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
{
nouveauShader *nvs = (nouveauShader *)prog;
NVSDBG("target=%s, prog=%p\n", _mesa_lookup_enum_by_nr(target), prog);
return nvs->translated;
}
@ -108,6 +120,8 @@ nvsUpdateShader(GLcontext *ctx, nouveauShader *nvs)
struct gl_program_parameter_list *plist;
int i;
NVSDBG("prog=%p\n", nvs);
/* Translate to HW format now if necessary */
if (!nvs->translated) {
/* Mesa ASM shader -> nouveauShader */

View file

@ -4,6 +4,12 @@
#include "mtypes.h"
#include "bufferobj.h"
#define NVSDBG(fmt, args...) do { \
if (NOUVEAU_DEBUG & DEBUG_SHADERS) { \
fprintf(stderr, "%s: "fmt, __func__, ##args); \
} \
} while(0)
typedef struct _nvsFunc nvsFunc;
#define NVS_MAX_TEMPS 32
@ -45,6 +51,7 @@ typedef struct _nouveauShader {
nvsFunc *func;
/* State of the final program */
GLboolean error;
GLboolean translated;
GLboolean on_hardware;
unsigned int *program;
@ -418,6 +425,12 @@ nvsSwizzle(nvsRegister reg, nvsSwzComp x, nvsSwzComp y,
return reg;
}
#define nvsProgramError(nvs,fmt,args...) do { \
fprintf(stderr, "nvsProgramError (%s): "fmt, __func__, ##args); \
(nvs)->error = GL_TRUE; \
(nvs)->translated = GL_FALSE; \
} while(0)
extern GLboolean nvsUpdateShader(GLcontext *ctx, nouveauShader *nvs);
extern void nvsDisasmHWShader(nvsPtr);
extern void nvsDumpFragmentList(nvsFragmentHeader *f, int lvl);

View file

@ -924,7 +924,7 @@ pass0_rebase_mesa_consts(nouveauShader *nvs)
}
}
static void
static GLboolean
pass0_resolve_mesa_consts(nouveauShader *nvs)
{
struct pass0_rec *rec = nvs->pass_rec;
@ -945,6 +945,11 @@ pass0_resolve_mesa_consts(nouveauShader *nvs)
for (i=0; i<plist->NumParameters; i++) {
int hw = rec->mesa_const_base + i;
if (hw > NVS_MAX_CONSTS) {
nvsProgramError(nvs, "hw = %d > NVS_MAX_CONSTS!\n", hw);
return GL_FALSE;
}
switch (plist->Parameters[i].Type) {
case PROGRAM_NAMED_PARAM:
case PROGRAM_STATE_VAR:
@ -958,10 +963,13 @@ pass0_resolve_mesa_consts(nouveauShader *nvs)
COPY_4V(nvs->params[hw].val, plist->ParameterValues[i]);
break;
default:
assert(0);
break;
nvsProgramError(nvs, "hit bad type=%d on param %d\n",
plist->Parameters[i].Type, i);
return GL_FALSE;
}
}
return GL_TRUE;
}
GLboolean
@ -974,6 +982,16 @@ nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs)
struct pass0_rec *rec;
int ret = GL_FALSE;
NVSDBG("start: nvs=%p\n", nvs);
/* Previously detected an error, and haven't recieved new program
* string, so fail immediately.
*/
if (nvs->error) {
NVSDBG("failed previous compile attempt, not retrying\n");
return GL_FALSE;
}
rec = CALLOC_STRUCT(pass0_rec);
if (!rec)
return GL_FALSE;
@ -1018,7 +1036,8 @@ nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs)
ret = pass0_translate_instructions(nvs, 0, 0, nvs->program_tree);
if (ret)
pass0_resolve_mesa_consts(nvs);
ret = pass0_resolve_mesa_consts(nvs);
/*XXX: if (!ret) DESTROY TREE!!! */
FREE(rec);

View file

@ -2,11 +2,13 @@
#include "macros.h"
#include "enums.h"
#include "nouveau_context.h"
#include "nouveau_shader.h"
GLboolean
nouveau_shader_pass1(nvsPtr nvs)
{
NVSDBG("start: nvs=%p\n", nvs);
return GL_TRUE;
}

View file

@ -209,6 +209,8 @@ nouveau_shader_pass2(nvsPtr nvs)
struct pass2_rec *rec;
int i;
NVSDBG("start: nvs=%p\n", nvs);
rec = calloc(1, sizeof(struct pass2_rec));
for (i=0; i<NVS_MAX_TEMPS; i++)
rec->temps[i] = -1;

View file

@ -124,7 +124,7 @@ nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id,
while (time <= timeout) {
if (n[NV_NOTIFY_STATE/4] & NV_NOTIFY_STATE_ERROR_CODE_MASK) {
MESSAGE("Notifier returned error: 0x%04x\n",
n[NV_NOTIFY_STATE] &
n[NV_NOTIFY_STATE/4] &
NV_NOTIFY_STATE_ERROR_CODE_MASK);
return GL_FALSE;
}

View file

@ -647,38 +647,89 @@ struct r300_vertex_program_cont {
#define PFS_NUM_TEMP_REGS 32
#define PFS_NUM_CONST_REGS 16
/* Tracking data for Mesa registers */
/* Mapping Mesa registers to R300 temporaries */
struct reg_acc {
int reg; /* Assigned hw temp */
unsigned int refcount; /* Number of uses by mesa program */
};
struct r300_pfs_compile_state {
int v_pos, s_pos; /* highest ALU slots used */
/* Track some information gathered during opcode
* construction.
*
* NOTE: Data is only set by the code, and isn't used yet.
*/
struct {
int vsrc[3];
int ssrc[3];
int umask;
} slot[PFS_MAX_ALU_INST];
/* Used to map Mesa's inputs/temps onto hardware temps */
int temp_in_use;
struct reg_acc temps[PFS_NUM_TEMP_REGS];
struct reg_acc inputs[32]; /* don't actually need 32... */
/* Track usage of hardware temps, for register allocation,
* indirection detection, etc. */
int hwreg_in_use;
GLuint used_in_node;
GLuint dest_in_node;
/**
* Describe the current lifetime information for an R300 temporary
*/
struct reg_lifetime {
/* Index of the first slot where this register is free in the sense
that it can be used as a new destination register.
This is -1 if the register has been assigned to a Mesa register
and the last access to the register has not yet been emitted */
int free;
/* Index of the first slot where this register is currently reserved.
This is used to stop e.g. a scalar operation from being moved
before the allocation time of a register that was first allocated
for a vector operation. */
int reserved;
/* Index of the first slot in which the register can be used as a
source without losing the value that is written by the last
emitted instruction that writes to the register */
int vector_valid;
int scalar_valid;
/* Index to the slot where the register was last read.
This is also the first slot in which the register may be written again */
int vector_lastread;
int scalar_lastread;
};
/**
* Store usage information about an ALU instruction slot during the
* compilation of a fragment program.
*/
#define SLOT_SRC_VECTOR (1<<0)
#define SLOT_SRC_SCALAR (1<<3)
#define SLOT_SRC_BOTH (SLOT_SRC_VECTOR | SLOT_SRC_SCALAR)
#define SLOT_OP_VECTOR (1<<16)
#define SLOT_OP_SCALAR (1<<17)
#define SLOT_OP_BOTH (SLOT_OP_VECTOR | SLOT_OP_SCALAR)
struct r300_pfs_compile_slot {
/* Bitmask indicating which parts of the slot are used, using SLOT_ constants
defined above */
unsigned int used;
/* Selected sources */
int vsrc[3];
int ssrc[3];
};
/**
* Store information during compilation of fragment programs.
*/
struct r300_pfs_compile_state {
int nrslots; /* number of ALU slots used so far */
/* Track which (parts of) slots are already filled with instructions */
struct r300_pfs_compile_slot slot[PFS_MAX_ALU_INST];
/* Track the validity of R300 temporaries */
struct reg_lifetime hwtemps[PFS_NUM_TEMP_REGS];
/* Used to map Mesa's inputs/temps onto hardware temps */
int temp_in_use;
struct reg_acc temps[PFS_NUM_TEMP_REGS];
struct reg_acc inputs[32]; /* don't actually need 32... */
/* Track usage of hardware temps, for register allocation,
* indirection detection, etc. */
GLuint used_in_node;
GLuint dest_in_node;
};
/**
* Store everything about a fragment program that is needed
* to render with that program.
*/
struct r300_fragment_program {
struct gl_fragment_program mesa_program;
@ -716,23 +767,21 @@ struct r300_fragment_program {
int tex_offset;
int tex_end;
/* Hardware constants */
GLfloat constant[PFS_NUM_CONST_REGS][4];
/* Hardware constants.
* Contains a pointer to the value. The destination of the pointer
* is supposed to be updated when GL state changes.
* Typically, this is either a pointer into
* gl_program_parameter_list::ParameterValues, or a pointer to a
* global constant (e.g. for sin/cos-approximation)
*/
const GLfloat* constant[PFS_NUM_CONST_REGS];
int const_nr;
/* Tracked parameters */
struct {
int idx; /* hardware index */
GLfloat *values; /* pointer to values */
} param[PFS_NUM_CONST_REGS];
int param_nr;
GLboolean params_uptodate;
int max_temp_idx;
/* the index of the sin constant is stored here */
GLint const_sin[2];
GLuint optimization;
};

File diff suppressed because it is too large Load diff

View file

@ -1047,7 +1047,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* WRT swizzling. If, for example, you want to load an R component into an
* Alpha operand, this R component is taken from a *color* source, not from
* an alpha source. The corresponding register doesn't even have to appear in
* the alpha sources list. (I hope this alll makes sense to you)
* the alpha sources list. (I hope this all makes sense to you)
*
* Destination selection
* The destination register index is in FPI1 (color) and FPI3 (alpha)
@ -1074,6 +1074,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_FPI1_SRC2C_SHIFT 12
# define R300_FPI1_SRC2C_MASK (31 << 12)
# define R300_FPI1_SRC2C_CONST (1 << 17)
# define R300_FPI1_SRC_MASK 0x0003ffff
# define R300_FPI1_DSTC_SHIFT 18
# define R300_FPI1_DSTC_MASK (31 << 18)
# define R300_FPI1_DSTC_REG_MASK_SHIFT 23
@ -1095,6 +1096,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_FPI3_SRC2A_SHIFT 12
# define R300_FPI3_SRC2A_MASK (31 << 12)
# define R300_FPI3_SRC2A_CONST (1 << 17)
# define R300_FPI3_SRC_MASK 0x0003ffff
# define R300_FPI3_DSTA_SHIFT 18
# define R300_FPI3_DSTA_MASK (31 << 18)
# define R300_FPI3_DSTA_REG (1 << 23)