wined3d: Use a local parameter for the position fixup.

I don't like that I have to do this because the posFixup is in all
vertex programs, so its at the same position and could be loaded
globally.  Unfortunately, there are only 256 env parameters usually,
which makes it impossible for any shader to use c256, even if it does
not use indirect addressing, and so we can't claim 256 constant
support.
This commit is contained in:
Stefan Dösinger 2009-06-22 16:35:05 +02:00 committed by Alexandre Julliard
parent 7ffd10da28
commit 444b7ac7e5
1 changed files with 9 additions and 8 deletions

View File

@ -158,6 +158,7 @@ struct arb_vs_compiled_shader
GLuint prgId;
UINT int_consts[MAX_CONST_I];
char num_int_consts;
UINT pos_fixup;
};
struct recorded_instruction
@ -419,14 +420,16 @@ static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl)
static inline void shader_arb_vs_local_constants(IWineD3DDeviceImpl* deviceImpl)
{
IWineD3DStateBlockImpl* stateBlock;
const WineD3D_GL_Info *gl_info;
const WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
unsigned char i;
struct shader_arb_priv *priv = deviceImpl->shader_priv;
const struct arb_vs_compiled_shader *gl_shader = priv->compiled_vprog;
/* Upload the position fixup */
GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, gl_shader->pos_fixup, deviceImpl->posFixup));
if(gl_shader->num_int_consts == 0) return;
gl_info = &deviceImpl->adapter->gl_info;
stateBlock = deviceImpl->stateBlock;
for(i = 0; i < MAX_CONST_I; i++)
@ -471,9 +474,6 @@ static void shader_arb_load_constants(
stateBlock->vertexShaderConstantF,
deviceImpl->activeContext->vshader_const_dirty);
/* Upload the position fixup */
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, ARB_SHADER_PRIVCONST_POS, deviceImpl->posFixup));
shader_arb_vs_local_constants(deviceImpl);
}
@ -581,7 +581,7 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
{
if(ctx->target_version >= NV2) *num_clipplanes = GL_LIMITS(clipplanes);
else *num_clipplanes = min(GL_LIMITS(clipplanes), 4);
max_constantsF = GL_LIMITS(vshader_constantsF) - 1;
max_constantsF = GL_LIMITS(vshader_constantsF);
}
}
@ -3455,7 +3455,8 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This,
}
/* We need a constant to fixup the final position */
shader_addline(buffer, "PARAM posFixup = program.env[%d];\n", ARB_SHADER_PRIVCONST_POS);
shader_addline(buffer, "PARAM posFixup = program.local[%u];\n", next_local);
compiled->pos_fixup = next_local++;
/* Initialize output parameters. GL_ARB_vertex_program does not require special initialization values
* for output parameters. D3D in theory does not do that either, but some applications depend on a
@ -4154,7 +4155,7 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *g
pCaps->VertexShaderVersion = WINED3DVS_VERSION(1,1);
TRACE_(d3d_caps)("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n");
}
pCaps->MaxVertexShaderConst = GL_LIMITS(vshader_constantsF) - 1;
pCaps->MaxVertexShaderConst = GL_LIMITS(vshader_constantsF);
}
if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) {