vkd3d-shader: Get rid of struct vkd3d_shader_desc.

This commit is contained in:
Henri Verbeet 2024-04-18 23:29:18 +02:00 committed by Alexandre Julliard
parent b761f1a263
commit 87c83e2ae2
Notes: Alexandre Julliard 2024-04-30 23:13:58 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/835
3 changed files with 24 additions and 29 deletions

View File

@ -215,8 +215,12 @@ struct vkd3d_shader_sm1_parser
struct vkd3d_shader_parser p;
struct
{
#define MAX_CONSTANT_COUNT 8192
uint32_t constant_def_mask[3][VKD3D_BITMAP_SIZE(MAX_CONSTANT_COUNT)];
uint32_t def_mask[VKD3D_BITMAP_SIZE(MAX_CONSTANT_COUNT)];
uint32_t count;
} constants[3];
};
/* This table is not order or position dependent. */
@ -750,15 +754,13 @@ static bool add_signature_element_from_semantic(struct vkd3d_shader_sm1_parser *
static void record_constant_register(struct vkd3d_shader_sm1_parser *sm1,
enum vkd3d_shader_d3dbc_constant_register set, uint32_t index, bool from_def)
{
struct vkd3d_shader_desc *desc = &sm1->p.shader_desc;
desc->flat_constant_count[set].used = max(desc->flat_constant_count[set].used, index + 1);
sm1->constants[set].count = max(sm1->constants[set].count, index + 1);
if (from_def)
{
/* d3d shaders have a maximum of 8192 constants; we should not overrun
* this array. */
assert((index / 32) <= ARRAY_SIZE(sm1->constant_def_mask[set]));
bitmap_set(sm1->constant_def_mask[set], index);
assert((index / 32) <= ARRAY_SIZE(sm1->constants[set].def_mask));
bitmap_set(sm1->constants[set].def_mask, index);
}
}
@ -1301,9 +1303,9 @@ static uint32_t get_external_constant_count(struct vkd3d_shader_sm1_parser *sm1,
/* Find the highest constant index which is not written by a DEF
* instruction. We can't (easily) use an FFZ function for this since it
* needs to be limited by the highest used register index. */
for (j = sm1->p.shader_desc.flat_constant_count[set].used; j > 0; --j)
for (j = sm1->constants[set].count; j > 0; --j)
{
if (!bitmap_is_set(sm1->constant_def_mask[set], j - 1))
if (!bitmap_is_set(sm1->constants[set].def_mask, j - 1))
return j;
}
@ -1354,8 +1356,8 @@ int vkd3d_shader_sm1_parser_create(const struct vkd3d_shader_compile_info *compi
++instructions->count;
}
for (i = 0; i < ARRAY_SIZE(sm1->p.shader_desc.flat_constant_count); ++i)
sm1->p.shader_desc.flat_constant_count[i].external = get_external_constant_count(sm1, i);
for (i = 0; i < ARRAY_SIZE(sm1->p.program.flat_constant_count); ++i)
sm1->p.program.flat_constant_count[i] = get_external_constant_count(sm1, i);
if (!sm1->p.failed)
ret = vkd3d_shader_parser_validate(&sm1->p);

View File

@ -1403,6 +1403,7 @@ static int scan_with_parser(const struct vkd3d_shader_compile_info *compile_info
struct vkd3d_shader_scan_descriptor_info1 local_descriptor_info1 = {0};
struct vkd3d_shader_scan_descriptor_info *descriptor_info;
struct vkd3d_shader_scan_signature_info *signature_info;
struct vsir_program *program = &parser->program;
struct vkd3d_shader_instruction *instruction;
struct vkd3d_shader_scan_context context;
int ret = VKD3D_OK;
@ -1428,27 +1429,27 @@ static int scan_with_parser(const struct vkd3d_shader_compile_info *compile_info
descriptor_info1 = &local_descriptor_info1;
}
vkd3d_shader_scan_context_init(&context, &parser->program.shader_version, compile_info,
vkd3d_shader_scan_context_init(&context, &program->shader_version, compile_info,
descriptor_info1, combined_sampler_info, message_context);
if (TRACE_ON())
vkd3d_shader_trace(&parser->program);
vkd3d_shader_trace(program);
for (i = 0; i < parser->program.instructions.count; ++i)
for (i = 0; i < program->instructions.count; ++i)
{
instruction = &parser->program.instructions.elements[i];
instruction = &program->instructions.elements[i];
if ((ret = vkd3d_shader_scan_instruction(&context, instruction)) < 0)
break;
}
for (i = 0; i < ARRAY_SIZE(parser->shader_desc.flat_constant_count); ++i)
for (i = 0; i < ARRAY_SIZE(program->flat_constant_count); ++i)
{
unsigned int size = parser->shader_desc.flat_constant_count[i].external;
struct vkd3d_shader_register_range range = {.space = 0, .first = i, .last = i};
struct vkd3d_shader_register reg = {.idx[0].offset = i, .idx_count = 1};
unsigned int size = program->flat_constant_count[i];
struct vkd3d_shader_descriptor_info1 *d;
if (parser->shader_desc.flat_constant_count[i].external)
if (size)
{
if ((d = vkd3d_shader_scan_add_descriptor(&context, VKD3D_SHADER_DESCRIPTOR_TYPE_CBV, &reg,
&range, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT)))
@ -1458,11 +1459,11 @@ static int scan_with_parser(const struct vkd3d_shader_compile_info *compile_info
if (!ret && signature_info)
{
if (!vkd3d_shader_signature_from_shader_signature(&signature_info->input, &parser->program.input_signature)
if (!vkd3d_shader_signature_from_shader_signature(&signature_info->input, &program->input_signature)
|| !vkd3d_shader_signature_from_shader_signature(&signature_info->output,
&parser->program.output_signature)
&program->output_signature)
|| !vkd3d_shader_signature_from_shader_signature(&signature_info->patch_constant,
&parser->program.patch_constant_signature))
&program->patch_constant_signature))
{
ret = VKD3D_ERROR_OUT_OF_MEMORY;
}

View File

@ -1061,14 +1061,6 @@ struct dxbc_shader_desc
struct shader_signature patch_constant_signature;
};
struct vkd3d_shader_desc
{
struct
{
uint32_t used, external;
} flat_constant_count[3];
};
struct vkd3d_shader_register_semantic
{
struct vkd3d_shader_dst_param reg;
@ -1332,6 +1324,7 @@ struct vsir_program
struct shader_signature patch_constant_signature;
unsigned int input_control_point_count, output_control_point_count;
unsigned int flat_constant_count[3];
unsigned int block_count;
unsigned int temp_count;
unsigned int ssa_count;
@ -1366,7 +1359,6 @@ struct vkd3d_shader_parser
struct vkd3d_shader_location location;
bool failed;
struct vkd3d_shader_desc shader_desc;
const struct vkd3d_shader_parser_ops *ops;
struct vsir_program program;