From 00a6542bc8accb01c8a6ac98c18f827a5f719832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Wed, 7 Oct 2009 22:30:35 +0200 Subject: [PATCH 09/18] WineD3D: use the native constant limit for fitting private constants --- dlls/wined3d/arb_program_shader.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index dfe56ec..9017eee 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -628,11 +628,11 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s * and don't know which are actually used. */ if(pshader) { - max_constantsF = GL_LIMITS(ps_arb_constantsF); + max_constantsF = GL_LIMITS(ps_arb_native_constants); } else { if(This->baseShader.reg_maps.usesrelconstF) { DWORD highest_constf = 0, clip_limit; - max_constantsF = GL_LIMITS(vs_arb_constantsF) - reserved_vs_const(iface, gl_info); + max_constantsF = GL_LIMITS(vs_arb_native_constants) - reserved_vs_const(iface, gl_info); max_constantsF -= count_bits(This->baseShader.reg_maps.integer_constants); for(i = 0; i < This->baseShader.limits.constant_float; i++) @@ -662,7 +662,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(vs_arb_constantsF); + max_constantsF = GL_LIMITS(vs_arb_native_constants); } } @@ -695,6 +695,18 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s } } + /* After subtracting privately used constants from the hardware limit(they are loaded as + * local constants), make sure the shader doesn't violate the env constant limit + */ + if(pshader) { + max_constantsF = min(max_constantsF, GL_LIMITS(ps_arb_constantsF)); + } else { + max_constantsF = min(max_constantsF, GL_LIMITS(vs_arb_constantsF)); + } + + /* Avoid declaring more constants than needed */ + max_constantsF = min(max_constantsF, This->baseShader.limits.constant_float); + /* we use the array-based constants array if the local constants are marked for loading, * because then we use indirect addressing, or when the local constant list is empty, * because then we don't know if we're using indirect addressing or not. If we're hardcoding -- 1.6.4.4