diff options
author | Axel Davy <[email protected]> | 2015-01-07 11:07:23 +0100 |
---|---|---|
committer | Axel Davy <[email protected]> | 2015-02-06 00:07:18 +0100 |
commit | a249c7a161cdbb995b17195f1af88ed14f69f8b6 (patch) | |
tree | ab7af507defc4faf5bbc588f2534b9f2d091b118 /src/gallium/state_trackers | |
parent | 65ca8e4b3d6903ef086b81a5bf94688898290c4f (diff) |
st/nine: Refactor how user constbufs sizes are calculated
Count explicitly the slots for float, int and bool constants,
and deduce the constbuf size in nine_shader.
Reviewed-by: Tiziano Bacocco <[email protected]>
Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/nine/nine_shader.c | 17 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_shader.h | 22 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.h | 5 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/pixelshader9.c | 1 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/vertexshader9.c | 2 |
5 files changed, 24 insertions, 23 deletions
diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c index 944b646b30d..3d3dcf3f6b4 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -2995,7 +2995,9 @@ tx_ctor(struct shader_translator *tx, struct nine_shader_info *info) info->position_t = FALSE; info->point_size = FALSE; - tx->info->const_used_size = 0; + tx->info->const_float_slots = 0; + tx->info->const_int_slots = 0; + tx->info->const_bool_slots = 0; info->sampler_mask = 0x0; info->rt_mask = 0x0; @@ -3065,6 +3067,7 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) struct shader_translator *tx; HRESULT hr = D3D_OK; const unsigned processor = tgsi_processor_from_type(info->type); + unsigned slot_max; user_assert(processor != ~0, D3DERR_INVALIDCALL); @@ -3196,8 +3199,16 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) hr = D3D_OK; } - if (tx->indirect_const_access) - info->const_used_size = ~0; + if (tx->indirect_const_access) /* vs only */ + info->const_float_slots = device->max_vs_const_f; + + slot_max = info->const_bool_slots > 0 ? + device->max_vs_const_f + NINE_MAX_CONST_I + + info->const_bool_slots : + info->const_int_slots > 0 ? + device->max_vs_const_f + info->const_int_slots : + info->const_float_slots; + info->const_used_size = sizeof(float[4]) * slot_max; /* slots start from 1 */ info->cso = ureg_create_shader_and_destroy(tx->ureg, device->pipe); if (!info->cso) { diff --git a/src/gallium/state_trackers/nine/nine_shader.h b/src/gallium/state_trackers/nine/nine_shader.h index ddee3724079..56c5d99b4d2 100644 --- a/src/gallium/state_trackers/nine/nine_shader.h +++ b/src/gallium/state_trackers/nine/nine_shader.h @@ -63,32 +63,30 @@ struct nine_shader_info unsigned const_b_base; /* in vec4 (16 byte) units */ unsigned const_used_size; + unsigned const_float_slots; + unsigned const_int_slots; + unsigned const_bool_slots; + struct nine_lconstf lconstf; /* out, NOTE: members to be free'd by user */ }; static INLINE void nine_info_mark_const_f_used(struct nine_shader_info *info, int idx) { - unsigned size = (idx + 1) * 16; - - if (info->const_used_size < size) - info->const_used_size = size; + if (info->const_float_slots < (idx + 1)) + info->const_float_slots = idx + 1; } static INLINE void nine_info_mark_const_i_used(struct nine_shader_info *info, int idx) { - unsigned size = (info->const_i_base + (idx + 1)) * 16; - - if (info->const_used_size < size) - info->const_used_size = size; + if (info->const_int_slots < (idx + 1)) + info->const_int_slots = idx + 1; } static INLINE void nine_info_mark_const_b_used(struct nine_shader_info *info, int idx) { - unsigned size = (info->const_b_base + ((idx + 4) / 4)) * 16; - - if (info->const_used_size < size) - info->const_used_size = size; + if (info->const_bool_slots < (idx + 1)) + info->const_bool_slots = idx + 1; } HRESULT diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index 58ca8c9f635..927bfe18cdd 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -91,11 +91,6 @@ ((nconstf) * 4 * sizeof(float) + \ NINE_MAX_CONST_I * 4 * sizeof(int)) -#define NINE_CONSTBUF_SIZE(nconstf) \ - ((nconstf) * 4 * sizeof(float) + \ - NINE_MAX_CONST_I * 4 * sizeof(int) + \ - NINE_MAX_CONST_B * 1 * sizeof(float)) - #define NINE_MAX_LIGHTS 65536 #define NINE_MAX_LIGHTS_ACTIVE 8 diff --git a/src/gallium/state_trackers/nine/pixelshader9.c b/src/gallium/state_trackers/nine/pixelshader9.c index dcd234670db..3f176a312bf 100644 --- a/src/gallium/state_trackers/nine/pixelshader9.c +++ b/src/gallium/state_trackers/nine/pixelshader9.c @@ -73,7 +73,6 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This, This->rt_mask = info.rt_mask; This->const_used_size = info.const_used_size; /* no constant relative addressing for ps */ - assert(info.const_used_size != ~0); assert(info.lconstf.data == NULL); assert(info.lconstf.ranges == NULL); diff --git a/src/gallium/state_trackers/nine/vertexshader9.c b/src/gallium/state_trackers/nine/vertexshader9.c index 3d40d60c062..bbd5ce99d9a 100644 --- a/src/gallium/state_trackers/nine/vertexshader9.c +++ b/src/gallium/state_trackers/nine/vertexshader9.c @@ -72,8 +72,6 @@ NineVertexShader9_ctor( struct NineVertexShader9 *This, This->variant.cso = info.cso; This->const_used_size = info.const_used_size; - if (info.const_used_size == ~0) - This->const_used_size = NINE_CONSTBUF_SIZE(device->max_vs_const_f); This->lconstf = info.lconstf; This->sampler_mask = info.sampler_mask; This->position_t = info.position_t; |