Checkpoint work for new GLSL compiler back-end.
Among changes: Remove ctx->FragmentProgram._Active Remove _UseTexEnvProgram Move _MaintainTnlProgram, _MaintainTexEnvProgram, _TexEnvProgram and _TnlProgram fields. Remove/disable old GLSL interpreter code.
This commit is contained in:
@@ -86,7 +86,7 @@ _tnl_CreateContext( GLcontext *ctx )
|
||||
_tnl_array_init( ctx );
|
||||
_tnl_vtx_init( ctx );
|
||||
|
||||
if (ctx->_MaintainTnlProgram) {
|
||||
if (ctx->VertexProgram._MaintainTnlProgram) {
|
||||
_tnl_ProgramCacheInit( ctx );
|
||||
_tnl_install_pipeline( ctx, _tnl_vp_pipeline );
|
||||
} else {
|
||||
@@ -136,7 +136,7 @@ _tnl_DestroyContext( GLcontext *ctx )
|
||||
_tnl_destroy_pipeline( ctx );
|
||||
_ae_destroy_context( ctx );
|
||||
|
||||
if (ctx->_MaintainTnlProgram)
|
||||
if (ctx->VertexProgram._MaintainTnlProgram)
|
||||
_tnl_ProgramCacheDestroy( ctx );
|
||||
|
||||
FREE(tnl);
|
||||
@@ -183,7 +183,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
|
||||
}
|
||||
|
||||
if (ctx->Fog.Enabled ||
|
||||
(ctx->FragmentProgram._Active &&
|
||||
(ctx->FragmentProgram._Current &&
|
||||
(ctx->FragmentProgram._Current->FogOption != GL_NONE ||
|
||||
ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_FOGC)))
|
||||
RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG );
|
||||
@@ -199,8 +199,13 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
|
||||
(ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled))
|
||||
RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE );
|
||||
|
||||
#if NEW_SLANG
|
||||
RENDERINPUTS_SET_RANGE( tnl->render_inputs_bitset,
|
||||
_TNL_FIRST_GENERIC, _TNL_LAST_GENERIC );
|
||||
#else
|
||||
if (ctx->ShaderObjects._VertexShaderPresent || ctx->ShaderObjects._FragmentShaderPresent)
|
||||
RENDERINPUTS_SET_RANGE( tnl->render_inputs_bitset, _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@@ -132,7 +132,7 @@ void _tnl_run_pipeline( GLcontext *ctx )
|
||||
* (ie const or non-const).
|
||||
*/
|
||||
if (check_input_changes( ctx ) || tnl->pipeline.new_state) {
|
||||
if (ctx->_MaintainTnlProgram)
|
||||
if (ctx->VertexProgram._MaintainTnlProgram)
|
||||
_tnl_UpdateFixedFunctionProgram( ctx );
|
||||
|
||||
for (i = 0; i < tnl->pipeline.nr_stages ; i++) {
|
||||
@@ -207,9 +207,6 @@ const struct tnl_pipeline_stage *_tnl_default_pipeline[] = {
|
||||
#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program)
|
||||
&_tnl_arb_vertex_program_stage,
|
||||
&_tnl_vertex_program_stage,
|
||||
#endif
|
||||
#if FEATURE_ARB_vertex_shader
|
||||
&_tnl_arb_vertex_shader_stage,
|
||||
#endif
|
||||
&_tnl_render_stage,
|
||||
NULL
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include "arbprogparse.h"
|
||||
#include "light.h"
|
||||
#include "program.h"
|
||||
#include "programopt.h"
|
||||
#include "math/m_matrix.h"
|
||||
#include "t_context.h"
|
||||
#include "t_pipeline.h"
|
||||
@@ -292,7 +293,7 @@ static void do_EX2( struct arb_vp_machine *m, union instruction op )
|
||||
GLfloat *result = m->File[0][op.alu.dst];
|
||||
const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
|
||||
|
||||
result[0] = (GLfloat)ApproxExp2(arg0[0]);
|
||||
result[0] = ApproxExp2(arg0[0]);
|
||||
PUFF(result);
|
||||
}
|
||||
|
||||
@@ -566,7 +567,7 @@ static void print_reg( GLuint file, GLuint reg )
|
||||
_mesa_printf("TMP%d", reg - REG_TMP0);
|
||||
else if (reg >= REG_IN0 && reg <= REG_IN31)
|
||||
_mesa_printf("IN%d", reg - REG_IN0);
|
||||
else if (reg >= REG_OUT0 && reg <= REG_OUT14)
|
||||
else if (reg >= REG_OUT0 && reg <= REG_OUT23)
|
||||
_mesa_printf("OUT%d", reg - REG_OUT0);
|
||||
else if (reg == REG_ADDR)
|
||||
_mesa_printf("ADDR");
|
||||
@@ -714,6 +715,7 @@ _tnl_disassem_vba_insn( union instruction op )
|
||||
|
||||
static void (* const opcode_func[MAX_OPCODE+3])(struct arb_vp_machine *, union instruction) =
|
||||
{
|
||||
do_NOP,
|
||||
do_ABS,
|
||||
do_ADD,
|
||||
do_NOP,/*ARA*/
|
||||
@@ -853,6 +855,7 @@ static struct reg cvp_load_reg( struct compilation *cp,
|
||||
return reg;
|
||||
|
||||
case PROGRAM_STATE_VAR:
|
||||
case PROGRAM_CONSTANT:
|
||||
reg = cvp_make_reg(FILE_STATE_PARAM, index);
|
||||
if (rel)
|
||||
return cvp_emit_rel(cp, reg, tmpreg);
|
||||
@@ -1058,6 +1061,16 @@ static void compile_vertex_program( struct gl_vertex_program *program,
|
||||
struct tnl_compiled_program *p = CALLOC_STRUCT(tnl_compiled_program);
|
||||
GLuint i;
|
||||
|
||||
#if 1
|
||||
if (!program->IsNVProgram && program->IsPositionInvariant) {
|
||||
printf("Adding MVP code\n");
|
||||
if (!program->Base.Parameters)
|
||||
program->Base.Parameters = _mesa_new_parameter_list();
|
||||
_mesa_insert_mvp_code(NULL, program);
|
||||
program->IsPositionInvariant = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (program->TnlData)
|
||||
free_tnl_data( program );
|
||||
|
||||
@@ -1182,6 +1195,7 @@ do_ndc_cliptest(GLcontext *ctx, struct arb_vp_machine *m)
|
||||
|
||||
/* Test userclip planes. This contributes to VB->ClipMask.
|
||||
*/
|
||||
/** XXX NEW_SLANG _Enabled ??? */
|
||||
if (ctx->Transform.ClipPlanesEnabled && (!ctx->VertexProgram._Enabled ||
|
||||
ctx->VertexProgram.Current->IsPositionInvariant)) {
|
||||
userclip( ctx,
|
||||
@@ -1221,21 +1235,14 @@ static INLINE void call_func( struct tnl_compiled_program *p,
|
||||
static GLboolean
|
||||
run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
const struct gl_vertex_program *program;
|
||||
const struct gl_vertex_program *program = ctx->VertexProgram._Current;
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
|
||||
struct tnl_compiled_program *p;
|
||||
GLuint i, j;
|
||||
GLbitfield outputs;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
|
||||
program = ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : NULL;
|
||||
if (!program && ctx->_MaintainTnlProgram) {
|
||||
program = ctx->_TnlProgram;
|
||||
}
|
||||
if (!program || program->IsNVProgram)
|
||||
if (!program)
|
||||
return GL_TRUE;
|
||||
|
||||
if (program->Base.Parameters) {
|
||||
@@ -1299,12 +1306,13 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
/* If the program is position invariant, multiply the input position
|
||||
* by the MVP matrix and store in the vertex position result register.
|
||||
*/
|
||||
#if 0
|
||||
if (program->IsPositionInvariant) {
|
||||
TRANSFORM_POINT( m->File[0][REG_OUT0+0],
|
||||
ctx->_ModelProjectMatrix.m,
|
||||
m->File[0][REG_IN0+0]);
|
||||
}
|
||||
|
||||
#endif
|
||||
for (j = 0; j < m->nr_outputs; j++) {
|
||||
GLuint idx = REG_OUT0 + m->output[j].idx;
|
||||
m->output[j].data[0] = m->File[0][idx][0];
|
||||
@@ -1370,6 +1378,14 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ctx->Const.MaxVarying; i++) {
|
||||
if (outputs & (1 << (VERT_RESULT_VAR0 + i))) {
|
||||
/* Note: varying results get put into the generic attributes */
|
||||
VB->AttribPtr[VERT_ATTRIB_GENERIC0+i]
|
||||
= &m->attribs[VERT_RESULT_VAR0 + i];
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (i = 0; i < VB->Count; i++) {
|
||||
printf("Out %d: %f %f %f %f %f %f %f %f\n", i,
|
||||
@@ -1394,15 +1410,7 @@ static void
|
||||
validate_vertex_program( GLcontext *ctx, struct tnl_pipeline_stage *stage )
|
||||
{
|
||||
struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
|
||||
struct gl_vertex_program *program;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return;
|
||||
|
||||
program = (ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : 0);
|
||||
if (!program && ctx->_MaintainTnlProgram) {
|
||||
program = ctx->_TnlProgram;
|
||||
}
|
||||
struct gl_vertex_program *program = ctx->VertexProgram._Current;
|
||||
|
||||
if (program) {
|
||||
if (!program->TnlData)
|
||||
@@ -1472,7 +1480,7 @@ static GLboolean init_vertex_program( GLcontext *ctx,
|
||||
_mesa_vector4f_alloc( &m->ndcCoords, 0, size, 32 );
|
||||
m->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
|
||||
|
||||
if (ctx->_MaintainTnlProgram)
|
||||
if (ctx->VertexProgram._MaintainTnlProgram)
|
||||
_mesa_allow_light_in_model( ctx, GL_FALSE );
|
||||
|
||||
m->fpucntl_rnd_neg = RND_NEG_FPU; /* const value */
|
||||
@@ -1529,7 +1537,7 @@ const struct tnl_pipeline_stage _tnl_arb_vertex_program_stage =
|
||||
void
|
||||
_tnl_program_string(GLcontext *ctx, GLenum target, struct gl_program *program)
|
||||
{
|
||||
if (target == GL_VERTEX_PROGRAM_ARB) {
|
||||
if (program->Target == GL_VERTEX_PROGRAM_ARB) {
|
||||
/* free any existing tnl data hanging off the program */
|
||||
struct gl_vertex_program *vprog = (struct gl_vertex_program *) program;
|
||||
if (vprog->TnlData) {
|
||||
|
@@ -56,6 +56,22 @@
|
||||
#define REG_TMP0 5
|
||||
#define REG_TMP11 16
|
||||
#define REG_OUT0 17
|
||||
#define REG_OUT23 40
|
||||
#define REG_IN0 41
|
||||
#define REG_IN31 72
|
||||
#define REG_ID 73 /* 0,0,0,1 */
|
||||
#define REG_ONES 74 /* 1,1,1,1 */
|
||||
#define REG_SWZ 75 /* 1,-1,0,0 */
|
||||
#define REG_NEG 76 /* -1,-1,-1,-1 */
|
||||
#define REG_LIT 77 /* 1,0,0,1 */
|
||||
#define REG_LIT2 78 /* 1,0,0,1 */
|
||||
#define REG_SCRATCH 79 /* internal temporary. XXX we can't actually use this because 70 doesn't fit in the 5-bit 'dst' instruction field! */
|
||||
#define REG_UNDEF 127 /* special case - never used */
|
||||
#define REG_MAX 128
|
||||
#define REG_INVALID ~0
|
||||
|
||||
|
||||
#if 0
|
||||
#define REG_OUT14 31
|
||||
#define REG_IN0 32
|
||||
#define REG_IN31 63
|
||||
@@ -69,6 +85,7 @@
|
||||
#define REG_UNDEF 127 /* special case - never used */
|
||||
#define REG_MAX 128
|
||||
#define REG_INVALID ~0
|
||||
#endif
|
||||
|
||||
/* ARB_vp instructions are broken down into one or more of the
|
||||
* following micro-instructions, each representable in a 64 bit packed
|
||||
@@ -76,16 +93,16 @@
|
||||
*/
|
||||
struct reg {
|
||||
GLuint file:2;
|
||||
GLuint idx:7;
|
||||
GLuint idx:8;
|
||||
};
|
||||
|
||||
|
||||
union instruction {
|
||||
struct {
|
||||
GLuint opcode:7;
|
||||
GLuint dst:5;
|
||||
GLuint dst:6;
|
||||
GLuint file0:2;
|
||||
GLuint idx0:7;
|
||||
GLuint idx0:8;
|
||||
GLuint file1:2;
|
||||
GLuint idx1:7;
|
||||
GLuint pad:2;
|
||||
@@ -94,18 +111,18 @@ union instruction {
|
||||
|
||||
struct {
|
||||
GLuint opcode:7;
|
||||
GLuint dst:5;
|
||||
GLuint dst:6;
|
||||
GLuint file0:2;
|
||||
GLuint idx0:7;
|
||||
GLuint idx0:8;
|
||||
GLuint neg:4;
|
||||
GLuint swz:12; /* xyzw01 */
|
||||
} rsw;
|
||||
|
||||
struct {
|
||||
GLuint opcode:7;
|
||||
GLuint dst:5;
|
||||
GLuint dst:6;
|
||||
GLuint file:2;
|
||||
GLuint idx:7;
|
||||
GLuint idx:8;
|
||||
GLuint mask:4;
|
||||
GLuint pad:7;
|
||||
GLuint pad2;
|
||||
|
@@ -38,264 +38,295 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLvector4f outputs[VERT_RESULT_MAX];
|
||||
GLvector4f varyings[MAX_VARYING_VECTORS];
|
||||
GLvector4f ndc_coords;
|
||||
GLubyte *clipmask;
|
||||
GLubyte ormask;
|
||||
GLubyte andmask;
|
||||
GLvector4f outputs[VERT_RESULT_MAX];
|
||||
GLvector4f varyings[MAX_VARYING_VECTORS];
|
||||
GLvector4f ndc_coords;
|
||||
GLubyte *clipmask;
|
||||
GLubyte ormask;
|
||||
GLubyte andmask;
|
||||
} arbvs_stage_data;
|
||||
|
||||
#define ARBVS_STAGE_DATA(stage) ((arbvs_stage_data *) stage->privatePtr)
|
||||
|
||||
static GLboolean construct_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
static GLboolean
|
||||
construct_arb_vertex_shader(GLcontext * ctx, struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *vb = &tnl->vb;
|
||||
arbvs_stage_data *store;
|
||||
GLuint size = vb->Size;
|
||||
GLuint i;
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *vb = &tnl->vb;
|
||||
arbvs_stage_data *store;
|
||||
GLuint size = vb->Size;
|
||||
GLuint i;
|
||||
|
||||
stage->privatePtr = _mesa_malloc (sizeof (arbvs_stage_data));
|
||||
store = ARBVS_STAGE_DATA(stage);
|
||||
if (store == NULL)
|
||||
return GL_FALSE;
|
||||
stage->privatePtr = _mesa_malloc(sizeof(arbvs_stage_data));
|
||||
store = ARBVS_STAGE_DATA(stage);
|
||||
if (store == NULL)
|
||||
return GL_FALSE;
|
||||
|
||||
for (i = 0; i < VERT_RESULT_MAX; i++)
|
||||
{
|
||||
_mesa_vector4f_alloc (&store->outputs[i], 0, size, 32);
|
||||
store->outputs[i].size = 4;
|
||||
}
|
||||
for (i = 0; i < MAX_VARYING_VECTORS; i++)
|
||||
{
|
||||
_mesa_vector4f_alloc (&store->varyings[i], 0, size, 32);
|
||||
store->varyings[i].size = 4;
|
||||
}
|
||||
_mesa_vector4f_alloc (&store->ndc_coords, 0, size, 32);
|
||||
store->clipmask = (GLubyte *) ALIGN_MALLOC (size, 32);
|
||||
for (i = 0; i < VERT_RESULT_MAX; i++) {
|
||||
_mesa_vector4f_alloc(&store->outputs[i], 0, size, 32);
|
||||
store->outputs[i].size = 4;
|
||||
}
|
||||
for (i = 0; i < MAX_VARYING_VECTORS; i++) {
|
||||
_mesa_vector4f_alloc(&store->varyings[i], 0, size, 32);
|
||||
store->varyings[i].size = 4;
|
||||
}
|
||||
_mesa_vector4f_alloc(&store->ndc_coords, 0, size, 32);
|
||||
store->clipmask = (GLubyte *) ALIGN_MALLOC(size, 32);
|
||||
|
||||
return GL_TRUE;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void destruct_arb_vertex_shader (struct tnl_pipeline_stage *stage)
|
||||
static void
|
||||
destruct_arb_vertex_shader(struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);
|
||||
arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);
|
||||
|
||||
if (store != NULL)
|
||||
{
|
||||
GLuint i;
|
||||
if (store != NULL) {
|
||||
GLuint i;
|
||||
|
||||
for (i = 0; i < VERT_RESULT_MAX; i++)
|
||||
_mesa_vector4f_free (&store->outputs[i]);
|
||||
for (i = 0; i < MAX_VARYING_VECTORS; i++)
|
||||
_mesa_vector4f_free (&store->varyings[i]);
|
||||
_mesa_vector4f_free (&store->ndc_coords);
|
||||
ALIGN_FREE (store->clipmask);
|
||||
for (i = 0; i < VERT_RESULT_MAX; i++)
|
||||
_mesa_vector4f_free(&store->outputs[i]);
|
||||
for (i = 0; i < MAX_VARYING_VECTORS; i++)
|
||||
_mesa_vector4f_free(&store->varyings[i]);
|
||||
_mesa_vector4f_free(&store->ndc_coords);
|
||||
ALIGN_FREE(store->clipmask);
|
||||
|
||||
_mesa_free (store);
|
||||
stage->privatePtr = NULL;
|
||||
}
|
||||
_mesa_free(store);
|
||||
stage->privatePtr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void validate_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
static void
|
||||
validate_arb_vertex_shader(GLcontext * ctx, struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
}
|
||||
|
||||
static GLvoid fetch_input_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
|
||||
struct vertex_buffer *vb)
|
||||
{
|
||||
const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
|
||||
const GLuint stride = vb->AttribPtr[attr]->stride;
|
||||
GLfloat *data = (GLfloat *) (ptr + stride * i);
|
||||
|
||||
(**pro).UpdateFixedAttrib (pro, index, data, 0, sizeof (GLfloat), GL_TRUE);
|
||||
}
|
||||
|
||||
static GLvoid fetch_input_vec3 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
|
||||
struct vertex_buffer *vb)
|
||||
{
|
||||
const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
|
||||
const GLuint stride = vb->AttribPtr[attr]->stride;
|
||||
GLfloat *data = (GLfloat *) (ptr + stride * i);
|
||||
|
||||
(**pro).UpdateFixedAttrib (pro, index, data, 0, 3 * sizeof (GLfloat), GL_TRUE);
|
||||
}
|
||||
|
||||
static void fetch_input_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
|
||||
struct vertex_buffer *vb)
|
||||
{
|
||||
const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
|
||||
const GLuint size = vb->AttribPtr[attr]->size;
|
||||
const GLuint stride = vb->AttribPtr[attr]->stride;
|
||||
const GLfloat *data = (const GLfloat *) (ptr + stride * i);
|
||||
GLfloat vec[4];
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case 2:
|
||||
vec[0] = data[0];
|
||||
vec[1] = data[1];
|
||||
vec[2] = 0.0f;
|
||||
vec[3] = 1.0f;
|
||||
break;
|
||||
case 3:
|
||||
vec[0] = data[0];
|
||||
vec[1] = data[1];
|
||||
vec[2] = data[2];
|
||||
vec[3] = 1.0f;
|
||||
break;
|
||||
case 4:
|
||||
vec[0] = data[0];
|
||||
vec[1] = data[1];
|
||||
vec[2] = data[2];
|
||||
vec[3] = data[3];
|
||||
break;
|
||||
}
|
||||
(**pro).UpdateFixedAttrib (pro, index, vec, 0, 4 * sizeof (GLfloat), GL_TRUE);
|
||||
}
|
||||
|
||||
static GLvoid
|
||||
fetch_gen_attrib (struct gl2_program_intf **pro, GLuint index, GLuint i, struct vertex_buffer *vb)
|
||||
fetch_input_float(struct gl2_program_intf **pro, GLuint index, GLuint attr,
|
||||
GLuint i, struct vertex_buffer *vb)
|
||||
{
|
||||
const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
|
||||
const GLuint stride = vb->AttribPtr[attr]->stride;
|
||||
GLfloat *data = (GLfloat *) (ptr + stride * i);
|
||||
|
||||
(**pro).UpdateFixedAttrib(pro, index, data, 0, sizeof(GLfloat), GL_TRUE);
|
||||
}
|
||||
|
||||
static GLvoid
|
||||
fetch_input_vec3(struct gl2_program_intf **pro, GLuint index, GLuint attr,
|
||||
GLuint i, struct vertex_buffer *vb)
|
||||
{
|
||||
const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
|
||||
const GLuint stride = vb->AttribPtr[attr]->stride;
|
||||
GLfloat *data = (GLfloat *) (ptr + stride * i);
|
||||
|
||||
(**pro).UpdateFixedAttrib(pro, index, data, 0, 3 * sizeof(GLfloat),
|
||||
GL_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
fetch_input_vec4(struct gl2_program_intf **pro, GLuint index, GLuint attr,
|
||||
GLuint i, struct vertex_buffer *vb)
|
||||
{
|
||||
const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
|
||||
const GLuint size = vb->AttribPtr[attr]->size;
|
||||
const GLuint stride = vb->AttribPtr[attr]->stride;
|
||||
const GLfloat *data = (const GLfloat *) (ptr + stride * i);
|
||||
GLfloat vec[4];
|
||||
|
||||
switch (size) {
|
||||
case 2:
|
||||
vec[0] = data[0];
|
||||
vec[1] = data[1];
|
||||
vec[2] = 0.0f;
|
||||
vec[3] = 1.0f;
|
||||
break;
|
||||
case 3:
|
||||
vec[0] = data[0];
|
||||
vec[1] = data[1];
|
||||
vec[2] = data[2];
|
||||
vec[3] = 1.0f;
|
||||
break;
|
||||
case 4:
|
||||
vec[0] = data[0];
|
||||
vec[1] = data[1];
|
||||
vec[2] = data[2];
|
||||
vec[3] = data[3];
|
||||
break;
|
||||
}
|
||||
(**pro).UpdateFixedAttrib(pro, index, vec, 0, 4 * sizeof(GLfloat),
|
||||
GL_TRUE);
|
||||
}
|
||||
|
||||
static GLvoid
|
||||
fetch_gen_attrib(struct gl2_program_intf **pro, GLuint index, GLuint i,
|
||||
struct vertex_buffer *vb)
|
||||
{
|
||||
const GLuint attr = _TNL_ATTRIB_GENERIC0 + index;
|
||||
const GLubyte *ptr = (const GLubyte *) (vb->AttribPtr[attr]->data);
|
||||
const GLuint stride = vb->AttribPtr[attr]->stride;
|
||||
const GLfloat *data = (const GLfloat *) (ptr + stride * i);
|
||||
|
||||
(**pro).WriteAttrib (pro, index, data);
|
||||
(**pro).WriteAttrib(pro, index, data);
|
||||
}
|
||||
|
||||
static GLvoid fetch_output_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
|
||||
arbvs_stage_data *store)
|
||||
static GLvoid
|
||||
fetch_output_float(struct gl2_program_intf **pro, GLuint index, GLuint attr,
|
||||
GLuint i, arbvs_stage_data * store)
|
||||
{
|
||||
(**pro).UpdateFixedAttrib (pro, index, &store->outputs[attr].data[i], 0, sizeof (GLfloat),
|
||||
GL_FALSE);
|
||||
(**pro).UpdateFixedAttrib(pro, index, &store->outputs[attr].data[i], 0,
|
||||
sizeof(GLfloat), GL_FALSE);
|
||||
}
|
||||
|
||||
static void fetch_output_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
|
||||
GLuint offset, arbvs_stage_data *store)
|
||||
static void
|
||||
fetch_output_vec4(struct gl2_program_intf **pro, GLuint index, GLuint attr,
|
||||
GLuint i, GLuint offset, arbvs_stage_data * store)
|
||||
{
|
||||
(**pro).UpdateFixedAttrib (pro, index, &store->outputs[attr].data[i], offset,
|
||||
4 * sizeof (GLfloat), GL_FALSE);
|
||||
(**pro).UpdateFixedAttrib(pro, index, &store->outputs[attr].data[i],
|
||||
offset, 4 * sizeof(GLfloat), GL_FALSE);
|
||||
}
|
||||
|
||||
static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
static GLboolean
|
||||
run_arb_vertex_shader(GLcontext * ctx, struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *vb = &tnl->vb;
|
||||
arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);
|
||||
struct gl2_program_intf **pro;
|
||||
GLsizei i, j;
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *vb = &tnl->vb;
|
||||
arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);
|
||||
struct gl2_program_intf **pro;
|
||||
GLsizei i, j;
|
||||
|
||||
if (!ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
#if 00
|
||||
if (!ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
#else
|
||||
return GL_TRUE;
|
||||
#endif
|
||||
|
||||
pro = ctx->ShaderObjects.CurrentProgram;
|
||||
(**pro).UpdateFixedUniforms (pro);
|
||||
pro = ctx->ShaderObjects.CurrentProgram;
|
||||
(**pro).UpdateFixedUniforms(pro);
|
||||
|
||||
for (i = 0; i < vb->Count; i++)
|
||||
{
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i, vb);
|
||||
fetch_input_vec3 (pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR, _TNL_ATTRIB_COLOR1, i, vb);
|
||||
fetch_input_float (pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0, _TNL_ATTRIB_TEX0, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1, _TNL_ATTRIB_TEX1, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD2, _TNL_ATTRIB_TEX2, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD3, _TNL_ATTRIB_TEX3, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD4, _TNL_ATTRIB_TEX4, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD5, _TNL_ATTRIB_TEX5, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD6, _TNL_ATTRIB_TEX6, i, vb);
|
||||
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD7, _TNL_ATTRIB_TEX7, i, vb);
|
||||
for (i = 0; i < vb->Count; i++) {
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i,
|
||||
vb);
|
||||
fetch_input_vec3(pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i,
|
||||
vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i,
|
||||
vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR,
|
||||
_TNL_ATTRIB_COLOR1, i, vb);
|
||||
fetch_input_float(pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i,
|
||||
vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0,
|
||||
_TNL_ATTRIB_TEX0, i, vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1,
|
||||
_TNL_ATTRIB_TEX1, i, vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD2,
|
||||
_TNL_ATTRIB_TEX2, i, vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD3,
|
||||
_TNL_ATTRIB_TEX3, i, vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD4,
|
||||
_TNL_ATTRIB_TEX4, i, vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD5,
|
||||
_TNL_ATTRIB_TEX5, i, vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD6,
|
||||
_TNL_ATTRIB_TEX6, i, vb);
|
||||
fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD7,
|
||||
_TNL_ATTRIB_TEX7, i, vb);
|
||||
for (j = 0; j < MAX_VERTEX_ATTRIBS; j++)
|
||||
fetch_gen_attrib (pro, j, i, vb);
|
||||
fetch_gen_attrib(pro, j, i, vb);
|
||||
|
||||
_slang_exec_vertex_shader (pro);
|
||||
_slang_exec_vertex_shader(pro);
|
||||
|
||||
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_POSITION, VERT_RESULT_HPOS, i, 0, store);
|
||||
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0, i, 0, store);
|
||||
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR, VERT_RESULT_COL1, i, 0, store);
|
||||
fetch_output_float (pro, SLANG_VERTEX_FIXED_FOGFRAGCOORD, VERT_RESULT_FOGC, i, store);
|
||||
for (j = 0; j < 8; j++)
|
||||
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_TEXCOORD, VERT_RESULT_TEX0 + j, i, j, store);
|
||||
fetch_output_float (pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ, i, store);
|
||||
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKCOLOR, VERT_RESULT_BFC0, i, 0, store);
|
||||
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR, VERT_RESULT_BFC1, i, 0, store);
|
||||
/* XXX: fetch output SLANG_VERTEX_FIXED_CLIPVERTEX */
|
||||
fetch_output_vec4(pro, SLANG_VERTEX_FIXED_POSITION, VERT_RESULT_HPOS, i,
|
||||
0, store);
|
||||
fetch_output_vec4(pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0,
|
||||
i, 0, store);
|
||||
fetch_output_vec4(pro, SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR,
|
||||
VERT_RESULT_COL1, i, 0, store);
|
||||
fetch_output_float(pro, SLANG_VERTEX_FIXED_FOGFRAGCOORD,
|
||||
VERT_RESULT_FOGC, i, store);
|
||||
for (j = 0; j < 8; j++)
|
||||
fetch_output_vec4(pro, SLANG_VERTEX_FIXED_TEXCOORD,
|
||||
VERT_RESULT_TEX0 + j, i, j, store);
|
||||
fetch_output_float(pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ,
|
||||
i, store);
|
||||
fetch_output_vec4(pro, SLANG_VERTEX_FIXED_BACKCOLOR, VERT_RESULT_BFC0,
|
||||
i, 0, store);
|
||||
fetch_output_vec4(pro, SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR,
|
||||
VERT_RESULT_BFC1, i, 0, store);
|
||||
/* XXX: fetch output SLANG_VERTEX_FIXED_CLIPVERTEX */
|
||||
|
||||
for (j = 0; j < MAX_VARYING_VECTORS; j++)
|
||||
{
|
||||
GLuint k;
|
||||
for (j = 0; j < MAX_VARYING_VECTORS; j++) {
|
||||
GLuint k;
|
||||
|
||||
for (k = 0; k < VARYINGS_PER_VECTOR; k++)
|
||||
{
|
||||
(**pro).UpdateVarying (pro, j * VARYINGS_PER_VECTOR + k,
|
||||
&store->varyings[j].data[i][k], GL_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (k = 0; k < VARYINGS_PER_VECTOR; k++) {
|
||||
(**pro).UpdateVarying(pro, j * VARYINGS_PER_VECTOR + k,
|
||||
&store->varyings[j].data[i][k], GL_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vb->ClipPtr = &store->outputs[VERT_RESULT_HPOS];
|
||||
vb->ClipPtr->count = vb->Count;
|
||||
vb->ClipPtr = &store->outputs[VERT_RESULT_HPOS];
|
||||
vb->ClipPtr->count = vb->Count;
|
||||
|
||||
vb->ColorPtr[0] = &store->outputs[VERT_RESULT_COL0];
|
||||
vb->AttribPtr[VERT_ATTRIB_COLOR0] = vb->ColorPtr[0];
|
||||
vb->ColorPtr[1] = &store->outputs[VERT_RESULT_BFC0];
|
||||
vb->ColorPtr[0] = &store->outputs[VERT_RESULT_COL0];
|
||||
vb->AttribPtr[VERT_ATTRIB_COLOR0] = vb->ColorPtr[0];
|
||||
vb->ColorPtr[1] = &store->outputs[VERT_RESULT_BFC0];
|
||||
|
||||
vb->SecondaryColorPtr[0] =
|
||||
vb->AttribPtr[VERT_ATTRIB_COLOR1] = &store->outputs[VERT_RESULT_COL1];
|
||||
vb->SecondaryColorPtr[0] =
|
||||
vb->AttribPtr[VERT_ATTRIB_COLOR1] = &store->outputs[VERT_RESULT_COL1];
|
||||
|
||||
vb->SecondaryColorPtr[1] = &store->outputs[VERT_RESULT_BFC1];
|
||||
vb->SecondaryColorPtr[1] = &store->outputs[VERT_RESULT_BFC1];
|
||||
|
||||
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
|
||||
vb->TexCoordPtr[i] =
|
||||
vb->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->outputs[VERT_RESULT_TEX0 + i];
|
||||
}
|
||||
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
|
||||
vb->TexCoordPtr[i] =
|
||||
vb->AttribPtr[VERT_ATTRIB_TEX0 + i] =
|
||||
&store->outputs[VERT_RESULT_TEX0 + i];
|
||||
}
|
||||
|
||||
vb->FogCoordPtr =
|
||||
vb->AttribPtr[VERT_ATTRIB_FOG] = &store->outputs[VERT_RESULT_FOGC];
|
||||
vb->FogCoordPtr =
|
||||
vb->AttribPtr[VERT_ATTRIB_FOG] = &store->outputs[VERT_RESULT_FOGC];
|
||||
|
||||
vb->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->outputs[VERT_RESULT_PSIZ];
|
||||
vb->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->outputs[VERT_RESULT_PSIZ];
|
||||
|
||||
for (i = 0; i < MAX_VARYING_VECTORS; i++) {
|
||||
vb->VaryingPtr[i] = &store->varyings[i];
|
||||
vb->AttribPtr[_TNL_ATTRIB_GENERIC0 + i] = vb->VaryingPtr[i];
|
||||
}
|
||||
for (i = 0; i < MAX_VARYING_VECTORS; i++) {
|
||||
vb->VaryingPtr[i] = &store->varyings[i];
|
||||
vb->AttribPtr[_TNL_ATTRIB_GENERIC0 + i] = vb->VaryingPtr[i];
|
||||
}
|
||||
|
||||
store->ormask = 0;
|
||||
store->andmask = CLIP_FRUSTUM_BITS;
|
||||
store->ormask = 0;
|
||||
store->andmask = CLIP_FRUSTUM_BITS;
|
||||
|
||||
if (tnl->NeedNdcCoords)
|
||||
{
|
||||
vb->NdcPtr = _mesa_clip_tab[vb->ClipPtr->size] (vb->ClipPtr, &store->ndc_coords,
|
||||
store->clipmask, &store->ormask, &store->andmask);
|
||||
}
|
||||
else
|
||||
{
|
||||
vb->NdcPtr = NULL;
|
||||
_mesa_clip_np_tab[vb->ClipPtr->size] (vb->ClipPtr, NULL, store->clipmask, &store->ormask,
|
||||
&store->andmask);
|
||||
}
|
||||
if (tnl->NeedNdcCoords) {
|
||||
vb->NdcPtr =
|
||||
_mesa_clip_tab[vb->ClipPtr->size] (vb->ClipPtr, &store->ndc_coords,
|
||||
store->clipmask, &store->ormask,
|
||||
&store->andmask);
|
||||
}
|
||||
else {
|
||||
vb->NdcPtr = NULL;
|
||||
_mesa_clip_np_tab[vb->ClipPtr->size] (vb->ClipPtr, NULL,
|
||||
store->clipmask, &store->ormask,
|
||||
&store->andmask);
|
||||
}
|
||||
|
||||
if (store->andmask)
|
||||
return GL_FALSE;
|
||||
if (store->andmask)
|
||||
return GL_FALSE;
|
||||
|
||||
vb->ClipAndMask = store->andmask;
|
||||
vb->ClipOrMask = store->ormask;
|
||||
vb->ClipMask = store->clipmask;
|
||||
vb->ClipAndMask = store->andmask;
|
||||
vb->ClipOrMask = store->ormask;
|
||||
vb->ClipMask = store->clipmask;
|
||||
|
||||
return GL_TRUE;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
const struct tnl_pipeline_stage _tnl_arb_vertex_shader_stage = {
|
||||
"ARB_vertex_shader",
|
||||
NULL,
|
||||
construct_arb_vertex_shader,
|
||||
destruct_arb_vertex_shader,
|
||||
validate_arb_vertex_shader,
|
||||
run_arb_vertex_shader
|
||||
"ARB_vertex_shader",
|
||||
NULL,
|
||||
construct_arb_vertex_shader,
|
||||
destruct_arb_vertex_shader,
|
||||
validate_arb_vertex_shader,
|
||||
run_arb_vertex_shader
|
||||
};
|
||||
|
||||
#endif /* FEATURE_ARB_vertex_shader */
|
||||
|
||||
|
@@ -57,10 +57,7 @@ static GLboolean run_cull_stage( GLcontext *ctx,
|
||||
GLuint count = VB->Count;
|
||||
GLuint i;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
|
||||
if (ctx->VertexProgram._Enabled ||
|
||||
if (ctx->VertexProgram._Current ||
|
||||
!ctx->Transform.CullVertexFlag)
|
||||
return GL_TRUE;
|
||||
|
||||
|
@@ -148,10 +148,7 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
struct fog_stage_data *store = FOG_STAGE_DATA(stage);
|
||||
GLvector4f *input;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
|
||||
if (!ctx->Fog.Enabled || ctx->VertexProgram._Enabled)
|
||||
if (!ctx->Fog.Enabled || ctx->VertexProgram._Current)
|
||||
return GL_TRUE;
|
||||
|
||||
|
||||
|
@@ -203,10 +203,7 @@ static GLboolean run_lighting( GLcontext *ctx,
|
||||
GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr;
|
||||
GLuint idx;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
|
||||
if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
|
||||
if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
|
||||
return GL_TRUE;
|
||||
|
||||
/* Make sure we can talk about position x,y and z:
|
||||
@@ -264,10 +261,7 @@ static void validate_lighting( GLcontext *ctx,
|
||||
{
|
||||
light_func *tab;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return;
|
||||
|
||||
if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
|
||||
if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
|
||||
return;
|
||||
|
||||
if (ctx->Visual.rgbMode) {
|
||||
|
@@ -95,12 +95,7 @@ validate_normal_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent) {
|
||||
store->NormalTransform = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx->VertexProgram._Enabled ||
|
||||
if (ctx->VertexProgram._Current ||
|
||||
(!ctx->Light.Enabled &&
|
||||
!(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS))) {
|
||||
store->NormalTransform = NULL;
|
||||
|
@@ -47,10 +47,7 @@ struct point_stage_data {
|
||||
static GLboolean
|
||||
run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
|
||||
if (ctx->Point._Attenuated && !ctx->VertexProgram._Enabled) {
|
||||
if (ctx->Point._Attenuated && !ctx->VertexProgram._Current) {
|
||||
struct point_stage_data *store = POINT_STAGE_DATA(stage);
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
const GLfloat (*eye)[4] = (const GLfloat (*)[4]) VB->EyePtr->data;
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "light.h"
|
||||
#include "macros.h"
|
||||
#include "imports.h"
|
||||
#include "program.h"
|
||||
#include "simple_list.h"
|
||||
#include "mtypes.h"
|
||||
#include "program_instruction.h"
|
||||
@@ -55,7 +56,7 @@
|
||||
*/
|
||||
struct vp_stage_data {
|
||||
/** The results of running the vertex program go into these arrays. */
|
||||
GLvector4f attribs[15];
|
||||
GLvector4f attribs[VERT_RESULT_MAX];
|
||||
|
||||
GLvector4f ndcCoords; /**< normalized device coords */
|
||||
GLubyte *clipmask; /**< clip flags */
|
||||
@@ -75,16 +76,14 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vp_stage_data *store = VP_STAGE_DATA(stage);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
struct gl_vertex_program *program = ctx->VertexProgram.Current;
|
||||
struct gl_vertex_program *program = ctx->VertexProgram._Current;
|
||||
struct vp_machine machine;
|
||||
GLuint i;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
if (!program || !program->IsNVProgram)
|
||||
return GL_TRUE;
|
||||
|
||||
if (!ctx->VertexProgram._Enabled ||
|
||||
!program->IsNVProgram)
|
||||
return GL_TRUE;
|
||||
_mesa_load_state_parameters(ctx, program->Base.Parameters);
|
||||
|
||||
/* load program parameter registers (they're read-only) */
|
||||
_mesa_init_vp_per_primitive_registers(ctx);
|
||||
@@ -140,9 +139,16 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
|
||||
|
||||
/* copy the output registers into the VB->attribs arrays */
|
||||
/* XXX (optimize) could use a conditional and smaller loop limit here */
|
||||
for (attr = 0; attr < 15; attr++) {
|
||||
for (attr = 0; attr < VERT_RESULT_MAX; attr++) {
|
||||
COPY_4V(store->attribs[attr].data[i], machine.Outputs[attr]);
|
||||
}
|
||||
#if 0
|
||||
printf("HPOS: %f %f %f %f\n",
|
||||
machine.Outputs[0][0],
|
||||
machine.Outputs[0][1],
|
||||
machine.Outputs[0][2],
|
||||
machine.Outputs[0][3]);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Setup the VB pointers so that the next pipeline stages get
|
||||
@@ -227,8 +233,7 @@ static GLboolean init_vp( GLcontext *ctx,
|
||||
return GL_FALSE;
|
||||
|
||||
/* Allocate arrays of vertex output values */
|
||||
/* XXX change '15' to a named constant */
|
||||
for (i = 0; i < 15; i++) {
|
||||
for (i = 0; i < VERT_RESULT_MAX; i++) {
|
||||
_mesa_vector4f_alloc( &store->attribs[i], 0, size, 32 );
|
||||
store->attribs[i].size = 4;
|
||||
}
|
||||
|
@@ -488,10 +488,7 @@ static GLboolean run_texgen_stage( GLcontext *ctx,
|
||||
struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
|
||||
GLuint i;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
|
||||
if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled)
|
||||
if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current)
|
||||
return GL_TRUE;
|
||||
|
||||
for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
|
||||
@@ -516,10 +513,7 @@ static void validate_texgen_stage( GLcontext *ctx,
|
||||
struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
|
||||
GLuint i;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return;
|
||||
|
||||
if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled)
|
||||
if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current)
|
||||
return;
|
||||
|
||||
for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
|
||||
|
@@ -61,10 +61,7 @@ static GLboolean run_texmat_stage( GLcontext *ctx,
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLuint i;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
|
||||
if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Enabled)
|
||||
if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Current)
|
||||
return GL_TRUE;
|
||||
|
||||
/* ENABLE_TEXMAT implies that the texture matrix is not the
|
||||
|
@@ -126,10 +126,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
|
||||
if (ctx->ShaderObjects._VertexShaderPresent)
|
||||
return GL_TRUE;
|
||||
|
||||
if (ctx->VertexProgram._Enabled)
|
||||
if (ctx->VertexProgram._Current)
|
||||
return GL_TRUE;
|
||||
|
||||
if (ctx->_NeedEyeCoords) {
|
||||
|
@@ -382,11 +382,14 @@ static struct ureg register_const4f( struct tnl_program *p,
|
||||
{
|
||||
GLfloat values[4];
|
||||
GLint idx;
|
||||
GLuint 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);
|
||||
}
|
||||
|
||||
@@ -1495,7 +1498,7 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
|
||||
GLuint hash;
|
||||
const struct gl_vertex_program *prev = ctx->VertexProgram._Current;
|
||||
|
||||
if (ctx->VertexProgram._Enabled == GL_FALSE) {
|
||||
if (!ctx->VertexProgram._Current) {
|
||||
/* Grab all the relevent state and put it in a single structure:
|
||||
*/
|
||||
key = make_state_key(ctx);
|
||||
@@ -1503,45 +1506,42 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
|
||||
|
||||
/* Look for an already-prepared program for this state:
|
||||
*/
|
||||
ctx->_TnlProgram = (struct gl_vertex_program *)
|
||||
ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *)
|
||||
search_cache( tnl->vp_cache, hash, key, sizeof(*key) );
|
||||
|
||||
/* OK, we'll have to build a new one:
|
||||
*/
|
||||
if (!ctx->_TnlProgram) {
|
||||
if (!ctx->VertexProgram._TnlProgram) {
|
||||
if (0)
|
||||
_mesa_printf("Build new TNL program\n");
|
||||
|
||||
ctx->_TnlProgram = (struct gl_vertex_program *)
|
||||
ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *)
|
||||
ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
|
||||
|
||||
create_new_program( key, ctx->_TnlProgram,
|
||||
create_new_program( key, ctx->VertexProgram._TnlProgram,
|
||||
ctx->Const.VertexProgram.MaxTemps );
|
||||
|
||||
if (ctx->Driver.ProgramStringNotify)
|
||||
ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
|
||||
&ctx->_TnlProgram->Base );
|
||||
&ctx->VertexProgram._TnlProgram->Base );
|
||||
|
||||
cache_item(tnl->vp_cache, hash, key, ctx->_TnlProgram );
|
||||
cache_item(tnl->vp_cache, hash, key, ctx->VertexProgram._TnlProgram );
|
||||
}
|
||||
else {
|
||||
FREE(key);
|
||||
if (0)
|
||||
_mesa_printf("Found existing TNL program for key %x\n", hash);
|
||||
}
|
||||
ctx->VertexProgram._Current = ctx->_TnlProgram;
|
||||
}
|
||||
else {
|
||||
ctx->VertexProgram._Current = ctx->VertexProgram.Current;
|
||||
ctx->VertexProgram._Current = ctx->VertexProgram._TnlProgram;
|
||||
}
|
||||
|
||||
/* Tell the driver about the change. Could define a new target for
|
||||
* this?
|
||||
*/
|
||||
if (ctx->VertexProgram._Current != prev &&
|
||||
ctx->Driver.BindProgram)
|
||||
if (ctx->VertexProgram._Current != prev && ctx->Driver.BindProgram) {
|
||||
ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
|
||||
(struct gl_program *) ctx->VertexProgram._Current);
|
||||
}
|
||||
}
|
||||
|
||||
void _tnl_ProgramCacheInit( GLcontext *ctx )
|
||||
|
@@ -123,8 +123,7 @@ void _tnl_update_eval( GLcontext *ctx )
|
||||
* We do this after the conventional attributes since the spec says that
|
||||
* these generic maps have higher priority.
|
||||
*/
|
||||
if (ctx->VertexProgram._Enabled &&
|
||||
ctx->VertexProgram._Current &&
|
||||
if (ctx->VertexProgram._Current &&
|
||||
ctx->VertexProgram._Current->IsNVProgram) {
|
||||
for (attr = 0; attr < 16; attr++) {
|
||||
if (ctx->Eval.Map1Attrib[attr])
|
||||
|
Reference in New Issue
Block a user