mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader: Get rid of struct vkd3d_shader_desc.
This commit is contained in:
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
@ -215,8 +215,12 @@ struct vkd3d_shader_sm1_parser
|
|||||||
|
|
||||||
struct vkd3d_shader_parser p;
|
struct vkd3d_shader_parser p;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
#define MAX_CONSTANT_COUNT 8192
|
#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. */
|
/* 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,
|
static void record_constant_register(struct vkd3d_shader_sm1_parser *sm1,
|
||||||
enum vkd3d_shader_d3dbc_constant_register set, uint32_t index, bool from_def)
|
enum vkd3d_shader_d3dbc_constant_register set, uint32_t index, bool from_def)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_desc *desc = &sm1->p.shader_desc;
|
sm1->constants[set].count = max(sm1->constants[set].count, index + 1);
|
||||||
|
|
||||||
desc->flat_constant_count[set].used = max(desc->flat_constant_count[set].used, index + 1);
|
|
||||||
if (from_def)
|
if (from_def)
|
||||||
{
|
{
|
||||||
/* d3d shaders have a maximum of 8192 constants; we should not overrun
|
/* d3d shaders have a maximum of 8192 constants; we should not overrun
|
||||||
* this array. */
|
* this array. */
|
||||||
assert((index / 32) <= ARRAY_SIZE(sm1->constant_def_mask[set]));
|
assert((index / 32) <= ARRAY_SIZE(sm1->constants[set].def_mask));
|
||||||
bitmap_set(sm1->constant_def_mask[set], index);
|
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
|
/* 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
|
* instruction. We can't (easily) use an FFZ function for this since it
|
||||||
* needs to be limited by the highest used register index. */
|
* 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;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1354,8 +1356,8 @@ int vkd3d_shader_sm1_parser_create(const struct vkd3d_shader_compile_info *compi
|
|||||||
++instructions->count;
|
++instructions->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(sm1->p.shader_desc.flat_constant_count); ++i)
|
for (i = 0; i < ARRAY_SIZE(sm1->p.program.flat_constant_count); ++i)
|
||||||
sm1->p.shader_desc.flat_constant_count[i].external = get_external_constant_count(sm1, i);
|
sm1->p.program.flat_constant_count[i] = get_external_constant_count(sm1, i);
|
||||||
|
|
||||||
if (!sm1->p.failed)
|
if (!sm1->p.failed)
|
||||||
ret = vkd3d_shader_parser_validate(&sm1->p);
|
ret = vkd3d_shader_parser_validate(&sm1->p);
|
||||||
|
@ -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_info1 local_descriptor_info1 = {0};
|
||||||
struct vkd3d_shader_scan_descriptor_info *descriptor_info;
|
struct vkd3d_shader_scan_descriptor_info *descriptor_info;
|
||||||
struct vkd3d_shader_scan_signature_info *signature_info;
|
struct vkd3d_shader_scan_signature_info *signature_info;
|
||||||
|
struct vsir_program *program = &parser->program;
|
||||||
struct vkd3d_shader_instruction *instruction;
|
struct vkd3d_shader_instruction *instruction;
|
||||||
struct vkd3d_shader_scan_context context;
|
struct vkd3d_shader_scan_context context;
|
||||||
int ret = VKD3D_OK;
|
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;
|
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);
|
descriptor_info1, combined_sampler_info, message_context);
|
||||||
|
|
||||||
if (TRACE_ON())
|
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)
|
if ((ret = vkd3d_shader_scan_instruction(&context, instruction)) < 0)
|
||||||
break;
|
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_range range = {.space = 0, .first = i, .last = i};
|
||||||
struct vkd3d_shader_register reg = {.idx[0].offset = i, .idx_count = 1};
|
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;
|
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, ®,
|
if ((d = vkd3d_shader_scan_add_descriptor(&context, VKD3D_SHADER_DESCRIPTOR_TYPE_CBV, ®,
|
||||||
&range, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT)))
|
&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 (!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,
|
|| !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,
|
|| !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;
|
ret = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1061,14 +1061,6 @@ struct dxbc_shader_desc
|
|||||||
struct shader_signature patch_constant_signature;
|
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_register_semantic
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_dst_param reg;
|
struct vkd3d_shader_dst_param reg;
|
||||||
@ -1332,6 +1324,7 @@ struct vsir_program
|
|||||||
struct shader_signature patch_constant_signature;
|
struct shader_signature patch_constant_signature;
|
||||||
|
|
||||||
unsigned int input_control_point_count, output_control_point_count;
|
unsigned int input_control_point_count, output_control_point_count;
|
||||||
|
unsigned int flat_constant_count[3];
|
||||||
unsigned int block_count;
|
unsigned int block_count;
|
||||||
unsigned int temp_count;
|
unsigned int temp_count;
|
||||||
unsigned int ssa_count;
|
unsigned int ssa_count;
|
||||||
@ -1366,7 +1359,6 @@ struct vkd3d_shader_parser
|
|||||||
struct vkd3d_shader_location location;
|
struct vkd3d_shader_location location;
|
||||||
bool failed;
|
bool failed;
|
||||||
|
|
||||||
struct vkd3d_shader_desc shader_desc;
|
|
||||||
const struct vkd3d_shader_parser_ops *ops;
|
const struct vkd3d_shader_parser_ops *ops;
|
||||||
struct vsir_program program;
|
struct vsir_program program;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user