Sipmlify structure and remove gotos.
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
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",
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;
}
/* 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)
{
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",
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