mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Parse the outputtopology attribute.
This commit is contained in:
parent
dae88bab52
commit
615ffb823b
Notes:
Henri Verbeet
2024-09-04 18:50:05 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1015
@ -4276,6 +4276,7 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compil
|
||||
|
||||
ctx->domain = VKD3D_TESSELLATOR_DOMAIN_INVALID;
|
||||
ctx->output_control_point_count = UINT_MAX;
|
||||
ctx->output_primitive = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1075,6 +1075,7 @@ struct hlsl_ctx
|
||||
|
||||
enum vkd3d_tessellator_domain domain;
|
||||
unsigned int output_control_point_count;
|
||||
enum vkd3d_shader_tessellator_output_primitive output_primitive;
|
||||
|
||||
/* In some cases we generate opcodes by parsing an HLSL function and then
|
||||
* invoking it. If not NULL, this field is the name of the function that we
|
||||
|
@ -5936,6 +5936,34 @@ static void parse_outputcontrolpoints_attribute(struct hlsl_ctx *ctx, const stru
|
||||
ctx->output_control_point_count = constant->value.u[0].u;
|
||||
}
|
||||
|
||||
static void parse_outputtopology_attribute(struct hlsl_ctx *ctx, const struct hlsl_attribute *attr)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
if (attr->args_count != 1)
|
||||
{
|
||||
hlsl_error(ctx, &attr->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
|
||||
"Expected 1 parameter for [outputtopology] attribute, but got %u.", attr->args_count);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(value = get_string_argument_value(ctx, attr, 0)))
|
||||
return;
|
||||
|
||||
if (!strcmp(value, "point"))
|
||||
ctx->output_primitive = VKD3D_SHADER_TESSELLATOR_OUTPUT_POINT;
|
||||
else if (!strcmp(value, "line"))
|
||||
ctx->output_primitive = VKD3D_SHADER_TESSELLATOR_OUTPUT_LINE;
|
||||
else if (!strcmp(value, "triangle_cw"))
|
||||
ctx->output_primitive = VKD3D_SHADER_TESSELLATOR_OUTPUT_TRIANGLE_CW;
|
||||
else if (!strcmp(value, "triangle_ccw"))
|
||||
ctx->output_primitive = VKD3D_SHADER_TESSELLATOR_OUTPUT_TRIANGLE_CCW;
|
||||
else
|
||||
hlsl_error(ctx, &attr->args[0].node->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_OUTPUT_PRIMITIVE,
|
||||
"Invalid tessellator output topology \"%s\": "
|
||||
"expected \"point\", \"line\", \"triangle_cw\", or \"triangle_ccw\".", value);
|
||||
}
|
||||
|
||||
static void parse_entry_function_attributes(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *entry_func)
|
||||
{
|
||||
const struct hlsl_profile_info *profile = ctx->profile;
|
||||
@ -5952,6 +5980,8 @@ static void parse_entry_function_attributes(struct hlsl_ctx *ctx, const struct h
|
||||
parse_domain_attribute(ctx, attr);
|
||||
else if (!strcmp(attr->name, "outputcontrolpoints") && profile->type == VKD3D_SHADER_TYPE_HULL)
|
||||
parse_outputcontrolpoints_attribute(ctx, attr);
|
||||
else if (!strcmp(attr->name, "outputtopology") && profile->type == VKD3D_SHADER_TYPE_HULL)
|
||||
parse_outputtopology_attribute(ctx, attr);
|
||||
else
|
||||
hlsl_warning(ctx, &entry_func->attrs[i]->loc, VKD3D_SHADER_WARNING_HLSL_UNKNOWN_ATTRIBUTE,
|
||||
"Ignoring unknown attribute \"%s\".", entry_func->attrs[i]->name);
|
||||
|
@ -156,6 +156,7 @@ enum vkd3d_shader_error
|
||||
VKD3D_SHADER_ERROR_HLSL_MISPLACED_COMPILE = 5034,
|
||||
VKD3D_SHADER_ERROR_HLSL_INVALID_DOMAIN = 5035,
|
||||
VKD3D_SHADER_ERROR_HLSL_INVALID_CONTROL_POINT_COUNT = 5036,
|
||||
VKD3D_SHADER_ERROR_HLSL_INVALID_OUTPUT_PRIMITIVE = 5037,
|
||||
|
||||
VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300,
|
||||
VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO = 5301,
|
||||
|
Loading…
Reference in New Issue
Block a user