From 0afe0032b06774cbfd3ddb56303ee90b3b25fdbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 27 Jun 2017 22:21:43 +0200 Subject: [PATCH] libs/vkd3d-shader: Add VKD3D_SHADER_STRIP_DEBUG compiler option. --- include/vkd3d_shader.h | 1 + libs/vkd3d-shader/spirv.c | 12 +++++++++++- programs/vkd3d-compiler/main.c | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 04f95f94..0c94ae74 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -28,6 +28,7 @@ extern "C" { enum vkd3d_shader_compiler_option { VKD3D_SHADER_FLIP_Y = 0x00000001, + VKD3D_SHADER_STRIP_DEBUG = 0x00000002, VKD3D_SHADER_COMPILER_OPTIONS_FORCE_32_BIT = 0x7fffffff, }; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 7bc6517b..08cafafe 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -107,6 +107,11 @@ static void vkd3d_spirv_stream_free(struct vkd3d_spirv_stream *stream) vkd3d_free(stream->words); } +static void vkd3d_spirv_stream_clear(struct vkd3d_spirv_stream *stream) +{ + stream->word_count = 0; +} + static bool vkd3d_spirv_stream_append(struct vkd3d_spirv_stream *dst_stream, const struct vkd3d_spirv_stream *src_stream) { @@ -2170,7 +2175,12 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler bool vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, struct vkd3d_shader_code *spirv) { - if (!vkd3d_spirv_compile_module(&compiler->spirv_builder, spirv)) + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + + if (compiler->options & VKD3D_SHADER_STRIP_DEBUG) + vkd3d_spirv_stream_clear(&builder->debug_stream); + + if (!vkd3d_spirv_compile_module(builder, spirv)) return false; if (TRACE_ON()) diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index 984a378f..1acbcdc0 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -90,6 +90,7 @@ static const struct compiler_options[] = { {"--flip-y", VKD3D_SHADER_FLIP_Y}, + {"--strip-debug", VKD3D_SHADER_STRIP_DEBUG}, }; struct options @@ -142,7 +143,9 @@ int main(int argc, char **argv) if (!parse_command_line(argc, argv, &options)) { - fprintf(stderr, "usage: %s [--flip-y] [-o ] \n", argv[0]); + fprintf(stderr, + "usage: %s [--strip-degug] [--flip-y] [-o ] \n", + argv[0]); return 1; }