mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-12-15 08:03:30 -08:00
vkd3d-shader: Store a vkd3d_result in struct vkd3d_shader_parser.
This commit is contained in:
committed by
Henri Verbeet
parent
f9c71d5775
commit
bdba25d028
Notes:
Henri Verbeet
2025-10-03 00:55:08 +02:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1761
@@ -1506,8 +1506,8 @@ int d3dbc_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t c
|
||||
for (i = 0; i < ARRAY_SIZE(program->flat_constant_count); ++i)
|
||||
program->flat_constant_count[i] = get_external_constant_count(&sm1, i);
|
||||
|
||||
if (sm1.p.failed && ret >= 0)
|
||||
ret = VKD3D_ERROR_INVALID_SHADER;
|
||||
if (ret >= 0 && sm1.p.status < 0)
|
||||
ret = sm1.p.status;
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
||||
@@ -981,7 +981,7 @@ static uint32_t sm6_parser_read_uint32(struct sm6_parser *sm6)
|
||||
{
|
||||
if (sm6_parser_is_end(sm6))
|
||||
{
|
||||
sm6->p.failed = true;
|
||||
sm6->p.status = VKD3D_ERROR_INVALID_SHADER;
|
||||
return 0;
|
||||
}
|
||||
return *sm6->ptr++;
|
||||
@@ -999,7 +999,7 @@ static uint32_t sm6_parser_read_bits(struct sm6_parser *sm6, unsigned int length
|
||||
|
||||
if (sm6_parser_is_end(sm6))
|
||||
{
|
||||
sm6->p.failed = true;
|
||||
sm6->p.status = VKD3D_ERROR_INVALID_SHADER;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1011,7 +1011,7 @@ static uint32_t sm6_parser_read_bits(struct sm6_parser *sm6, unsigned int length
|
||||
++sm6->ptr;
|
||||
if (sm6_parser_is_end(sm6) && l < length)
|
||||
{
|
||||
sm6->p.failed = true;
|
||||
sm6->p.status = VKD3D_ERROR_INVALID_SHADER;
|
||||
return bits;
|
||||
}
|
||||
sm6->bitpos = 0;
|
||||
@@ -1033,7 +1033,7 @@ static uint64_t sm6_parser_read_vbr(struct sm6_parser *sm6, unsigned int length)
|
||||
|
||||
if (sm6_parser_is_end(sm6))
|
||||
{
|
||||
sm6->p.failed = true;
|
||||
sm6->p.status = VKD3D_ERROR_INVALID_SHADER;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1044,9 +1044,10 @@ static uint64_t sm6_parser_read_vbr(struct sm6_parser *sm6, unsigned int length)
|
||||
bits = sm6_parser_read_bits(sm6, length);
|
||||
result |= (uint64_t)(bits & mask) << shift;
|
||||
shift += length - 1;
|
||||
} while ((bits & flag) && !sm6->p.failed && shift < 64);
|
||||
} while ((bits & flag) && (sm6->p.status >= 0) && shift < 64);
|
||||
|
||||
sm6->p.failed |= !!(bits & flag);
|
||||
if (bits & flag)
|
||||
sm6->p.status = VKD3D_ERROR_INVALID_SHADER;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1058,7 +1059,7 @@ static void sm6_parser_align_32(struct sm6_parser *sm6)
|
||||
|
||||
if (sm6_parser_is_end(sm6))
|
||||
{
|
||||
sm6->p.failed = true;
|
||||
sm6->p.status = VKD3D_ERROR_INVALID_SHADER;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1149,8 +1150,8 @@ static enum vkd3d_result sm6_parser_read_unabbrev_record(struct sm6_parser *sm6)
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
record->operands[i] = sm6_parser_read_vbr(sm6, 6);
|
||||
if (sm6->p.failed)
|
||||
ret = VKD3D_ERROR_INVALID_SHADER;
|
||||
if (sm6->p.status < 0)
|
||||
ret = sm6->p.status;
|
||||
|
||||
if (ret < 0 || (ret = dxil_block_add_record(block, record)) < 0)
|
||||
vkd3d_free(record);
|
||||
@@ -1161,25 +1162,25 @@ static enum vkd3d_result sm6_parser_read_unabbrev_record(struct sm6_parser *sm6)
|
||||
static bool sm6_parser_read_literal_operand(struct sm6_parser *sm6, uint64_t context, uint64_t *op)
|
||||
{
|
||||
*op = context;
|
||||
return !sm6->p.failed;
|
||||
return sm6->p.status >= 0;
|
||||
}
|
||||
|
||||
static bool sm6_parser_read_fixed_operand(struct sm6_parser *sm6, uint64_t context, uint64_t *op)
|
||||
{
|
||||
*op = sm6_parser_read_bits(sm6, context);
|
||||
return !sm6->p.failed;
|
||||
return sm6->p.status >= 0;
|
||||
}
|
||||
|
||||
static bool sm6_parser_read_vbr_operand(struct sm6_parser *sm6, uint64_t context, uint64_t *op)
|
||||
{
|
||||
*op = sm6_parser_read_vbr(sm6, context);
|
||||
return !sm6->p.failed;
|
||||
return sm6->p.status >= 0;
|
||||
}
|
||||
|
||||
static bool sm6_parser_read_char6_operand(struct sm6_parser *sm6, uint64_t context, uint64_t *op)
|
||||
{
|
||||
*op = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._"[sm6_parser_read_bits(sm6, 6)];
|
||||
return !sm6->p.failed;
|
||||
return sm6->p.status >= 0;
|
||||
}
|
||||
|
||||
static bool sm6_parser_read_blob_operand(struct sm6_parser *sm6, uint64_t context, uint64_t *op)
|
||||
@@ -1199,7 +1200,7 @@ static enum vkd3d_result dxil_abbrev_init(struct dxil_abbrev *abbrev, unsigned i
|
||||
|
||||
abbrev->is_array = false;
|
||||
|
||||
for (i = 0, prev_type = 0; i < count && !sm6->p.failed; ++i)
|
||||
for (i = 0, prev_type = 0; i < count && (sm6->p.status >= 0); ++i)
|
||||
{
|
||||
if (sm6_parser_read_bits(sm6, 1))
|
||||
{
|
||||
@@ -1252,7 +1253,7 @@ static enum vkd3d_result dxil_abbrev_init(struct dxil_abbrev *abbrev, unsigned i
|
||||
|
||||
abbrev->count = count;
|
||||
|
||||
return sm6->p.failed ? VKD3D_ERROR_INVALID_SHADER : VKD3D_OK;
|
||||
return sm6->p.status;
|
||||
}
|
||||
|
||||
static enum vkd3d_result sm6_parser_add_global_abbrev(struct sm6_parser *sm6)
|
||||
@@ -1464,7 +1465,7 @@ static enum vkd3d_result dxil_block_read(struct dxil_block *parent, struct sm6_p
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (!sm6->p.failed);
|
||||
} while (sm6->p.status >= 0);
|
||||
|
||||
return VKD3D_ERROR_INVALID_SHADER;
|
||||
}
|
||||
@@ -1515,8 +1516,8 @@ static enum vkd3d_result dxil_block_init(struct dxil_block *block, const struct
|
||||
block->length = sm6_parser_read_uint32(sm6);
|
||||
block->start = sm6->ptr - sm6->start;
|
||||
|
||||
if (sm6->p.failed)
|
||||
return VKD3D_ERROR_INVALID_SHADER;
|
||||
if (sm6->p.status < 0)
|
||||
return sm6->p.status;
|
||||
|
||||
if ((block->abbrev_count = sm6_parser_compute_global_abbrev_count_for_block_id(sm6, block->id)))
|
||||
{
|
||||
@@ -8418,8 +8419,8 @@ static enum vkd3d_result sm6_parser_function_init(struct sm6_parser *sm6, const
|
||||
return VKD3D_ERROR_INVALID_SHADER;
|
||||
}
|
||||
|
||||
if (sm6->p.failed)
|
||||
return VKD3D_ERROR;
|
||||
if (sm6->p.status < 0)
|
||||
return sm6->p.status;
|
||||
|
||||
if (record->attachment)
|
||||
metadata_attachment_record_apply(record->attachment, record->code, ins, dst, sm6);
|
||||
@@ -8501,7 +8502,7 @@ static void sm6_block_emit_terminator(const struct sm6_block *block, struct sm6_
|
||||
switch_case = &block->terminator.cases[i];
|
||||
if (!(case_block = switch_case->block))
|
||||
{
|
||||
VKD3D_ASSERT(sm6->p.failed);
|
||||
VKD3D_ASSERT(sm6->p.status < 0);
|
||||
continue;
|
||||
}
|
||||
if (switch_case->is_default)
|
||||
@@ -8570,7 +8571,7 @@ static void sm6_block_emit_phi(const struct sm6_block *block, struct sm6_parser
|
||||
if (incoming_block)
|
||||
vsir_src_param_init_label(&src_params[index + 1], incoming_block->id);
|
||||
else
|
||||
VKD3D_ASSERT(sm6->p.failed);
|
||||
VKD3D_ASSERT(sm6->p.status < 0);
|
||||
}
|
||||
|
||||
dst_param_init(dst_param);
|
||||
@@ -11026,9 +11027,9 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, struct vsir_pro
|
||||
|
||||
dxil_block_destroy(&sm6->root_block);
|
||||
|
||||
if (sm6->p.failed)
|
||||
if (sm6->p.status < 0)
|
||||
{
|
||||
ret = VKD3D_ERROR_INVALID_SHADER;
|
||||
ret = sm6->p.status;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
@@ -2976,13 +2976,13 @@ int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t con
|
||||
}
|
||||
}
|
||||
if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL
|
||||
&& !sm4.has_control_point_phase && !sm4.p.failed)
|
||||
&& !sm4.has_control_point_phase && sm4.p.status >= 0)
|
||||
shader_sm4_validate_default_phase_index_ranges(&sm4);
|
||||
|
||||
if (sm4.p.failed)
|
||||
if (sm4.p.status < 0)
|
||||
{
|
||||
vsir_program_cleanup(program);
|
||||
return VKD3D_ERROR_INVALID_SHADER;
|
||||
return sm4.p.status;
|
||||
}
|
||||
|
||||
return VKD3D_OK;
|
||||
|
||||
@@ -742,7 +742,24 @@ void VKD3D_PRINTF_FUNC(3, 4) vkd3d_shader_parser_error(struct vkd3d_shader_parse
|
||||
vkd3d_shader_verror(parser->message_context, &parser->location, error, format, args);
|
||||
va_end(args);
|
||||
|
||||
parser->failed = true;
|
||||
if (parser->status >= 0)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case VKD3D_SHADER_ERROR_DXBC_OUT_OF_MEMORY:
|
||||
case VKD3D_SHADER_ERROR_TPF_OUT_OF_MEMORY:
|
||||
case VKD3D_SHADER_ERROR_SPV_OUT_OF_MEMORY:
|
||||
case VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY:
|
||||
case VKD3D_SHADER_ERROR_D3DBC_OUT_OF_MEMORY:
|
||||
case VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY:
|
||||
case VKD3D_SHADER_ERROR_FX_OUT_OF_MEMORY:
|
||||
parser->status = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
default:
|
||||
parser->status = VKD3D_ERROR_INVALID_SHADER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VKD3D_PRINTF_FUNC(3, 4) vkd3d_shader_parser_warning(struct vkd3d_shader_parser *parser,
|
||||
|
||||
@@ -1679,7 +1679,7 @@ struct vkd3d_shader_parser
|
||||
{
|
||||
struct vkd3d_shader_message_context *message_context;
|
||||
struct vkd3d_shader_location location;
|
||||
bool failed;
|
||||
enum vkd3d_result status;
|
||||
};
|
||||
|
||||
void vkd3d_shader_parser_error(struct vkd3d_shader_parser *parser,
|
||||
|
||||
Reference in New Issue
Block a user