mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/ir: Introduce vsir_program_append().
To append an instruction to the end of the vsir program.
This commit is contained in:
committed by
Henri Verbeet
parent
b4bf2af315
commit
0789578175
Notes:
Henri Verbeet
2025-07-22 17:21:09 +02:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1635
@@ -2896,7 +2896,6 @@ static void shader_sm4_validate_default_phase_index_ranges(struct vkd3d_shader_s
|
|||||||
int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags,
|
int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags,
|
||||||
struct vkd3d_shader_message_context *message_context, struct vsir_program *program)
|
struct vkd3d_shader_message_context *message_context, struct vsir_program *program)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_instruction_array *instructions;
|
|
||||||
struct vkd3d_shader_sm4_parser sm4 = {0};
|
struct vkd3d_shader_sm4_parser sm4 = {0};
|
||||||
struct dxbc_shader_desc dxbc_desc = {0};
|
struct dxbc_shader_desc dxbc_desc = {0};
|
||||||
struct vkd3d_shader_instruction *ins;
|
struct vkd3d_shader_instruction *ins;
|
||||||
@@ -2956,17 +2955,14 @@ int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t con
|
|||||||
return VKD3D_ERROR_INVALID_SHADER;
|
return VKD3D_ERROR_INVALID_SHADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
instructions = &program->instructions;
|
|
||||||
while (sm4.ptr != sm4.end)
|
while (sm4.ptr != sm4.end)
|
||||||
{
|
{
|
||||||
if (!shader_instruction_array_reserve(instructions, instructions->count + 1))
|
if (!(ins = vsir_program_append(program)))
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate instructions.\n");
|
|
||||||
vkd3d_shader_parser_error(&sm4.p, VKD3D_SHADER_ERROR_TPF_OUT_OF_MEMORY, "Out of memory.");
|
vkd3d_shader_parser_error(&sm4.p, VKD3D_SHADER_ERROR_TPF_OUT_OF_MEMORY, "Out of memory.");
|
||||||
vsir_program_cleanup(program);
|
vsir_program_cleanup(program);
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
ins = &instructions->elements[instructions->count];
|
|
||||||
shader_sm4_read_instruction(&sm4, ins);
|
shader_sm4_read_instruction(&sm4, ins);
|
||||||
|
|
||||||
if (ins->opcode == VSIR_OP_INVALID)
|
if (ins->opcode == VSIR_OP_INVALID)
|
||||||
@@ -2975,7 +2971,6 @@ int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t con
|
|||||||
vsir_program_cleanup(program);
|
vsir_program_cleanup(program);
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
++instructions->count;
|
|
||||||
}
|
}
|
||||||
if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL
|
if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL
|
||||||
&& !sm4.has_control_point_phase && !sm4.p.failed)
|
&& !sm4.has_control_point_phase && !sm4.p.failed)
|
||||||
|
@@ -1583,6 +1583,16 @@ bool vsir_instruction_init_with_params(struct vsir_program *program,
|
|||||||
struct vkd3d_shader_instruction *ins, const struct vkd3d_shader_location *location,
|
struct vkd3d_shader_instruction *ins, const struct vkd3d_shader_location *location,
|
||||||
enum vkd3d_shader_opcode opcode, unsigned int dst_count, unsigned int src_count);
|
enum vkd3d_shader_opcode opcode, unsigned int dst_count, unsigned int src_count);
|
||||||
|
|
||||||
|
static inline struct vkd3d_shader_instruction *vsir_program_append(struct vsir_program *program)
|
||||||
|
{
|
||||||
|
struct vkd3d_shader_instruction_array *array = &program->instructions;
|
||||||
|
|
||||||
|
if (!shader_instruction_array_insert_at(array, array->count, 1))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return &array->elements[array->count - 1];
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct vkd3d_shader_dst_param *vsir_program_get_dst_params(
|
static inline struct vkd3d_shader_dst_param *vsir_program_get_dst_params(
|
||||||
struct vsir_program *program, unsigned int count)
|
struct vsir_program *program, unsigned int count)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user