diff options
author | Brian Paul <[email protected]> | 2015-09-10 08:55:01 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2015-09-10 12:23:46 -0600 |
commit | a9b143a648ff77ac76ff6f4580559f1a061e37f9 (patch) | |
tree | 997484e22de0b0a4f00f96a2e93f8f6c8421a33c /src/gallium/drivers/svga | |
parent | 289804515f7de20cb41a5e1b4c20864f0dab8d51 (diff) |
svga: clean up the compile_vs/gs/fs() functions
Sipmlify structure and remove gotos.
Reviewed-by: Charmaine Lee <[email protected]>
Diffstat (limited to 'src/gallium/drivers/svga')
-rw-r--r-- | src/gallium/drivers/svga/svga_state_fs.c | 29 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state_gs.c | 19 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state_vs.c | 28 |
3 files changed, 27 insertions, 49 deletions
diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c index 5d39100f63a..c244d5352d9 100644 --- a/src/gallium/drivers/svga/svga_state_fs.c +++ b/src/gallium/drivers/svga/svga_state_fs.c @@ -136,13 +136,8 @@ compile_fs(struct svga_context *svga, debug_printf("Failed to compile fragment shader," " using dummy shader instead.\n"); variant = get_compiled_dummy_shader(svga, fs, key); - if (!variant) { - ret = PIPE_ERROR; - goto fail; - } } - - if (svga_shader_too_large(svga, variant)) { + else if (svga_shader_too_large(svga, variant)) { /* too big, use dummy shader */ debug_printf("Shader too large (%u bytes)," " using dummy shader instead.\n", @@ -152,29 +147,25 @@ compile_fs(struct svga_context *svga, svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant); /* Use simple pass-through shader instead */ variant = get_compiled_dummy_shader(svga, fs, key); - if (!variant) { - ret = PIPE_ERROR; - goto fail; - } + } + + if (!variant) { + return PIPE_ERROR; } ret = svga_define_shader(svga, SVGA3D_SHADERTYPE_PS, variant); - if (ret != PIPE_OK) - goto fail; + if (ret != PIPE_OK) { + svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant); + return ret; + } *out_variant = variant; - /* insert variants at head of linked list */ + /* insert variant at head of linked list */ variant->next = fs->base.variants; fs->base.variants = variant; return PIPE_OK; - -fail: - if (variant) { - svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant); - } - return ret; } diff --git a/src/gallium/drivers/svga/svga_state_gs.c b/src/gallium/drivers/svga/svga_state_gs.c index 9f6885b95a2..7f75410fb57 100644 --- a/src/gallium/drivers/svga/svga_state_gs.c +++ b/src/gallium/drivers/svga/svga_state_gs.c @@ -80,34 +80,29 @@ compile_gs(struct svga_context *svga, /* some problem during translation, try the dummy shader */ const struct tgsi_token *dummy = get_dummy_geometry_shader(); if (!dummy) { - ret = PIPE_ERROR_OUT_OF_MEMORY; - goto fail; + return PIPE_ERROR_OUT_OF_MEMORY; } debug_printf("Failed to compile geometry shader, using dummy shader instead.\n"); FREE((void *) gs->base.tokens); gs->base.tokens = dummy; variant = translate_geometry_program(svga, gs, key); if (variant == NULL) { - ret = PIPE_ERROR; - goto fail; + return PIPE_ERROR; } } ret = svga_define_shader(svga, SVGA3D_SHADERTYPE_GS, variant); - if (ret != PIPE_OK) - goto fail; + if (ret != PIPE_OK) { + svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_GS, variant); + return ret; + } *out_variant = variant; return PIPE_OK; - -fail: - if (variant) { - svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_GS, variant); - } - return ret; } + static void make_gs_key(struct svga_context *svga, struct svga_compile_key *key) { diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c index de41519593c..a846b779e70 100644 --- a/src/gallium/drivers/svga/svga_state_vs.c +++ b/src/gallium/drivers/svga/svga_state_vs.c @@ -127,13 +127,8 @@ compile_vs(struct svga_context *svga, debug_printf("Failed to compile vertex shader," " using dummy shader instead.\n"); variant = get_compiled_dummy_vertex_shader(svga, vs, key); - if (!variant) { - ret = PIPE_ERROR; - goto fail; - } } - - if (svga_shader_too_large(svga, variant)) { + else if (svga_shader_too_large(svga, variant)) { /* too big, use dummy shader */ debug_printf("Shader too large (%u bytes)," " using dummy shader instead.\n", @@ -143,27 +138,24 @@ compile_vs(struct svga_context *svga, svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant); /* Use simple pass-through shader instead */ variant = get_compiled_dummy_vertex_shader(svga, vs, key); - if (!variant) { - ret = PIPE_ERROR; - goto fail; - } + } + + if (!variant) { + return PIPE_ERROR; } ret = svga_define_shader(svga, SVGA3D_SHADERTYPE_VS, variant); - if (ret != PIPE_OK) - goto fail; + if (ret != PIPE_OK) { + svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant); + return ret; + } *out_variant = variant; return PIPE_OK; - -fail: - if (variant) { - svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant); - } - return ret; } + /* SVGA_NEW_PRESCALE, SVGA_NEW_RAST, SVGA_NEW_FS */ static void |