diff --git a/src/gallium/frontends/nine/device9.c b/src/gallium/frontends/nine/device9.c index 693b914a129..c81c55915bf 100644 --- a/src/gallium/frontends/nine/device9.c +++ b/src/gallium/frontends/nine/device9.c @@ -440,25 +440,23 @@ NineDevice9_ctor( struct NineDevice9 *This, /* Create constant buffers. */ { - unsigned max_const_vs, max_const_ps; + unsigned max_const_vs; /* vs 3.0: >= 256 float constants, but for cards with exactly 256 slots, * we have to take in some more slots for int and bool*/ max_const_vs = _min(pScreen->get_shader_param(pScreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE) / sizeof(float[4]), - NINE_MAX_CONST_ALL); + NINE_MAX_CONST_ALL_VS); /* ps 3.0: 224 float constants. All cards supported support at least * 256 constants for ps */ - max_const_ps = NINE_MAX_CONST_F_PS3 + (NINE_MAX_CONST_I + NINE_MAX_CONST_B / 4); + assert(NINE_MAX_CONST_ALL_PS <= 256); This->max_vs_const_f = max_const_vs - (NINE_MAX_CONST_I + NINE_MAX_CONST_B / 4); - This->max_ps_const_f = max_const_ps - - (NINE_MAX_CONST_I + NINE_MAX_CONST_B / 4); This->vs_const_size = max_const_vs * sizeof(float[4]); - This->ps_const_size = max_const_ps * sizeof(float[4]); + This->ps_const_size = NINE_MAX_CONST_ALL_PS * sizeof(float[4]); /* Include space for I,B constants for user constbuf. */ if (This->may_swvp) { This->state.vs_const_f = CALLOC(NINE_MAX_CONST_F_SWVP * sizeof(float[4]),1); @@ -2516,7 +2514,7 @@ NineDevice9_CreateStateBlock( struct NineDevice9 *This, NINE_STATE_PS | NINE_STATE_PS_CONST | NINE_STATE_FF_PS_CONSTS; memcpy(dst->changed.rs, nine_render_states_pixel, sizeof(dst->changed.rs)); - nine_ranges_insert(&dst->changed.ps_const_f, 0, This->max_ps_const_f, + nine_ranges_insert(&dst->changed.ps_const_f, 0, NINE_MAX_CONST_F_PS3, &This->range_pool); dst->changed.ps_const_i = 0xffff; dst->changed.ps_const_b = 0xffff; diff --git a/src/gallium/frontends/nine/device9.h b/src/gallium/frontends/nine/device9.h index 51f0553959d..5ca9b55af37 100644 --- a/src/gallium/frontends/nine/device9.h +++ b/src/gallium/frontends/nine/device9.h @@ -95,7 +95,6 @@ struct NineDevice9 uint16_t vs_const_size; uint16_t ps_const_size; uint16_t max_vs_const_f; - uint16_t max_ps_const_f; struct pipe_resource *dummy_texture; struct pipe_sampler_view *dummy_sampler_view; diff --git a/src/gallium/frontends/nine/nine_shader.c b/src/gallium/frontends/nine/nine_shader.c index 4f622cb1ced..d16e9ade5cc 100644 --- a/src/gallium/frontends/nine/nine_shader.c +++ b/src/gallium/frontends/nine/nine_shader.c @@ -510,7 +510,7 @@ struct shader_translator struct sm1_local_const *lconstb; unsigned num_lconstb; - boolean slots_used[NINE_MAX_CONST_ALL]; + boolean slots_used[NINE_MAX_CONST_ALL_VS]; unsigned *slot_map; unsigned num_slots; @@ -4018,14 +4018,14 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info, num_ranges = 0; prev = -2; - for (i = 0; i < NINE_MAX_CONST_ALL; i++) { + for (i = 0; i < NINE_MAX_CONST_ALL_VS; i++) { if (tx->slots_used[i]) { if (prev != i - 1) num_ranges++; prev = i; } } - slot_map = MALLOC(NINE_MAX_CONST_ALL * sizeof(unsigned)); + slot_map = MALLOC(NINE_MAX_CONST_ALL_VS * sizeof(unsigned)); const_ranges = CALLOC(num_ranges + 1, 2 * sizeof(unsigned)); /* ranges stop when last is of size 0 */ if (!slot_map || !const_ranges) { hr = E_OUTOFMEMORY; @@ -4034,7 +4034,7 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info, c = 0; j = -1; prev = -2; - for (i = 0; i < NINE_MAX_CONST_ALL; i++) { + for (i = 0; i < NINE_MAX_CONST_ALL_VS; i++) { if (tx->slots_used[i]) { if (prev != i - 1) j++; diff --git a/src/gallium/frontends/nine/nine_state.c b/src/gallium/frontends/nine/nine_state.c index d326e6f1469..e5ff9def9ba 100644 --- a/src/gallium/frontends/nine/nine_state.c +++ b/src/gallium/frontends/nine/nine_state.c @@ -560,12 +560,12 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device) cb.user_buffer = context->ps_const_f; if (context->changed.ps_const_i) { - int *idst = (int *)&context->ps_const_f[4 * device->max_ps_const_f]; + int *idst = (int *)&context->ps_const_f[4 * NINE_MAX_CONST_F_PS3]; memcpy(idst, context->ps_const_i, sizeof(context->ps_const_i)); context->changed.ps_const_i = 0; } if (context->changed.ps_const_b) { - int *idst = (int *)&context->ps_const_f[4 * device->max_ps_const_f]; + int *idst = (int *)&context->ps_const_f[4 * NINE_MAX_CONST_F_PS3]; uint32_t *bdst = (uint32_t *)&idst[4 * NINE_MAX_CONST_I]; memcpy(bdst, context->ps_const_b, sizeof(context->ps_const_b)); context->changed.ps_const_b = 0; diff --git a/src/gallium/frontends/nine/nine_state.h b/src/gallium/frontends/nine/nine_state.h index 0c20ac058c7..4b87a6b0a21 100644 --- a/src/gallium/frontends/nine/nine_state.h +++ b/src/gallium/frontends/nine/nine_state.h @@ -111,7 +111,8 @@ #define NINE_MAX_CONST_F_SWVP 8192 #define NINE_MAX_CONST_I_SWVP 2048 #define NINE_MAX_CONST_B_SWVP 2048 -#define NINE_MAX_CONST_ALL 276 /* B consts count only 1/4 th */ +#define NINE_MAX_CONST_ALL_VS 276 /* B consts count only 1/4 th */ +#define NINE_MAX_CONST_ALL_PS (NINE_MAX_CONST_F_PS3 + (NINE_MAX_CONST_I + NINE_MAX_CONST_B / 4)) #define NINE_CONST_I_BASE(nconstf) \ ((nconstf) * 4 * sizeof(float)) diff --git a/src/gallium/frontends/nine/pixelshader9.c b/src/gallium/frontends/nine/pixelshader9.c index a6ea126d77a..45a14f31383 100644 --- a/src/gallium/frontends/nine/pixelshader9.c +++ b/src/gallium/frontends/nine/pixelshader9.c @@ -54,8 +54,8 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This, info.type = PIPE_SHADER_FRAGMENT; info.byte_code = pFunction; - info.const_i_base = NINE_CONST_I_BASE(device->max_ps_const_f) / 16; - info.const_b_base = NINE_CONST_B_BASE(device->max_ps_const_f) / 16; + info.const_i_base = NINE_CONST_I_BASE(NINE_MAX_CONST_F_PS3) / 16; + info.const_b_base = NINE_CONST_B_BASE(NINE_MAX_CONST_F_PS3) / 16; info.sampler_mask_shadow = 0x0; info.fetch4 = 0x0; info.sampler_ps1xtypes = 0x0; @@ -192,8 +192,8 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This, HRESULT hr; info.type = PIPE_SHADER_FRAGMENT; - info.const_i_base = NINE_CONST_I_BASE(device->max_ps_const_f) / 16; - info.const_b_base = NINE_CONST_B_BASE(device->max_ps_const_f) / 16; + info.const_i_base = NINE_CONST_I_BASE(NINE_MAX_CONST_F_PS3) / 16; + info.const_b_base = NINE_CONST_B_BASE(NINE_MAX_CONST_F_PS3) / 16; info.byte_code = This->byte_code.tokens; info.sampler_mask_shadow = key & 0xffff; /* intended overlap with sampler_mask_shadow */