vkd3d-shader/hlsl: Parse the partitioning attribute.

This commit is contained in:
Shaun Ren 2024-09-03 15:09:24 -04:00 committed by Henri Verbeet
parent 615ffb823b
commit 41cb29c4c8
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
4 changed files with 33 additions and 0 deletions

View File

@ -4277,6 +4277,7 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compil
ctx->domain = VKD3D_TESSELLATOR_DOMAIN_INVALID; ctx->domain = VKD3D_TESSELLATOR_DOMAIN_INVALID;
ctx->output_control_point_count = UINT_MAX; ctx->output_control_point_count = UINT_MAX;
ctx->output_primitive = 0; ctx->output_primitive = 0;
ctx->partitioning = 0;
return true; return true;
} }

View File

@ -1076,6 +1076,7 @@ struct hlsl_ctx
enum vkd3d_tessellator_domain domain; enum vkd3d_tessellator_domain domain;
unsigned int output_control_point_count; unsigned int output_control_point_count;
enum vkd3d_shader_tessellator_output_primitive output_primitive; enum vkd3d_shader_tessellator_output_primitive output_primitive;
enum vkd3d_shader_tessellator_partitioning partitioning;
/* In some cases we generate opcodes by parsing an HLSL function and then /* 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 * invoking it. If not NULL, this field is the name of the function that we

View File

@ -5964,6 +5964,34 @@ static void parse_outputtopology_attribute(struct hlsl_ctx *ctx, const struct hl
"expected \"point\", \"line\", \"triangle_cw\", or \"triangle_ccw\".", value); "expected \"point\", \"line\", \"triangle_cw\", or \"triangle_ccw\".", value);
} }
static void parse_partitioning_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 [partitioning] attribute, but got %u.", attr->args_count);
return;
}
if (!(value = get_string_argument_value(ctx, attr, 0)))
return;
if (!strcmp(value, "integer"))
ctx->partitioning = VKD3D_SHADER_TESSELLATOR_PARTITIONING_INTEGER;
else if (!strcmp(value, "pow2"))
ctx->partitioning = VKD3D_SHADER_TESSELLATOR_PARTITIONING_POW2;
else if (!strcmp(value, "fractional_even"))
ctx->partitioning = VKD3D_SHADER_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN;
else if (!strcmp(value, "fractional_odd"))
ctx->partitioning = VKD3D_SHADER_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD;
else
hlsl_error(ctx, &attr->args[0].node->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_PARTITIONING,
"Invalid tessellator partitioning \"%s\": "
"expected \"integer\", \"pow2\", \"fractional_even\", or \"fractional_odd\".", value);
}
static void parse_entry_function_attributes(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *entry_func) 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; const struct hlsl_profile_info *profile = ctx->profile;
@ -5982,6 +6010,8 @@ static void parse_entry_function_attributes(struct hlsl_ctx *ctx, const struct h
parse_outputcontrolpoints_attribute(ctx, attr); parse_outputcontrolpoints_attribute(ctx, attr);
else if (!strcmp(attr->name, "outputtopology") && profile->type == VKD3D_SHADER_TYPE_HULL) else if (!strcmp(attr->name, "outputtopology") && profile->type == VKD3D_SHADER_TYPE_HULL)
parse_outputtopology_attribute(ctx, attr); parse_outputtopology_attribute(ctx, attr);
else if (!strcmp(attr->name, "partitioning") && profile->type == VKD3D_SHADER_TYPE_HULL)
parse_partitioning_attribute(ctx, attr);
else else
hlsl_warning(ctx, &entry_func->attrs[i]->loc, VKD3D_SHADER_WARNING_HLSL_UNKNOWN_ATTRIBUTE, hlsl_warning(ctx, &entry_func->attrs[i]->loc, VKD3D_SHADER_WARNING_HLSL_UNKNOWN_ATTRIBUTE,
"Ignoring unknown attribute \"%s\".", entry_func->attrs[i]->name); "Ignoring unknown attribute \"%s\".", entry_func->attrs[i]->name);

View File

@ -157,6 +157,7 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_HLSL_INVALID_DOMAIN = 5035, VKD3D_SHADER_ERROR_HLSL_INVALID_DOMAIN = 5035,
VKD3D_SHADER_ERROR_HLSL_INVALID_CONTROL_POINT_COUNT = 5036, VKD3D_SHADER_ERROR_HLSL_INVALID_CONTROL_POINT_COUNT = 5036,
VKD3D_SHADER_ERROR_HLSL_INVALID_OUTPUT_PRIMITIVE = 5037, VKD3D_SHADER_ERROR_HLSL_INVALID_OUTPUT_PRIMITIVE = 5037,
VKD3D_SHADER_ERROR_HLSL_INVALID_PARTITIONING = 5038,
VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300,
VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO = 5301, VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO = 5301,