From 9e7b53433fe8beb49a8c573ce8a27031b62686ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sat, 24 Oct 2009 18:17:22 -0700 Subject: [PATCH 06/16] WineD3D: use the native constant limit for fitting private constants --- dlls/wined3d/arb_program_shader.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 9b1d06a..86ead1c 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -629,13 +629,13 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s */ if (pshader) { - max_constantsF = gl_info->max_ps_arb_constantsF; + max_constantsF = gl_info->max_ps_arb_native_constants; } else { if(This->baseShader.reg_maps.usesrelconstF) { DWORD highest_constf = 0, clip_limit; - max_constantsF = gl_info->max_vs_arb_constantsF - reserved_vs_const(iface, gl_info); + max_constantsF = gl_info->max_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++) @@ -665,7 +665,7 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s { if (ctx->target_version >= NV2) *num_clipplanes = gl_info->max_clipplanes; else *num_clipplanes = min(gl_info->max_clipplanes, 4); - max_constantsF = gl_info->max_vs_arb_constantsF; + max_constantsF = gl_info->max_vs_arb_native_constants; } } @@ -698,6 +698,21 @@ 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_info->max_ps_arb_constantsF); + } + else + { + max_constantsF = min(max_constantsF, gl_info->max_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