diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 9ac5806c..5cc36e18 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -322,6 +322,14 @@ enum vkd3d_shader_compile_option_name * \since 1.12 */ VKD3D_SHADER_COMPILE_OPTION_WARN_IMPLICIT_TRUNCATION = 0x0000000c, + /** + * If \a value is nonzero, empty constant buffers descriptions are + * written out in the output effect binary. This option applies only + * to fx_4_0 and fx_4_1 profiles and is otherwise ignored. + * + * \since 1.12 + */ + VKD3D_SHADER_COMPILE_OPTION_INCLUDE_EMPTY_BUFFERS_IN_EFFECTS = 0x0000000d, VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_NAME), }; diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 5fcd3eac..466908cd 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -90,6 +90,7 @@ struct fx_write_context int status; bool child_effect; + bool include_empty_buffers; const struct fx_write_context_ops *ops; }; @@ -191,6 +192,7 @@ static void fx_write_context_init(struct hlsl_ctx *ctx, const struct fx_write_co list_init(&fx->types); fx->child_effect = fx->ops->are_child_effects_supported && ctx->child_effect; + fx->include_empty_buffers = version == 4 && ctx->include_empty_buffers; hlsl_block_init(&block); hlsl_prepend_global_uniform_copy(fx->ctx, &block); @@ -1065,7 +1067,9 @@ static void write_buffers(struct fx_write_context *fx) LIST_FOR_EACH_ENTRY(buffer, &fx->ctx->buffers, struct hlsl_buffer, entry) { - if (!buffer->size) + if (!buffer->size && !fx->include_empty_buffers) + continue; + if (!strcmp(buffer->name, "$Params")) continue; write_fx_4_buffer(buffer, fx); diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 17458963..5638a03a 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -3622,6 +3622,10 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compil ctx->warn_implicit_truncation = option->value; break; + case VKD3D_SHADER_COMPILE_OPTION_INCLUDE_EMPTY_BUFFERS_IN_EFFECTS: + ctx->include_empty_buffers = option->value; + break; + default: break; } diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 4f9f04c7..16ddbf3c 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -927,6 +927,7 @@ struct hlsl_ctx bool semantic_compat_mapping; bool child_effect; + bool include_empty_buffers; bool warn_implicit_truncation; }; diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index 1e05c093..298db2b4 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -42,6 +42,7 @@ enum OPTION_CHILD_EFFECT, OPTION_ENTRY, OPTION_FRAGMENT_COORDINATE_ORIGIN, + OPTION_INCLUDE_EMPTY_BUFFERS, OPTION_MATRIX_STORAGE_ORDER, OPTION_OUTPUT, OPTION_PRINT_SOURCE_TYPES, @@ -202,6 +203,9 @@ static void print_usage(const char *program_name) " targets. Valid values are 'upper-left' (default) and\n" " 'lower-left'. The only value supported by Vulkan\n" " environments is 'upper-left'.\n" + " --fx-include-empty-buffers\n" + " Write empty constant buffers descriptions. This option\n" + " is only meaningful for fx_4_0 and fx_4_1 profiles.\n" " --matrix-storage-order=\n" " Specify the default matrix storage order. Valid values\n" " are 'column' (default) and 'row'.\n" @@ -485,6 +489,7 @@ static bool parse_command_line(int argc, char **argv, struct options *options) {"child-effect", no_argument, NULL, OPTION_CHILD_EFFECT}, {"entry", required_argument, NULL, OPTION_ENTRY}, {"fragment-coordinate-origin", required_argument, NULL, OPTION_FRAGMENT_COORDINATE_ORIGIN}, + {"fx-include-empty-buffers", no_argument, NULL, OPTION_INCLUDE_EMPTY_BUFFERS}, {"matrix-storage-order", required_argument, NULL, OPTION_MATRIX_STORAGE_ORDER}, {"output", required_argument, NULL, OPTION_OUTPUT}, {"formatting", required_argument, NULL, OPTION_TEXT_FORMATTING}, @@ -559,6 +564,10 @@ static bool parse_command_line(int argc, char **argv, struct options *options) options->output_filename = optarg; break; + case OPTION_INCLUDE_EMPTY_BUFFERS: + add_compile_option(options, VKD3D_SHADER_COMPILE_OPTION_INCLUDE_EMPTY_BUFFERS_IN_EFFECTS, 1); + break; + case OPTION_MATRIX_STORAGE_ORDER: if (!parse_matrix_storage_order(&pack_matrix_order, optarg)) {