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 <tizbac2@gmail.com>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
This commit is contained in:
Axel Davy
2015-01-07 11:07:23 +01:00
parent 65ca8e4b3d
commit a249c7a161
5 changed files with 24 additions and 23 deletions
+14 -3
View File
@@ -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) {
+10 -12
View File
@@ -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
@@ -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
@@ -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);
@@ -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;