Merge commit 'origin/gallium-0.1' into gallium-0.2
This commit is contained in:
@@ -178,6 +178,92 @@ void draw_pt_destroy( struct draw_context *draw )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Debug- print the first 'count' vertices.
|
||||
*/
|
||||
static void
|
||||
draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count)
|
||||
{
|
||||
uint i;
|
||||
|
||||
debug_printf("Draw arrays(prim = %u, start = %u, count = %u)\n",
|
||||
prim, start, count);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
uint ii, j;
|
||||
|
||||
if (draw->pt.user.elts) {
|
||||
/* indexed arrays */
|
||||
switch (draw->pt.user.eltSize) {
|
||||
case 1:
|
||||
{
|
||||
const ubyte *elem = (const ubyte *) draw->pt.user.elts;
|
||||
ii = elem[start + i];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
const ushort *elem = (const ushort *) draw->pt.user.elts;
|
||||
ii = elem[start + i];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
const uint *elem = (const uint *) draw->pt.user.elts;
|
||||
ii = elem[start + i];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
debug_printf("Element[%u + %u] -> Vertex %u:\n", start, i, ii);
|
||||
}
|
||||
else {
|
||||
/* non-indexed arrays */
|
||||
ii = start + i;
|
||||
debug_printf("Vertex %u:\n", ii);
|
||||
}
|
||||
|
||||
for (j = 0; j < draw->pt.nr_vertex_elements; j++) {
|
||||
uint buf = draw->pt.vertex_element[j].vertex_buffer_index;
|
||||
ubyte *ptr = (ubyte *) draw->pt.user.vbuffer[buf];
|
||||
ptr += draw->pt.vertex_buffer[buf].pitch * ii;
|
||||
ptr += draw->pt.vertex_element[j].src_offset;
|
||||
|
||||
debug_printf(" Attr %u: ", j);
|
||||
switch (draw->pt.vertex_element[j].src_format) {
|
||||
case PIPE_FORMAT_R32_FLOAT:
|
||||
{
|
||||
float *v = (float *) ptr;
|
||||
debug_printf("%f @ %p\n", v[0], (void *) v);
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_R32G32_FLOAT:
|
||||
{
|
||||
float *v = (float *) ptr;
|
||||
debug_printf("%f %f @ %p\n", v[0], v[1], (void *) v);
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_R32G32B32_FLOAT:
|
||||
{
|
||||
float *v = (float *) ptr;
|
||||
debug_printf("%f %f %f @ %p\n", v[0], v[1], v[2], (void *) v);
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_R32G32B32A32_FLOAT:
|
||||
{
|
||||
float *v = (float *) ptr;
|
||||
debug_printf("%f %f %f %f @ %p\n", v[0], v[1], v[2], v[3],
|
||||
(void *) v);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
debug_printf("other format (fix me)\n");
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -197,6 +283,9 @@ draw_arrays(struct draw_context *draw, unsigned prim,
|
||||
draw->reduced_prim = reduced_prim;
|
||||
}
|
||||
|
||||
if (0)
|
||||
draw_print_arrays(draw, prim, start, MIN2(count, 20));
|
||||
|
||||
#if 0
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1045,12 +1045,16 @@ fetch_source(
|
||||
if (reg->SrcRegister.Indirect) {
|
||||
union tgsi_exec_channel index2;
|
||||
union tgsi_exec_channel indir_index;
|
||||
const uint execmask = mach->ExecMask;
|
||||
uint i;
|
||||
|
||||
/* which address register (always zero now) */
|
||||
index2.i[0] =
|
||||
index2.i[1] =
|
||||
index2.i[2] =
|
||||
index2.i[3] = reg->SrcRegisterInd.Index;
|
||||
|
||||
/* get current value of address register[swizzle] */
|
||||
swizzle = tgsi_util_get_src_register_swizzle( ®->SrcRegisterInd, CHAN_X );
|
||||
fetch_src_file_channel(
|
||||
mach,
|
||||
@@ -1059,10 +1063,19 @@ fetch_source(
|
||||
&index2,
|
||||
&indir_index );
|
||||
|
||||
/* add value of address register to the offset */
|
||||
index.i[0] += indir_index.i[0];
|
||||
index.i[1] += indir_index.i[1];
|
||||
index.i[2] += indir_index.i[2];
|
||||
index.i[3] += indir_index.i[3];
|
||||
|
||||
/* for disabled execution channels, zero-out the index to
|
||||
* avoid using a potential garbage value.
|
||||
*/
|
||||
for (i = 0; i < QUAD_SIZE; i++) {
|
||||
if ((execmask & (1 << i)) == 0)
|
||||
index.i[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if( reg->SrcRegister.Dimension ) {
|
||||
@@ -1091,6 +1104,8 @@ fetch_source(
|
||||
if (reg->SrcRegisterDim.Indirect) {
|
||||
union tgsi_exec_channel index2;
|
||||
union tgsi_exec_channel indir_index;
|
||||
const uint execmask = mach->ExecMask;
|
||||
uint i;
|
||||
|
||||
index2.i[0] =
|
||||
index2.i[1] =
|
||||
@@ -1109,6 +1124,14 @@ fetch_source(
|
||||
index.i[1] += indir_index.i[1];
|
||||
index.i[2] += indir_index.i[2];
|
||||
index.i[3] += indir_index.i[3];
|
||||
|
||||
/* for disabled execution channels, zero-out the index to
|
||||
* avoid using a potential garbage value.
|
||||
*/
|
||||
for (i = 0; i < QUAD_SIZE; i++) {
|
||||
if ((execmask & (1 << i)) == 0)
|
||||
index.i[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,17 +153,21 @@ check_register_usage(
|
||||
if (!check_file_name( ctx, file ))
|
||||
return FALSE;
|
||||
|
||||
if (index < 0 || index > MAX_REGISTERS) {
|
||||
report_error( ctx, "%s[%i]: Invalid index %s", file_names[file], index, name );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (indirect_access) {
|
||||
/* Note that 'index' is an offset relative to the value of the
|
||||
* address register. No range checking done here.
|
||||
*/
|
||||
if (!is_any_register_declared( ctx, file ))
|
||||
report_error( ctx, "%s: Undeclared %s register", file_names[file], name );
|
||||
ctx->regs_ind_used[file] = TRUE;
|
||||
}
|
||||
else {
|
||||
if (index < 0 || index > MAX_REGISTERS) {
|
||||
report_error( ctx, "%s[%i]: Invalid index %s",
|
||||
file_names[file], index, name );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!is_register_declared( ctx, file, index ))
|
||||
report_error( ctx, "%s[%d]: Undeclared %s register", file_names[file], index, name );
|
||||
ctx->regs_used[file][index / BITS_IN_REG_FLAG] |= (1 << (index % BITS_IN_REG_FLAG));
|
||||
|
||||
@@ -64,6 +64,14 @@ output_quad(struct quad_stage *qs, struct quad_header *quad)
|
||||
for (i = 0; i < 4; i++) { /* loop over color chans */
|
||||
tile->data.color[y][x][i] = quadColor[i][j];
|
||||
}
|
||||
if (0) {
|
||||
debug_printf("sp write pixel %d,%d: %g, %g, %g\n",
|
||||
quad->input.x0 + x,
|
||||
quad->input.y0 + y,
|
||||
quadColor[0][j],
|
||||
quadColor[1][j],
|
||||
quadColor[2][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1422,10 +1422,22 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
|
||||
|
||||
|
||||
/**
|
||||
* Update the vertex and fragment program's TexturesUsed arrays.
|
||||
* Update the vertex/fragment program's TexturesUsed array.
|
||||
*
|
||||
* This needs to be called after glUniform(set sampler var) is called.
|
||||
* A call to glUniform(samplerVar, value) causes a sampler to point to a
|
||||
* particular texture unit. We know the sampler's texture target
|
||||
* (1D/2D/3D/etc) from compile time but the sampler's texture unit is
|
||||
* set by glUniform() calls.
|
||||
*
|
||||
* So, scan the program->SamplerUnits[] and program->SamplerTargets[]
|
||||
* information to update the prog->TexturesUsed[] values.
|
||||
* Each value of TexturesUsed[unit] is one of zero, TEXTURE_1D_INDEX,
|
||||
* TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc.
|
||||
* We'll use that info for state validation before rendering.
|
||||
*/
|
||||
static void
|
||||
update_textures_used(struct gl_program *prog)
|
||||
void
|
||||
_mesa_update_shader_textures_used(struct gl_program *prog)
|
||||
{
|
||||
GLuint s;
|
||||
|
||||
@@ -1551,7 +1563,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
|
||||
|
||||
/* This maps a sampler to a texture unit: */
|
||||
program->SamplerUnits[sampler] = texUnit;
|
||||
update_textures_used(program);
|
||||
_mesa_update_shader_textures_used(program);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@ extern struct gl_shader *
|
||||
_mesa_lookup_shader(GLcontext *ctx, GLuint name);
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_update_shader_textures_used(struct gl_program *prog);
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_use_program(GLcontext *ctx, GLuint program);
|
||||
|
||||
|
||||
@@ -561,6 +561,9 @@ _slang_link(GLcontext *ctx,
|
||||
|
||||
|
||||
if (fragProg && shProg->FragmentProgram) {
|
||||
/* Compute initial program's TexturesUsed info */
|
||||
_mesa_update_shader_textures_used(&shProg->FragmentProgram->Base);
|
||||
|
||||
/* notify driver that a new fragment program has been compiled/linked */
|
||||
ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
|
||||
&shProg->FragmentProgram->Base);
|
||||
@@ -576,6 +579,9 @@ _slang_link(GLcontext *ctx,
|
||||
}
|
||||
|
||||
if (vertProg && shProg->VertexProgram) {
|
||||
/* Compute initial program's TexturesUsed info */
|
||||
_mesa_update_shader_textures_used(&shProg->VertexProgram->Base);
|
||||
|
||||
/* notify driver that a new vertex program has been compiled/linked */
|
||||
ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
|
||||
&shProg->VertexProgram->Base);
|
||||
|
||||
@@ -512,3 +512,19 @@ st_translate_fragment_program(struct st_context *st,
|
||||
tgsi_dump( fs.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Debug- print current shader text
|
||||
*/
|
||||
void
|
||||
st_print_shaders(GLcontext *ctx)
|
||||
{
|
||||
struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
|
||||
if (shProg) {
|
||||
GLuint i;
|
||||
for (i = 0; i < shProg->NumShaders; i++) {
|
||||
printf("GLSL shader %u of %u:\n", i, shProg->NumShaders);
|
||||
printf("%s\n", shProg->Shaders[i]->Source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,4 +151,8 @@ st_translate_vertex_program(struct st_context *st,
|
||||
const ubyte *fs_input_semantic_index);
|
||||
|
||||
|
||||
extern void
|
||||
st_print_shaders(GLcontext *ctx);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user