if (ctx->Extensions.ARB_vertex_program) {
save->VertexProgramEnabled = ctx->VertexProgram.Enabled;
- _mesa_reference_vertprog(ctx, &save->VertexProgram,
- ctx->VertexProgram.Current);
+ _mesa_reference_program(ctx, &save->VertexProgram,
+ ctx->VertexProgram.Current);
_mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE);
}
if (ctx->Extensions.ARB_vertex_program) {
_mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB,
save->VertexProgramEnabled);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
- save->VertexProgram);
- _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram.Current,
+ save->VertexProgram);
+ _mesa_reference_program(ctx, &save->VertexProgram, NULL);
}
if (ctx->Extensions.ARB_fragment_program) {
/** MESA_META_SHADER */
GLboolean VertexProgramEnabled;
- struct gl_vertex_program *VertexProgram;
+ struct gl_program *VertexProgram;
GLboolean FragmentProgramEnabled;
struct gl_fragment_program *FragmentProgram;
GLboolean ATIFragmentShaderEnabled;
{
switch (target) {
case GL_VERTEX_PROGRAM_ARB: {
- struct gl_vertex_program *prog = CALLOC_STRUCT(gl_vertex_program);
- return _mesa_init_gl_program(&prog->Base, target, id);
+ struct gl_program *prog = CALLOC_STRUCT(gl_program);
+ return _mesa_init_gl_program(prog, target, id);
}
case GL_FRAGMENT_PROGRAM_ARB:{
/** Subclass of Mesa vertex program */
struct brw_vertex_program {
- struct gl_vertex_program program;
+ struct gl_program program;
GLuint id;
};
/* Active vertex program:
*/
- const struct gl_vertex_program *vertex_program;
+ const struct gl_program *vertex_program;
const struct gl_program *geometry_program;
const struct gl_program *tess_ctrl_program;
const struct gl_program *tess_eval_program;
}
static inline struct brw_vertex_program *
-brw_vertex_program(struct gl_vertex_program *p)
+brw_vertex_program(struct gl_program *p)
{
return (struct brw_vertex_program *) p;
}
static inline const struct brw_vertex_program *
-brw_vertex_program_const(const struct gl_vertex_program *p)
+brw_vertex_program_const(const struct gl_program *p)
{
return (const struct brw_vertex_program *) p;
}
/* vertex shader constants */
if (brw->curbe.vs_size) {
- _mesa_load_state_parameters(ctx, brw->vertex_program->Base.Parameters);
+ _mesa_load_state_parameters(ctx, brw->vertex_program->Parameters);
GLuint offset = brw->curbe.vs_start * 16;
}
if (brw->gen < 8 && !brw->is_haswell) {
- uint64_t mask = ctx->VertexProgram._Current->Base.info.inputs_read;
+ uint64_t mask = ctx->VertexProgram._Current->info.inputs_read;
/* Prior to Haswell, the hardware can't natively support GL_FIXED or
* 2_10_10_10_REV vertex formats. Set appropriate workaround flags.
*/
brw->tcs.base.sampler_count = ctx->TessCtrlProgram._Current ?
util_last_bit(ctx->TessCtrlProgram._Current->SamplersUsed) : 0;
brw->vs.base.sampler_count =
- util_last_bit(ctx->VertexProgram._Current->Base.SamplersUsed);
+ util_last_bit(ctx->VertexProgram._Current->SamplersUsed);
intel_prepare_render(brw);
brw_predraw_set_aux_buffers(brw);
if (prog) {
prog->id = get_new_program_id(brw->screen);
- return _mesa_init_gl_program(&prog->program.Base, target, id);
+ return _mesa_init_gl_program(&prog->program, target, id);
}
else
return NULL;
GLenum target,
struct gl_program *prog)
{
+ assert(target == GL_VERTEX_PROGRAM_ARB || !prog->IsPositionInvariant);
+
struct brw_context *brw = brw_context(ctx);
const struct brw_compiler *compiler = brw->screen->compiler;
break;
}
case GL_VERTEX_PROGRAM_ARB: {
- struct gl_vertex_program *vprog = (struct gl_vertex_program *) prog;
- struct brw_vertex_program *newVP = brw_vertex_program(vprog);
+ struct brw_vertex_program *newVP = brw_vertex_program(prog);
const struct brw_vertex_program *curVP =
brw_vertex_program_const(brw->vertex_program);
mem_ctx = ralloc_context(NULL);
- brw_assign_common_binding_table_offsets(MESA_SHADER_VERTEX,
- devinfo,
- prog, &vp->program.Base,
- &prog_data.base.base, 0);
+ brw_assign_common_binding_table_offsets(MESA_SHADER_VERTEX, devinfo, prog,
+ &vp->program, &prog_data.base.base,
+ 0);
/* Allocate the references to the uniforms that will end up in the
* prog_data associated with the compiled program, and which will be freed
* by the state cache.
*/
- int param_count = vp->program.Base.nir->num_uniforms / 4;
+ int param_count = vp->program.nir->num_uniforms / 4;
if (vs)
prog_data.base.base.nr_image_params = vs->base.NumImages;
stage_prog_data->nr_params = param_count;
if (prog) {
- brw_nir_setup_glsl_uniforms(vp->program.Base.nir, prog, &vp->program.Base,
+ brw_nir_setup_glsl_uniforms(vp->program.nir, prog, &vp->program,
&prog_data.base.base,
compiler->scalar_stage[MESA_SHADER_VERTEX]);
} else {
- brw_nir_setup_arb_uniforms(vp->program.Base.nir, &vp->program.Base,
+ brw_nir_setup_arb_uniforms(vp->program.nir, &vp->program,
&prog_data.base.base);
}
uint64_t outputs_written =
- brw_vs_outputs_written(brw, key, vp->program.Base.info.outputs_written);
- prog_data.inputs_read = vp->program.Base.info.inputs_read;
+ brw_vs_outputs_written(brw, key, vp->program.info.outputs_written);
+ prog_data.inputs_read = vp->program.info.inputs_read;
if (key->copy_edgeflag) {
prog_data.inputs_read |= VERT_BIT_EDGEFLAG;
}
prog_data.base.cull_distance_mask =
- ((1 << vp->program.Base.CullDistanceArraySize) - 1) <<
- vp->program.Base.ClipDistanceArraySize;
+ ((1 << vp->program.CullDistanceArraySize) - 1) <<
+ vp->program.ClipDistanceArraySize;
brw_compute_vue_map(devinfo,
&prog_data.base.vue_map, outputs_written,
: false);
if (0) {
- _mesa_fprint_program_opt(stderr, &vp->program.Base, PROG_PRINT_DEBUG,
- true);
+ _mesa_fprint_program_opt(stderr, &vp->program, PROG_PRINT_DEBUG, true);
}
if (unlikely(brw->perf_debug)) {
}
if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
- brw_dump_ir("vertex", prog, vs ? &vs->base : NULL, &vp->program.Base);
+ brw_dump_ir("vertex", prog, vs ? &vs->base : NULL, &vp->program);
fprintf(stderr, "VS Output ");
brw_print_vue_map(stderr, &prog_data.base.vue_map);
int st_index = -1;
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
- st_index = brw_get_shader_time_index(brw, prog, &vp->program.Base, ST_VS);
+ st_index = brw_get_shader_time_index(brw, prog, &vp->program, ST_VS);
/* Emit GEN4 code.
*/
char *error_str;
- program = brw_compile_vs(compiler, brw, mem_ctx, key,
- &prog_data, vp->program.Base.nir,
+ program = brw_compile_vs(compiler, brw, mem_ctx, key, &prog_data,
+ vp->program.nir,
brw_select_clip_planes(&brw->ctx),
!_mesa_is_gles3(&brw->ctx),
st_index, &program_size, &error_str);
key->program_string_id = vp->id;
if (ctx->Transform.ClipPlanesEnabled != 0 &&
- (ctx->API == API_OPENGL_COMPAT ||
- ctx->API == API_OPENGLES) &&
- vp->program.Base.ClipDistanceArraySize == 0) {
+ (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) &&
+ vp->program.ClipDistanceArraySize == 0) {
key->nr_userclip_plane_consts =
_mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
}
struct brw_stage_prog_data *old_prog_data = brw->vs.base.prog_data;
bool success;
- struct gl_vertex_program *vp = (struct gl_vertex_program *) prog;
- struct brw_vertex_program *bvp = brw_vertex_program(vp);
+ struct brw_vertex_program *bvp = brw_vertex_program(prog);
memset(&key, 0, sizeof(key));
_mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_VERTEX);
/* _NEW_PROGRAM_CONSTANTS */
- brw_upload_pull_constants(brw, BRW_NEW_VS_CONSTBUF, &vp->program.Base,
+ brw_upload_pull_constants(brw, BRW_NEW_VS_CONSTBUF, &vp->program,
stage_state, prog_data);
}
const struct brw_stage_prog_data *prog_data = brw->vs.base.prog_data;
_mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_VERTEX);
- gen6_upload_push_constants(brw, &vp->program.Base, prog_data,
- stage_state, AUB_TRACE_VS_CONSTANTS);
+ gen6_upload_push_constants(brw, &vp->program, prog_data, stage_state,
+ AUB_TRACE_VS_CONSTANTS);
if (brw->gen >= 7) {
if (brw->gen == 7 && !brw->is_haswell && !brw->is_baytrail)
#include "main/mm.h"
struct r200_vertex_program {
- struct gl_vertex_program mesa_program; /* Must be first */
+ struct gl_program mesa_program; /* Must be first */
int translated;
/* need excess instr: 1 for late loop checking, 2 for
additional instr due to instr/attr, 3 for fog */
TCL_OR_VP_CHECK( tcl_or_vp_add2, GL_TRUE, 2 )
VP_CHECK( tcl_vp, GL_TRUE, 0 )
VP_CHECK( tcl_vp_add4, GL_TRUE, 4 )
-VP_CHECK( tcl_vp_size_add4, ctx->VertexProgram.Current->Base.NumNativeInstructions > 64, 4 )
-VP_CHECK( tcl_vpp_size_add4, ctx->VertexProgram.Current->Base.NumNativeParameters > 96, 4 )
+VP_CHECK( tcl_vp_size_add4, ctx->VertexProgram.Current->NumNativeInstructions > 64, 4 )
+VP_CHECK( tcl_vpp_size_add4, ctx->VertexProgram.Current->NumNativeParameters > 96, 4 )
#define OUT_VEC(hdr, data) do { \
drm_radeon_cmd_header_t h; \
We only need to change compsel. */
GLuint out_compsel = 0;
const GLbitfield64 vp_out =
- rmesa->curr_vp_hw->mesa_program.Base.OutputsWritten;
+ rmesa->curr_vp_hw->mesa_program.OutputsWritten;
vimap_rev = &rmesa->curr_vp_hw->inputmap_rev[0];
assert(vp_out & BITFIELD64_BIT(VARYING_SLOT_POS));
r200ContextPtr rmesa = R200_CONTEXT( ctx );
GLfloat *fcmd = (GLfloat *)&rmesa->hw.vpp[0].cmd[VPP_CMD_0 + 1];
int pi;
- struct gl_vertex_program *mesa_vp = &vp->mesa_program;
+ struct gl_program *mesa_vp = &vp->mesa_program;
struct gl_program_parameter_list *paramList;
drm_radeon_cmd_header_t tmp;
R200_STATECHANGE( rmesa, vpp[0] );
R200_STATECHANGE( rmesa, vpp[1] );
- assert(mesa_vp->Base.Parameters);
- _mesa_load_state_parameters(ctx, mesa_vp->Base.Parameters);
- paramList = mesa_vp->Base.Parameters;
+ assert(mesa_vp->Parameters);
+ _mesa_load_state_parameters(ctx, mesa_vp->Parameters);
+ paramList = mesa_vp->Parameters;
if(paramList->NumParameters > R200_VSF_MAX_PARAM){
fprintf(stderr, "%s:Params exhausted\n", __func__);
*/
static GLboolean r200_translate_vertex_program(struct gl_context *ctx, struct r200_vertex_program *vp)
{
- struct gl_vertex_program *mesa_vp = &vp->mesa_program;
+ struct gl_program *mesa_vp = &vp->mesa_program;
struct prog_instruction *vpi;
int i;
VERTEX_SHADER_INSTRUCTION *o_inst;
vp->translated = GL_TRUE;
vp->fogmode = ctx->Fog.Mode;
- if (mesa_vp->Base.NumInstructions == 0)
+ if (mesa_vp->NumInstructions == 0)
return GL_FALSE;
#if 0
- if ((mesa_vp->Base.InputsRead &
+ if ((mesa_vp->InputsRead &
~(VERT_BIT_POS | VERT_BIT_NORMAL | VERT_BIT_COLOR0 | VERT_BIT_COLOR1 |
VERT_BIT_FOG | VERT_BIT_TEX0 | VERT_BIT_TEX1 | VERT_BIT_TEX2 |
VERT_BIT_TEX3 | VERT_BIT_TEX4 | VERT_BIT_TEX5)) != 0) {
if (R200_DEBUG & RADEON_FALLBACKS) {
fprintf(stderr, "can't handle vert prog inputs 0x%x\n",
- mesa_vp->Base.InputsRead);
+ mesa_vp->InputsRead);
}
return GL_FALSE;
}
#endif
- if ((mesa_vp->Base.OutputsWritten &
+ if ((mesa_vp->OutputsWritten &
~((1 << VARYING_SLOT_POS) | (1 << VARYING_SLOT_COL0) | (1 << VARYING_SLOT_COL1) |
(1 << VARYING_SLOT_FOGC) | (1 << VARYING_SLOT_TEX0) | (1 << VARYING_SLOT_TEX1) |
(1 << VARYING_SLOT_TEX2) | (1 << VARYING_SLOT_TEX3) | (1 << VARYING_SLOT_TEX4) |
(1 << VARYING_SLOT_TEX5) | (1 << VARYING_SLOT_PSIZ))) != 0) {
if (R200_DEBUG & RADEON_FALLBACKS) {
fprintf(stderr, "can't handle vert prog outputs 0x%llx\n",
- (unsigned long long) mesa_vp->Base.OutputsWritten);
+ (unsigned long long) mesa_vp->OutputsWritten);
}
return GL_FALSE;
}
/* FIXME: is changing the prog safe to do here? */
if (mesa_vp->IsPositionInvariant &&
/* make sure we only do this once */
- !(mesa_vp->Base.OutputsWritten & (1 << VARYING_SLOT_POS))) {
+ !(mesa_vp->OutputsWritten & (1 << VARYING_SLOT_POS))) {
_mesa_insert_mvp_code(ctx, mesa_vp);
}
/* for fogc, can't change mesa_vp, as it would hose swtnl, and exp with
base e isn't directly available neither. */
- if ((mesa_vp->Base.OutputsWritten & (1 << VARYING_SLOT_FOGC)) && !vp->fogpidx) {
+ if ((mesa_vp->OutputsWritten & (1 << VARYING_SLOT_FOGC)) && !vp->fogpidx) {
struct gl_program_parameter_list *paramList;
gl_state_index tokens[STATE_LENGTH] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
- paramList = mesa_vp->Base.Parameters;
+ paramList = mesa_vp->Parameters;
vp->fogpidx = _mesa_add_state_reference(paramList, tokens);
}
vp->pos_end = 0;
- mesa_vp->Base.NumNativeInstructions = 0;
- if (mesa_vp->Base.Parameters)
- mesa_vp->Base.NumNativeParameters = mesa_vp->Base.Parameters->NumParameters;
+ mesa_vp->NumNativeInstructions = 0;
+ if (mesa_vp->Parameters)
+ mesa_vp->NumNativeParameters = mesa_vp->Parameters->NumParameters;
else
- mesa_vp->Base.NumNativeParameters = 0;
+ mesa_vp->NumNativeParameters = 0;
for(i = 0; i < VERT_ATTRIB_MAX; i++)
vp->inputs[i] = -1;
Haven't seen attr 14 used, maybe that's for the hw pointsize vec1 (which is
not possibe to use with vertex progs as it is lacking in vert prog specification) */
/* may look different when using idx buf / input_route instead of se_vtx_fmt? */
- if (mesa_vp->Base.InputsRead & VERT_BIT_POS) {
+ if (mesa_vp->InputsRead & VERT_BIT_POS) {
vp->inputs[VERT_ATTRIB_POS] = 0;
vp->inputmap_rev[0] = VERT_ATTRIB_POS;
free_inputs &= ~(1 << 0);
array_count++;
}
- if (mesa_vp->Base.InputsRead & VERT_BIT_WEIGHT) {
+ if (mesa_vp->InputsRead & VERT_BIT_WEIGHT) {
vp->inputs[VERT_ATTRIB_WEIGHT] = 12;
vp->inputmap_rev[1] = VERT_ATTRIB_WEIGHT;
array_count++;
}
- if (mesa_vp->Base.InputsRead & VERT_BIT_NORMAL) {
+ if (mesa_vp->InputsRead & VERT_BIT_NORMAL) {
vp->inputs[VERT_ATTRIB_NORMAL] = 1;
vp->inputmap_rev[2] = VERT_ATTRIB_NORMAL;
array_count++;
}
- if (mesa_vp->Base.InputsRead & VERT_BIT_COLOR0) {
+ if (mesa_vp->InputsRead & VERT_BIT_COLOR0) {
vp->inputs[VERT_ATTRIB_COLOR0] = 2;
vp->inputmap_rev[4] = VERT_ATTRIB_COLOR0;
free_inputs &= ~(1 << 2);
array_count++;
}
- if (mesa_vp->Base.InputsRead & VERT_BIT_COLOR1) {
+ if (mesa_vp->InputsRead & VERT_BIT_COLOR1) {
vp->inputs[VERT_ATTRIB_COLOR1] = 3;
vp->inputmap_rev[5] = VERT_ATTRIB_COLOR1;
free_inputs &= ~(1 << 3);
array_count++;
}
- if (mesa_vp->Base.InputsRead & VERT_BIT_FOG) {
+ if (mesa_vp->InputsRead & VERT_BIT_FOG) {
vp->inputs[VERT_ATTRIB_FOG] = 15; array_count++;
vp->inputmap_rev[3] = VERT_ATTRIB_FOG;
array_count++;
}
/* VERT_ATTRIB_TEX0-5 */
for (i = 0; i <= 5; i++) {
- if (mesa_vp->Base.InputsRead & VERT_BIT_TEX(i)) {
+ if (mesa_vp->InputsRead & VERT_BIT_TEX(i)) {
vp->inputs[VERT_ATTRIB_TEX(i)] = i + 6;
vp->inputmap_rev[8 + i] = VERT_ATTRIB_TEX(i);
free_inputs &= ~(1 << (i + 6));
}
/* using VERT_ATTRIB_TEX6/7 would be illegal */
for (; i < VERT_ATTRIB_TEX_MAX; i++) {
- if (mesa_vp->Base.InputsRead & VERT_BIT_TEX(i)) {
+ if (mesa_vp->InputsRead & VERT_BIT_TEX(i)) {
if (R200_DEBUG & RADEON_FALLBACKS) {
fprintf(stderr, "texture attribute %d in vert prog\n", i);
}
for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
int j;
/* completely ignore aliasing? */
- if (mesa_vp->Base.InputsRead & VERT_BIT_GENERIC(i)) {
+ if (mesa_vp->InputsRead & VERT_BIT_GENERIC(i)) {
array_count++;
if (array_count > 12) {
if (R200_DEBUG & RADEON_FALLBACKS) {
}
}
- if (!(mesa_vp->Base.OutputsWritten & (1 << VARYING_SLOT_POS))) {
+ if (!(mesa_vp->OutputsWritten & (1 << VARYING_SLOT_POS))) {
if (R200_DEBUG & RADEON_FALLBACKS) {
fprintf(stderr, "can't handle vert prog without position output\n");
}
}
o_inst = vp->instr;
- for (vpi = mesa_vp->Base.Instructions; vpi->Opcode != OPCODE_END; vpi++, o_inst++){
+ for (vpi = mesa_vp->Instructions; vpi->Opcode != OPCODE_END; vpi++, o_inst++){
operands = op_operands(vpi->Opcode);
are_srcs_scalar = operands & SCALAR_FLAG;
operands &= OP_MASK;
}
u_temp_used = (R200_VSF_MAX_TEMPS - 1) - u_temp_i;
- if (mesa_vp->Base.NumNativeTemporaries <
- (mesa_vp->Base.NumTemporaries + u_temp_used)) {
- mesa_vp->Base.NumNativeTemporaries =
- mesa_vp->Base.NumTemporaries + u_temp_used;
+ if (mesa_vp->NumNativeTemporaries <
+ (mesa_vp->NumTemporaries + u_temp_used)) {
+ mesa_vp->NumNativeTemporaries =
+ mesa_vp->NumTemporaries + u_temp_used;
}
- if ((mesa_vp->Base.NumTemporaries + u_temp_used) > R200_VSF_MAX_TEMPS) {
+ if ((mesa_vp->NumTemporaries + u_temp_used) > R200_VSF_MAX_TEMPS) {
if (R200_DEBUG & RADEON_FALLBACKS) {
- fprintf(stderr, "Ran out of temps, num temps %d, us %d\n", mesa_vp->Base.NumTemporaries, u_temp_used);
+ fprintf(stderr, "Ran out of temps, num temps %d, us %d\n", mesa_vp->NumTemporaries, u_temp_used);
}
return GL_FALSE;
}
u_temp_i = R200_VSF_MAX_TEMPS - 1;
if(o_inst - vp->instr >= R200_VSF_MAX_INST) {
- mesa_vp->Base.NumNativeInstructions = 129;
+ mesa_vp->NumNativeInstructions = 129;
if (R200_DEBUG & RADEON_FALLBACKS) {
fprintf(stderr, "more than 128 native instructions\n");
}
}
vp->native = GL_TRUE;
- mesa_vp->Base.NumNativeInstructions = (o_inst - vp->instr);
+ mesa_vp->NumNativeInstructions = (o_inst - vp->instr);
#if 0
fprintf(stderr, "hw program:\n");
for(i=0; i < vp->program.length; i++)
R200_STATECHANGE( rmesa, pvs );
rmesa->hw.pvs.cmd[PVS_CNTL_1] = (0 << R200_PVS_CNTL_1_PROGRAM_START_SHIFT) |
- ((vp->mesa_program.Base.NumNativeInstructions - 1) << R200_PVS_CNTL_1_PROGRAM_END_SHIFT) |
+ ((vp->mesa_program.NumNativeInstructions - 1) << R200_PVS_CNTL_1_PROGRAM_END_SHIFT) |
(vp->pos_end << R200_PVS_CNTL_1_POS_END_SHIFT);
rmesa->hw.pvs.cmd[PVS_CNTL_2] = (0 << R200_PVS_CNTL_2_PARAM_OFFSET_SHIFT) |
- (vp->mesa_program.Base.NumNativeParameters << R200_PVS_CNTL_2_PARAM_COUNT_SHIFT);
+ (vp->mesa_program.NumNativeParameters << R200_PVS_CNTL_2_PARAM_COUNT_SHIFT);
/* maybe user clip planes just work with vertex progs... untested */
if (ctx->Transform.ClipPlanesEnabled) {
}
if (vp != rmesa->curr_vp_hw) {
- GLuint count = vp->mesa_program.Base.NumNativeInstructions;
+ GLuint count = vp->mesa_program.NumNativeInstructions;
drm_radeon_cmd_header_t tmp;
R200_STATECHANGE( rmesa, vpi[0] );
switch(target){
case GL_VERTEX_PROGRAM_ARB: {
struct r200_vertex_program *vp = CALLOC_STRUCT(r200_vertex_program);
- return _mesa_init_gl_program(&vp->mesa_program.Base, target, id);
+ return _mesa_init_gl_program(&vp->mesa_program, target, id);
}
case GL_FRAGMENT_PROGRAM_ARB: {
struct gl_fragment_program *prog = CALLOC_STRUCT(gl_fragment_program);
case GL_VERTEX_PROGRAM_ARB:
vp->translated = GL_FALSE;
vp->fogpidx = 0;
-/* memset(&vp->translated, 0, sizeof(struct r200_vertex_program) - sizeof(struct gl_vertex_program));*/
+/* memset(&vp->translated, 0, sizeof(struct r200_vertex_program) - sizeof(struct gl_program));*/
r200_translate_vertex_program(ctx, vp);
rmesa->curr_vp_hw = NULL;
break;
/* Error-check target and get curProg */
if (target == GL_VERTEX_PROGRAM_ARB && ctx->Extensions.ARB_vertex_program) {
- curProg = &ctx->VertexProgram.Current->Base;
+ curProg = ctx->VertexProgram.Current;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
/* Bind a default program */
newProg = NULL;
if (target == GL_VERTEX_PROGRAM_ARB)
- newProg = &ctx->Shared->DefaultVertexProgram->Base;
+ newProg = ctx->Shared->DefaultVertexProgram;
else
newProg = &ctx->Shared->DefaultFragmentProgram->Base;
}
/* bind newProg */
if (target == GL_VERTEX_PROGRAM_ARB) {
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
- gl_vertex_program(newProg));
+ _mesa_reference_program(ctx, &ctx->VertexProgram.Current, newProg);
}
else if (target == GL_FRAGMENT_PROGRAM_ARB) {
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
switch (prog->Target) {
case GL_VERTEX_PROGRAM_ARB:
if (ctx->VertexProgram.Current &&
- ctx->VertexProgram.Current->Base.Id == ids[i]) {
+ ctx->VertexProgram.Current->Id == ids[i]) {
/* unbind this currently bound program */
_mesa_BindProgramARB(prog->Target, 0);
}
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
- prog = &(ctx->VertexProgram.Current->Base);
+ prog = ctx->VertexProgram.Current;
maxParams = ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
}
if (target == GL_VERTEX_PROGRAM_ARB && ctx->Extensions.ARB_vertex_program) {
- struct gl_vertex_program *prog = ctx->VertexProgram.Current;
+ struct gl_program *prog = ctx->VertexProgram.Current;
_mesa_parse_arb_vertex_program(ctx, target, string, len, prog);
- base = & prog->Base;
+ base = prog;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
- prog = &(ctx->VertexProgram.Current->Base);
+ prog = ctx->VertexProgram.Current;
limits = &ctx->Const.Program[MESA_SHADER_VERTEX];
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
GET_CURRENT_CONTEXT(ctx);
if (target == GL_VERTEX_PROGRAM_ARB) {
- prog = &(ctx->VertexProgram.Current->Base);
+ prog = ctx->VertexProgram.Current;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB) {
prog = &(ctx->FragmentProgram.Current->Base);
/* check that we don't exceed the size of various bitfields */
assert(VARYING_SLOT_MAX <=
- (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten)));
+ (8 * sizeof(ctx->VertexProgram._Current->OutputsWritten)));
assert(VARYING_SLOT_MAX <=
(8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead)));
_mesa_reference_framebuffer(&ctx->DrawBuffer, NULL);
_mesa_reference_framebuffer(&ctx->ReadBuffer, NULL);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram.Current, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._TnlProgram, NULL);
_mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, NULL);
_mesa_reference_program(ctx, &ctx->TessEvalProgram._Current, NULL);
if (vertexShader)
vprog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
else
- vprog = &ctx->VertexProgram.Current->Base;
+ vprog = ctx->VertexProgram.Current;
vp_outputs = vprog->OutputsWritten;
struct tnl_program {
const struct state_key *state;
- struct gl_vertex_program *program;
+ struct gl_program *program;
GLuint max_inst; /** number of instructions allocated for program */
GLboolean mvp_with_dp4;
exit(1);
}
- if ((GLuint) bit > p->program->Base.NumTemporaries)
- p->program->Base.NumTemporaries = bit;
+ if ((GLuint) bit > p->program->NumTemporaries)
+ p->program->NumTemporaries = bit;
p->temp_in_use |= 1<<(bit-1);
return make_ureg(PROGRAM_TEMPORARY, bit-1);
tokens[2] = s2;
tokens[3] = s3;
tokens[4] = s4;
- idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens );
+ idx = _mesa_add_state_reference(p->program->Parameters, tokens );
return make_ureg(PROGRAM_STATE_VAR, idx);
}
assert(input < VERT_ATTRIB_MAX);
if (p->state->varying_vp_inputs & VERT_BIT(input)) {
- p->program->Base.InputsRead |= VERT_BIT(input);
+ p->program->InputsRead |= VERT_BIT(input);
return make_ureg(PROGRAM_INPUT, input);
}
else {
*/
static struct ureg register_output( struct tnl_program *p, GLuint output )
{
- p->program->Base.OutputsWritten |= BITFIELD64_BIT(output);
+ p->program->OutputsWritten |= BITFIELD64_BIT(output);
return make_ureg(PROGRAM_OUTPUT, output);
}
values[1].f = s1;
values[2].f = s2;
values[3].f = s3;
- idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
- &swizzle );
+ idx = _mesa_add_unnamed_constant(p->program->Parameters, values, 4,
+ &swizzle );
assert(swizzle == SWIZZLE_NOOP);
return make_ureg(PROGRAM_CONSTANT, idx);
}
GLuint nr;
struct prog_instruction *inst;
- assert(p->program->Base.NumInstructions <= p->max_inst);
+ assert(p->program->NumInstructions <= p->max_inst);
- if (p->program->Base.NumInstructions == p->max_inst) {
+ if (p->program->NumInstructions == p->max_inst) {
/* need to extend the program's instruction array */
struct prog_instruction *newInst;
return;
}
- _mesa_copy_instructions(newInst,
- p->program->Base.Instructions,
- p->program->Base.NumInstructions);
+ _mesa_copy_instructions(newInst, p->program->Instructions,
+ p->program->NumInstructions);
- _mesa_free_instructions(p->program->Base.Instructions,
- p->program->Base.NumInstructions);
+ _mesa_free_instructions(p->program->Instructions,
+ p->program->NumInstructions);
- p->program->Base.Instructions = newInst;
+ p->program->Instructions = newInst;
}
- nr = p->program->Base.NumInstructions++;
+ nr = p->program->NumInstructions++;
- inst = &p->program->Base.Instructions[nr];
+ inst = &p->program->Instructions[nr];
inst->Opcode = (enum prog_opcode) op;
emit_arg( &inst->SrcReg[0], src0 );
static void
create_new_program( const struct state_key *key,
- struct gl_vertex_program *program,
+ struct gl_program *program,
GLboolean mvp_with_dp4,
GLuint max_temps)
{
* If we need more, we'll grow the instruction array as needed.
*/
p.max_inst = 32;
- p.program->Base.Instructions = _mesa_alloc_instructions(p.max_inst);
- p.program->Base.String = NULL;
- p.program->Base.NumInstructions =
- p.program->Base.NumTemporaries =
- p.program->Base.NumParameters =
- p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0;
- p.program->Base.Parameters = _mesa_new_parameter_list();
- p.program->Base.InputsRead = 0;
- p.program->Base.OutputsWritten = 0;
+ p.program->Instructions = _mesa_alloc_instructions(p.max_inst);
+ p.program->String = NULL;
+ p.program->NumInstructions =
+ p.program->NumTemporaries =
+ p.program->NumParameters =
+ p.program->NumAttributes = p.program->NumAddressRegs = 0;
+ p.program->Parameters = _mesa_new_parameter_list();
+ p.program->InputsRead = 0;
+ p.program->OutputsWritten = 0;
build_tnl_program( &p );
}
* Return a vertex program which implements the current fixed-function
* transform/lighting/texgen operations.
*/
-struct gl_vertex_program *
+struct gl_program *
_mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
{
- struct gl_vertex_program *prog;
+ struct gl_program *prog;
struct state_key key;
/* Grab all the relevant state and put it in a single structure:
/* Look for an already-prepared program for this state:
*/
- prog = gl_vertex_program(
- _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key)));
+ prog = _mesa_search_program_cache(ctx->VertexProgram.Cache, &key,
+ sizeof(key));
if (!prog) {
/* OK, we'll have to build a new one */
if (0)
printf("Build new TNL program\n");
- prog = gl_vertex_program(ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0));
+ prog = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
if (!prog)
return NULL;
ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps );
if (ctx->Driver.ProgramStringNotify)
- ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
- &prog->Base );
+ ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, prog);
- _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache,
- &key, sizeof(key), &prog->Base);
+ _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache, &key,
+ sizeof(key), prog);
}
return prog;
struct gl_context;
-struct gl_vertex_program *
+struct gl_program *
_mesa_get_fixed_func_vertex_program(struct gl_context *ctx);
GLuint NumNativeTexInstructions;
GLuint NumNativeTexIndirections;
/*@}*/
-};
-
-/** Vertex program object */
-struct gl_vertex_program
-{
- struct gl_program Base; /**< base class */
+ /** Used by ARB assembly-style programs. Can only be true for vertex
+ * programs.
+ */
GLboolean IsPositionInvariant;
};
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
/** Computed two sided lighting for fixed function/programs. */
GLboolean _TwoSideEnabled;
- struct gl_vertex_program *Current; /**< User-bound vertex program */
+ struct gl_program *Current; /**< User-bound vertex program */
/** Currently enabled and valid vertex program (including internal
* programs, user-defined vertex programs and GLSL vertex shaders).
* This is the program we must use when rendering.
*/
- struct gl_vertex_program *_Current;
+ struct gl_program *_Current;
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
GLboolean _MaintainTnlProgram;
/** Program to emulate fixed-function T&L (see above) */
- struct gl_vertex_program *_TnlProgram;
+ struct gl_program *_TnlProgram;
/** Cache of fixed-function programs */
struct gl_program_cache *Cache;
/** Vertex shader state */
struct {
/**
- * True if gl_ClipDistance is written to. Copied into gl_vertex_program
+ * True if gl_ClipDistance is written to. Copied into gl_program
* by _mesa_copy_linked_program_data().
*/
GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
*/
/*@{*/
struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
- struct gl_vertex_program *DefaultVertexProgram;
+ struct gl_program *DefaultVertexProgram;
struct gl_fragment_program *DefaultFragmentProgram;
/*@}*/
shared->Programs = _mesa_NewHashTable();
shared->DefaultVertexProgram =
- gl_vertex_program(ctx->Driver.NewProgram(ctx,
- GL_VERTEX_PROGRAM_ARB, 0));
+ ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
shared->DefaultFragmentProgram =
gl_fragment_program(ctx->Driver.NewProgram(ctx,
GL_FRAGMENT_PROGRAM_ARB, 0));
_mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx);
_mesa_DeleteHashTable(shared->Programs);
- _mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL);
+ _mesa_reference_program(ctx, &shared->DefaultVertexProgram, NULL);
_mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL);
_mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx);
* GLSL shaders not relevant here.
*/
ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
- && ctx->VertexProgram.Current->Base.Instructions;
+ && ctx->VertexProgram.Current->Instructions;
ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
&& ctx->FragmentProgram.Current->Base.Instructions;
ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
const struct gl_shader_program *csProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
+ const struct gl_program *prevVP = ctx->VertexProgram._Current;
const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
const struct gl_program *prevGP = ctx->GeometryProgram._Current;
const struct gl_program *prevTCP = ctx->TessCtrlProgram._Current;
if (vsProg && vsProg->LinkStatus
&& vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
/* Use GLSL vertex shader */
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
- gl_vertex_program(vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program));
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current,
+ vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
}
else if (ctx->VertexProgram._Enabled) {
/* Use user-defined vertex program */
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
- ctx->VertexProgram.Current);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current,
+ ctx->VertexProgram.Current);
}
else if (ctx->VertexProgram._MaintainTnlProgram) {
/* Use vertex program generated from fixed-function state */
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
- _mesa_get_fixed_func_vertex_program(ctx));
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram,
- ctx->VertexProgram._Current);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current,
+ _mesa_get_fixed_func_vertex_program(ctx));
+ _mesa_reference_program(ctx, &ctx->VertexProgram._TnlProgram,
+ ctx->VertexProgram._Current);
}
else {
/* no vertex program */
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current, NULL);
}
if (csProg && csProg->LinkStatus
new_state |= _NEW_PROGRAM;
if (ctx->Driver.BindProgram) {
ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
- (struct gl_program *) ctx->VertexProgram._Current);
+ ctx->VertexProgram._Current);
}
}
if (ctx->VertexProgram._Current) {
const struct gl_program_parameter_list *params =
- ctx->VertexProgram._Current->Base.Parameters;
+ ctx->VertexProgram._Current->Parameters;
if (params && params->StateFlags & ctx->NewState) {
new_state |= _NEW_PROGRAM_CONSTANTS;
}
if (ctx->VertexProgram._Current &&
(ctx->VertexProgram._Current != ctx->VertexProgram._TnlProgram) &&
- (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1))
+ (ctx->VertexProgram._Current->InputsRead & VERT_BIT_COLOR1))
return GL_TRUE;
if (ctx->FragmentProgram._Current &&
void
_mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
const GLvoid *str, GLsizei len,
- struct gl_vertex_program *program)
+ struct gl_program *program)
{
struct gl_program prog;
struct asm_parser_state state;
if ((ctx->_Shader->Flags & GLSL_NO_OPT) == 0)
_mesa_optimize_program(ctx, &prog);
- free(program->Base.String);
+ free(program->String);
/* Copy the relevant contents of the arb_program struct into the
* vertex_program struct.
*/
- program->Base.String = prog.String;
- program->Base.NumInstructions = prog.NumInstructions;
- program->Base.NumTemporaries = prog.NumTemporaries;
- program->Base.NumParameters = prog.NumParameters;
- program->Base.NumAttributes = prog.NumAttributes;
- program->Base.NumAddressRegs = prog.NumAddressRegs;
- program->Base.NumNativeInstructions = prog.NumNativeInstructions;
- program->Base.NumNativeTemporaries = prog.NumNativeTemporaries;
- program->Base.NumNativeParameters = prog.NumNativeParameters;
- program->Base.NumNativeAttributes = prog.NumNativeAttributes;
- program->Base.NumNativeAddressRegs = prog.NumNativeAddressRegs;
- program->Base.InputsRead = prog.InputsRead;
- program->Base.OutputsWritten = prog.OutputsWritten;
- program->Base.IndirectRegisterFiles = prog.IndirectRegisterFiles;
+ program->String = prog.String;
+ program->NumInstructions = prog.NumInstructions;
+ program->NumTemporaries = prog.NumTemporaries;
+ program->NumParameters = prog.NumParameters;
+ program->NumAttributes = prog.NumAttributes;
+ program->NumAddressRegs = prog.NumAddressRegs;
+ program->NumNativeInstructions = prog.NumNativeInstructions;
+ program->NumNativeTemporaries = prog.NumNativeTemporaries;
+ program->NumNativeParameters = prog.NumNativeParameters;
+ program->NumNativeAttributes = prog.NumNativeAttributes;
+ program->NumNativeAddressRegs = prog.NumNativeAddressRegs;
+ program->InputsRead = prog.InputsRead;
+ program->OutputsWritten = prog.OutputsWritten;
+ program->IndirectRegisterFiles = prog.IndirectRegisterFiles;
program->IsPositionInvariant = (state.option.PositionInvariant)
? GL_TRUE : GL_FALSE;
- free(program->Base.Instructions);
- program->Base.Instructions = prog.Instructions;
+ free(program->Instructions);
+ program->Instructions = prog.Instructions;
- if (program->Base.Parameters)
- _mesa_free_parameter_list(program->Base.Parameters);
- program->Base.Parameters = prog.Parameters;
+ if (program->Parameters)
+ _mesa_free_parameter_list(program->Parameters);
+ program->Parameters = prog.Parameters;
#if DEBUG_VP
- printf("____________Vertex program %u __________\n", program->Base.Id);
- _mesa_print_program(&program->Base);
+ printf("____________Vertex program %u __________\n", program->Id);
+ _mesa_print_program(program);
#endif
}
extern void
_mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
const GLvoid *str, GLsizei len,
- struct gl_vertex_program *program);
+ struct gl_program *program);
extern void
_mesa_parse_arb_fragment_program(struct gl_context *ctx, GLenum target,
COPY_4V(value, ctx->VertexProgram.Parameters[idx]);
return;
case STATE_LOCAL:
- if (!ctx->VertexProgram.Current->Base.LocalParams) {
- ctx->VertexProgram.Current->Base.LocalParams =
+ if (!ctx->VertexProgram.Current->LocalParams) {
+ ctx->VertexProgram.Current->LocalParams =
calloc(MAX_PROGRAM_LOCAL_PARAMS, sizeof(float[4]));
- if (!ctx->VertexProgram.Current->Base.LocalParams)
+ if (!ctx->VertexProgram.Current->LocalParams)
return;
}
- COPY_4V(value, ctx->VertexProgram.Current->Base.LocalParams[idx]);
+ COPY_4V(value, ctx->VertexProgram.Current->LocalParams[idx]);
return;
default:
_mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
ctx->VertexProgram.PointSizeEnabled =
(ctx->API == API_OPENGLES2) ? GL_TRUE : GL_FALSE;
ctx->VertexProgram.TwoSideEnabled = GL_FALSE;
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
- ctx->Shared->DefaultVertexProgram);
+ _mesa_reference_program(ctx, &ctx->VertexProgram.Current,
+ ctx->Shared->DefaultVertexProgram);
assert(ctx->VertexProgram.Current);
ctx->VertexProgram.Cache = _mesa_new_program_cache();
void
_mesa_free_program_data(struct gl_context *ctx)
{
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram.Current, NULL);
_mesa_delete_program_cache(ctx, ctx->VertexProgram.Cache);
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL);
_mesa_delete_shader_cache(ctx, ctx->FragmentProgram.Cache);
void
_mesa_update_default_objects_program(struct gl_context *ctx)
{
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
- ctx->Shared->DefaultVertexProgram);
+ _mesa_reference_program(ctx, &ctx->VertexProgram.Current,
+ ctx->Shared->DefaultVertexProgram);
assert(ctx->VertexProgram.Current);
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id)
{
switch (target) {
- case GL_VERTEX_PROGRAM_ARB: { /* == GL_VERTEX_PROGRAM_NV */
- struct gl_vertex_program *prog = CALLOC_STRUCT(gl_vertex_program);
- return _mesa_init_gl_program(&prog->Base, target, id);
- }
case GL_FRAGMENT_PROGRAM_ARB: {
struct gl_fragment_program *prog = CALLOC_STRUCT(gl_fragment_program);
return _mesa_init_gl_program(&prog->Base, target, id);
}
+ case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
case GL_GEOMETRY_PROGRAM_NV:
case GL_TESS_CONTROL_PROGRAM_NV:
case GL_TESS_EVALUATION_PROGRAM_NV: {
_mesa_reference_program_(ctx, ptr, prog);
}
-static inline void
-_mesa_reference_vertprog(struct gl_context *ctx,
- struct gl_vertex_program **ptr,
- struct gl_vertex_program *prog)
-{
- _mesa_reference_program(ctx, (struct gl_program **) ptr,
- (struct gl_program *) prog);
-}
-
static inline void
_mesa_reference_fragprog(struct gl_context *ctx,
struct gl_fragment_program **ptr,
}
-/* Cast wrappers from gl_program to derived program types.
- * (e.g. gl_vertex_program)
- */
-
static inline struct gl_fragment_program *
gl_fragment_program(struct gl_program *prog)
{
return (const struct gl_fragment_program *) prog;
}
-
-static inline struct gl_vertex_program *
-gl_vertex_program(struct gl_program *prog)
-{
- return (struct gl_vertex_program *) prog;
-}
-
-static inline const struct gl_vertex_program *
-gl_vertex_program_const(const struct gl_program *prog)
-{
- return (const struct gl_vertex_program *) prog;
-}
-
static inline struct gl_compute_program *
gl_compute_program(struct gl_program *prog)
{
* May be used to implement the position_invariant option.
*/
static void
-_mesa_insert_mvp_dp4_code(struct gl_context *ctx, struct gl_vertex_program *vprog)
+_mesa_insert_mvp_dp4_code(struct gl_context *ctx, struct gl_program *vprog)
{
struct prog_instruction *newInst;
- const GLuint origLen = vprog->Base.NumInstructions;
+ const GLuint origLen = vprog->NumInstructions;
const GLuint newLen = origLen + 4;
GLuint i;
GLint mvpRef[4];
for (i = 0; i < 4; i++) {
- mvpRef[i] = _mesa_add_state_reference(vprog->Base.Parameters,
- mvpState[i]);
+ mvpRef[i] = _mesa_add_state_reference(vprog->Parameters, mvpState[i]);
}
/* Alloc storage for new instructions */
}
/* Append original instructions after new instructions */
- _mesa_copy_instructions (newInst + 4, vprog->Base.Instructions, origLen);
+ _mesa_copy_instructions (newInst + 4, vprog->Instructions, origLen);
/* free old instructions */
- _mesa_free_instructions(vprog->Base.Instructions, origLen);
+ _mesa_free_instructions(vprog->Instructions, origLen);
/* install new instructions */
- vprog->Base.Instructions = newInst;
- vprog->Base.NumInstructions = newLen;
- vprog->Base.InputsRead |= VERT_BIT_POS;
- vprog->Base.OutputsWritten |= BITFIELD64_BIT(VARYING_SLOT_POS);
+ vprog->Instructions = newInst;
+ vprog->NumInstructions = newLen;
+ vprog->InputsRead |= VERT_BIT_POS;
+ vprog->OutputsWritten |= BITFIELD64_BIT(VARYING_SLOT_POS);
}
static void
-_mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_vertex_program *vprog)
+_mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_program *vprog)
{
struct prog_instruction *newInst;
- const GLuint origLen = vprog->Base.NumInstructions;
+ const GLuint origLen = vprog->NumInstructions;
const GLuint newLen = origLen + 4;
GLuint hposTemp;
GLuint i;
GLint mvpRef[4];
for (i = 0; i < 4; i++) {
- mvpRef[i] = _mesa_add_state_reference(vprog->Base.Parameters,
- mvpState[i]);
+ mvpRef[i] = _mesa_add_state_reference(vprog->Parameters, mvpState[i]);
}
/* Alloc storage for new instructions */
}
/* TEMP hposTemp; */
- hposTemp = vprog->Base.NumTemporaries++;
+ hposTemp = vprog->NumTemporaries++;
/*
* Generated instructions:
/* Append original instructions after new instructions */
- _mesa_copy_instructions (newInst + 4, vprog->Base.Instructions, origLen);
+ _mesa_copy_instructions (newInst + 4, vprog->Instructions, origLen);
/* free old instructions */
- _mesa_free_instructions(vprog->Base.Instructions, origLen);
+ _mesa_free_instructions(vprog->Instructions, origLen);
/* install new instructions */
- vprog->Base.Instructions = newInst;
- vprog->Base.NumInstructions = newLen;
- vprog->Base.InputsRead |= VERT_BIT_POS;
- vprog->Base.OutputsWritten |= BITFIELD64_BIT(VARYING_SLOT_POS);
+ vprog->Instructions = newInst;
+ vprog->NumInstructions = newLen;
+ vprog->InputsRead |= VERT_BIT_POS;
+ vprog->OutputsWritten |= BITFIELD64_BIT(VARYING_SLOT_POS);
}
void
-_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog)
+_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_program *vprog)
{
if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS)
_mesa_insert_mvp_dp4_code( ctx, vprog );
extern void
-_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog);
+_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_program *vprog);
extern void
_mesa_append_fog_code(struct gl_context *ctx,
struct st_geometry_program *old_gp = st->gp;
struct st_fragment_program *old_fp = st->fp;
- struct gl_vertex_program *new_vp = ctx->VertexProgram._Current;
+ struct gl_program *new_vp = ctx->VertexProgram._Current;
struct gl_program *new_tcp = ctx->TessCtrlProgram._Current;
struct gl_program *new_tep = ctx->TessEvalProgram._Current;
struct gl_program *new_gp = ctx->GeometryProgram._Current;
{
const struct gl_client_array **arrays = st->ctx->Array._DrawArrays;
GLboolean vertdata_edgeflags, edgeflag_culls_prims, edgeflags_enabled;
- struct gl_vertex_program *vp = st->ctx->VertexProgram._Current;
+ struct gl_program *vp = st->ctx->VertexProgram._Current;
if (!arrays)
return;
static void update_vs_constants(struct st_context *st )
{
struct st_vertex_program *vp = st->vp;
- struct gl_program_parameter_list *params = vp->Base.Base.Parameters;
+ struct gl_program_parameter_list *params = vp->Base.Parameters;
st_upload_constants( st, params, MESA_SHADER_VERTEX );
}
{
struct gl_context *ctx = st->ctx;
struct pipe_rasterizer_state *raster = &st->state.rasterizer;
- const struct gl_vertex_program *vertProg = ctx->VertexProgram._Current;
+ const struct gl_program *vertProg = ctx->VertexProgram._Current;
const struct gl_fragment_program *fragProg = ctx->FragmentProgram._Current;
memset(raster, 0, sizeof(*raster));
/* ST_NEW_VERTEX_PROGRAM
*/
if (vertProg) {
- if (vertProg->Base.Id == 0) {
- if (vertProg->Base.OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_PSIZ)) {
+ if (vertProg->Id == 0) {
+ if (vertProg->OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_PSIZ)) {
/* generated program which emits point size */
raster->point_size_per_vertex = TRUE;
}
else if (ctx->TessEvalProgram._Current)
last = ctx->TessEvalProgram._Current;
else if (ctx->VertexProgram._Current)
- last = &ctx->VertexProgram._Current->Base;
+ last = ctx->VertexProgram._Current;
if (last)
raster->point_size_per_vertex =
!!(last->OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_PSIZ));
update_shader_samplers(st,
PIPE_SHADER_VERTEX,
- &ctx->VertexProgram._Current->Base,
+ ctx->VertexProgram._Current,
ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_VERTEX],
&st->state.num_samplers[PIPE_SHADER_VERTEX]);
*/
assert(st->ctx->VertexProgram._Current);
stvp = st_vertex_program(st->ctx->VertexProgram._Current);
- assert(stvp->Base.Base.Target == GL_VERTEX_PROGRAM_ARB);
+ assert(stvp->Base.Target == GL_VERTEX_PROGRAM_ARB);
memset(&key, 0, sizeof key);
key.st = st->has_shareable_shaders ? NULL : st;
key.clamp_color = st->clamp_vert_color_in_shader &&
st->ctx->Light._ClampVertexColor &&
- (stvp->Base.Base.OutputsWritten &
+ (stvp->Base.OutputsWritten &
(VARYING_SLOT_COL0 |
VARYING_SLOT_COL1 |
VARYING_SLOT_BFC0 |
if (ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits > 0) {
update_textures(st,
MESA_SHADER_VERTEX,
- &ctx->VertexProgram._Current->Base,
+ ctx->VertexProgram._Current,
ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_VERTEX],
&st->state.num_sampler_views[PIPE_SHADER_VERTEX]);
vbo_set_draw_func(ctx, st_feedback_draw_vbo);
}
else {
- struct gl_vertex_program *vp = st->ctx->VertexProgram._Current;
+ struct gl_program *vp = st->ctx->VertexProgram._Current;
if (!st->feedback_stage)
st->feedback_stage = draw_glfeedback_stage(ctx, draw);
switch (target) {
case GL_VERTEX_PROGRAM_ARB: {
struct st_vertex_program *prog = ST_CALLOC_STRUCT(st_vertex_program);
- return _mesa_init_gl_program(&prog->Base.Base, target, id);
+ return _mesa_init_gl_program(&prog->Base, target, id);
}
case GL_FRAGMENT_PROGRAM_ARB: {
struct st_fragment_program *prog = ST_CALLOC_STRUCT(st_fragment_program);
if (st->vp->variants)
tgsi_dump( st->vp->variants[0].tgsi.tokens, 0 );
- if (st->vp->Base.Base.Parameters)
- _mesa_print_parameter_list(st->vp->Base.Base.Parameters);
+ if (st->vp->Base.Parameters)
+ _mesa_print_parameter_list(st->vp->Base.Parameters);
tgsi_dump(st->fp->tgsi.tokens, 0);
if (st->fp->Base.Base.Parameters)
* and TGSI generic input indexes, plus input attrib semantic info.
*/
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if ((stvp->Base.Base.InputsRead & BITFIELD64_BIT(attr)) != 0) {
+ if ((stvp->Base.InputsRead & BITFIELD64_BIT(attr)) != 0) {
input_to_index[attr] = stvp->num_inputs;
stvp->index_to_input[stvp->num_inputs] = attr;
stvp->num_inputs++;
- if ((stvp->Base.Base.DoubleInputsRead & BITFIELD64_BIT(attr)) != 0) {
+ if ((stvp->Base.DoubleInputsRead & BITFIELD64_BIT(attr)) != 0) {
/* add placeholder for second part of a double attribute */
stvp->index_to_input[stvp->num_inputs] = ST_DOUBLE_ATTRIB_PLACEHOLDER;
stvp->num_inputs++;
/* Compute mapping of vertex program outputs to slots.
*/
for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
- if ((stvp->Base.Base.OutputsWritten & BITFIELD64_BIT(attr)) == 0) {
+ if ((stvp->Base.OutputsWritten & BITFIELD64_BIT(attr)) == 0) {
stvp->result_to_output[attr] = ~0;
}
else {
/* ARB_vp: */
if (!stvp->glsl_to_tgsi && !stvp->shader_program) {
- _mesa_remove_output_reads(&stvp->Base.Base, PROGRAM_OUTPUT);
+ _mesa_remove_output_reads(&stvp->Base, PROGRAM_OUTPUT);
/* This determines which states will be updated when the assembly
* shader is bound.
ST_NEW_RASTERIZER |
ST_NEW_VERTEX_ARRAYS;
- if (stvp->Base.Base.Parameters->NumParameters)
+ if (stvp->Base.Parameters->NumParameters)
stvp->affected_states |= ST_NEW_VS_CONSTANTS;
/* No samplers are allowed in ARB_vp. */
}
if (stvp->shader_program) {
- nir_shader *nir = st_glsl_to_nir(st, &stvp->Base.Base,
- stvp->shader_program,
+ nir_shader *nir = st_glsl_to_nir(st, &stvp->Base, stvp->shader_program,
MESA_SHADER_VERTEX);
stvp->tgsi.type = PIPE_SHADER_IR_NIR;
if (ureg == NULL)
return false;
- if (stvp->Base.Base.ClipDistanceArraySize)
+ if (stvp->Base.ClipDistanceArraySize)
ureg_property(ureg, TGSI_PROPERTY_NUM_CLIPDIST_ENABLED,
- stvp->Base.Base.ClipDistanceArraySize);
- if (stvp->Base.Base.CullDistanceArraySize)
+ stvp->Base.ClipDistanceArraySize);
+ if (stvp->Base.CullDistanceArraySize)
ureg_property(ureg, TGSI_PROPERTY_NUM_CULLDIST_ENABLED,
- stvp->Base.Base.CullDistanceArraySize);
+ stvp->Base.CullDistanceArraySize);
if (ST_DEBUG & DEBUG_MESA) {
- _mesa_print_program(&stvp->Base.Base);
- _mesa_print_program_parameters(st->ctx, &stvp->Base.Base);
+ _mesa_print_program(&stvp->Base);
+ _mesa_print_program_parameters(st->ctx, &stvp->Base);
debug_printf("\n");
}
PIPE_SHADER_VERTEX,
ureg,
stvp->glsl_to_tgsi,
- &stvp->Base.Base,
+ &stvp->Base,
/* inputs */
stvp->num_inputs,
input_to_index,
error = st_translate_mesa_program(st->ctx,
PIPE_SHADER_VERTEX,
ureg,
- &stvp->Base.Base,
+ &stvp->Base,
/* inputs */
stvp->num_inputs,
input_to_index,
if (error) {
debug_printf("%s: failed to translate Mesa program:\n", __func__);
- _mesa_print_program(&stvp->Base.Base);
+ _mesa_print_program(&stvp->Base);
debug_assert(0);
return false;
}
if (key->passthrough_edgeflags)
NIR_PASS_V(vpv->tgsi.ir.nir, nir_lower_passthrough_edgeflags);
- st_finalize_nir(st, &stvp->Base.Base, vpv->tgsi.ir.nir);
+ st_finalize_nir(st, &stvp->Base, vpv->tgsi.ir.nir);
vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi);
/* driver takes ownership of IR: */
(struct st_vertex_program *) ctx->VertexProgram._Current;
struct st_vp_variant *stv;
- debug_printf("Vertex program %u\n", stvp->Base.Base.Id);
+ debug_printf("Vertex program %u\n", stvp->Base.Id);
for (stv = stvp->variants; stv; stv = stv->next) {
debug_printf("variant %p\n", stv);
*/
struct st_vertex_program
{
- struct gl_vertex_program Base; /**< The Mesa vertex program */
+ struct gl_program Base; /**< The Mesa vertex program */
struct pipe_shader_state tgsi;
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
uint64_t affected_states; /**< ST_NEW_* flags to mark dirty when binding */
static inline struct st_vertex_program *
-st_vertex_program( struct gl_vertex_program *vp )
+st_vertex_program( struct gl_program *vp )
{
return (struct st_vertex_program *)vp;
}
_tnl_InvalidateState( struct gl_context *ctx, GLuint new_state )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
- const struct gl_vertex_program *vp = ctx->VertexProgram._Current;
+ const struct gl_program *vp = ctx->VertexProgram._Current;
const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
GLuint i;
if (vp) {
GLuint i;
for (i = 0; i < MAX_VARYING; i++) {
- if (vp->Base.OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
+ if (vp->OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_GENERIC(i));
}
}
machine->FetchTexelLod = vp_fetch_texel;
machine->FetchTexelDeriv = NULL; /* not used by vertex programs */
- machine->Samplers = ctx->VertexProgram._Current->Base.SamplerUnits;
+ machine->Samplers = ctx->VertexProgram._Current->SamplerUnits;
machine->SystemValues[SYSTEM_VALUE_INSTANCE_ID][0] = (GLfloat) instID;
}
* Map the texture images which the vertex program will access (if any).
*/
static void
-map_textures(struct gl_context *ctx, const struct gl_vertex_program *vp)
+map_textures(struct gl_context *ctx, const struct gl_program *vp)
{
GLuint u;
for (u = 0; u < ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits; u++) {
- if (vp->Base.TexturesUsed[u]) {
+ if (vp->TexturesUsed[u]) {
/* Note: _Current *should* correspond to the target indicated
* in TexturesUsed[u].
*/
* Unmap the texture images which were used by the vertex program (if any).
*/
static void
-unmap_textures(struct gl_context *ctx, const struct gl_vertex_program *vp)
+unmap_textures(struct gl_context *ctx, const struct gl_program *vp)
{
GLuint u;
for (u = 0; u < ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits; u++) {
- if (vp->Base.TexturesUsed[u]) {
+ if (vp->TexturesUsed[u]) {
/* Note: _Current *should* correspond to the target indicated
* in TexturesUsed[u].
*/
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_program *program = ctx->VertexProgram._Current;
struct gl_program_machine *machine = &store->machine;
GLuint outputs[VARYING_SLOT_MAX], numOutputs;
GLuint i, j;
return GL_TRUE;
/* ARB program or vertex shader */
- _mesa_load_state_parameters(ctx, program->Base.Parameters);
+ _mesa_load_state_parameters(ctx, program->Parameters);
/* make list of outputs to save some time below */
numOutputs = 0;
for (i = 0; i < VARYING_SLOT_MAX; i++) {
- if (program->Base.OutputsWritten & BITFIELD64_BIT(i)) {
+ if (program->OutputsWritten & BITFIELD64_BIT(i)) {
outputs[numOutputs++] = i;
}
}
/* the vertex array case */
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if (program->Base.InputsRead & BITFIELD64_BIT(attr)) {
+ if (program->InputsRead & BITFIELD64_BIT(attr)) {
const GLubyte *ptr = (const GLubyte*) VB->AttribPtr[attr]->data;
const GLuint size = VB->AttribPtr[attr]->size;
const GLuint stride = VB->AttribPtr[attr]->stride;
}
/* execute the program */
- _mesa_execute_program(ctx, &program->Base, machine);
+ _mesa_execute_program(ctx, program, machine);
/* copy the output registers into the VB->attribs arrays */
for (j = 0; j < numOutputs; j++) {
}
/* FOGC is a special case. Fragment shader expects (f,0,0,1) */
- if (program->Base.OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_FOGC)) {
+ if (program->OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_FOGC)) {
store->results[VARYING_SLOT_FOGC].data[i][1] = 0.0;
store->results[VARYING_SLOT_FOGC].data[i][2] = 0.0;
store->results[VARYING_SLOT_FOGC].data[i][3] = 1.0;
}
for (i = 0; i < ctx->Const.MaxVarying; i++) {
- if (program->Base.OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
+ if (program->OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
/* Note: varying results get put into the generic attributes */
VB->AttribPtr[VERT_ATTRIB_GENERIC0+i]
= &store->results[VARYING_SLOT_VAR0 + i];
*/
void _tnl_UpdateFixedFunctionProgram( struct gl_context *ctx )
{
- const struct gl_vertex_program *prev = ctx->VertexProgram._Current;
+ const struct gl_program *prev = ctx->VertexProgram._Current;
if (!ctx->VertexProgram._Current ||
ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) {
*/
if (ctx->VertexProgram._Current != prev && ctx->Driver.BindProgram) {
ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
- (struct gl_program *) ctx->VertexProgram._Current);
+ ctx->VertexProgram._Current);
}
}
* glVertexAttrib(0, val) calls to feed into the GENERIC0 input.
* The original state gets essentially restored below.
*/
- if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 &&
- (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) {
+ if ((ctx->VertexProgram._Current->InputsRead & VERT_BIT_POS) == 0 &&
+ (ctx->VertexProgram._Current->InputsRead & VERT_BIT_GENERIC0)) {
swap_pos = true;
exec->vtx.inputs[VERT_ATTRIB_GENERIC0] = exec->vtx.inputs[0];
exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = exec->vtx.attrsz[0];
* In that case we effectively need to route the data from
* glVertexAttrib(0, val) calls to feed into the GENERIC0 input.
*/
- if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 &&
- (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) {
+ if ((ctx->VertexProgram._Current->InputsRead & VERT_BIT_POS) == 0 &&
+ (ctx->VertexProgram._Current->InputsRead & VERT_BIT_GENERIC0)) {
save->inputs[VERT_ATTRIB_GENERIC0] = save->inputs[0];
node_attrsz[VERT_ATTRIB_GENERIC0] = node_attrsz[0];
node_attrtype[VERT_ATTRIB_GENERIC0] = node_attrtype[0];